1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
43 from logilab.common.deprecation import deprecated, class_deprecated |
43 from logilab.common.deprecation import deprecated, class_deprecated |
44 from logilab.common.shellutils import getlogin |
44 from logilab.common.shellutils import getlogin |
45 |
45 |
46 from cubicweb import ValidationError, NoSelectableObject, AuthenticationError |
46 from cubicweb import ValidationError, NoSelectableObject, AuthenticationError |
47 from cubicweb import cwconfig, dbapi, devtools, web, server |
47 from cubicweb import cwconfig, dbapi, devtools, web, server |
|
48 from cubicweb.utils import json |
48 from cubicweb.sobjects import notification |
49 from cubicweb.sobjects import notification |
49 from cubicweb.web import Redirect, application |
50 from cubicweb.web import Redirect, application |
50 from cubicweb.server.session import Session |
51 from cubicweb.server.session import Session |
51 from cubicweb.server.hook import SendMailOp |
52 from cubicweb.server.hook import SendMailOp |
52 from cubicweb.devtools import SYSTEM_ENTITIES, SYSTEM_RELATIONS, VIEW_VALIDATORS |
53 from cubicweb.devtools import SYSTEM_ENTITIES, SYSTEM_RELATIONS, VIEW_VALIDATORS |
82 if strict: |
83 if strict: |
83 protected_entities = yams.schema.BASE_TYPES |
84 protected_entities = yams.schema.BASE_TYPES |
84 else: |
85 else: |
85 protected_entities = yams.schema.BASE_TYPES.union(SYSTEM_ENTITIES) |
86 protected_entities = yams.schema.BASE_TYPES.union(SYSTEM_ENTITIES) |
86 return set(schema.entities()) - protected_entities |
87 return set(schema.entities()) - protected_entities |
|
88 |
|
89 class JsonValidator(object): |
|
90 def parse_string(self, data): |
|
91 json.loads(data) |
|
92 return data |
87 |
93 |
88 # email handling, to test emails sent by an application ######################## |
94 # email handling, to test emails sent by an application ######################## |
89 |
95 |
90 MAILBOX = [] |
96 MAILBOX = [] |
91 |
97 |
791 # snippets |
797 # snippets |
792 #'text/html': DTDValidator, |
798 #'text/html': DTDValidator, |
793 #'application/xhtml+xml': DTDValidator, |
799 #'application/xhtml+xml': DTDValidator, |
794 'application/xml': htmlparser.SaxOnlyValidator, |
800 'application/xml': htmlparser.SaxOnlyValidator, |
795 'text/xml': htmlparser.SaxOnlyValidator, |
801 'text/xml': htmlparser.SaxOnlyValidator, |
|
802 'application/json': JsonValidator, |
796 'text/plain': None, |
803 'text/plain': None, |
797 'text/comma-separated-values': None, |
804 'text/comma-separated-values': None, |
798 'text/x-vcard': None, |
805 'text/x-vcard': None, |
799 'text/calendar': None, |
806 'text/calendar': None, |
800 'application/json': None, |
|
801 'image/png': None, |
807 'image/png': None, |
802 } |
808 } |
803 # maps vid : validator name (override content_type_validators) |
809 # maps vid : validator name (override content_type_validators) |
804 vid_validators = dict((vid, htmlparser.VALMAP[valkey]) |
810 vid_validators = dict((vid, htmlparser.VALMAP[valkey]) |
805 for vid, valkey in VIEW_VALIDATORS.iteritems()) |
811 for vid, valkey in VIEW_VALIDATORS.iteritems()) |