Commit 62261452 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Move interfaces and mixins for patchable and json_representable to ERP5Type

parent 2e6fe715
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
############################################################################## ##############################################################################
import json import json
import xmldict import xmltodict
import zope.interface import zope.interface
from OFS import XMLExportImport from OFS import XMLExportImport
from StringIO import StringIO from StringIO import StringIO
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5.interfaces.json_representable import IJSONRepresentable from Products.ERP5Type.interfaces.json_representable import IJSONRepresentable
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
...@@ -42,18 +42,18 @@ class JSONRepresentableMixin: ...@@ -42,18 +42,18 @@ class JSONRepresentableMixin:
An implementation for IJSONRepresentable An implementation for IJSONRepresentable
""" """
zope.interface.implements(IJSONRepresentable)
# Declarative Security # Declarative Security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
zope.interface.implements(IJSONRepresentable)
security.declareProtected(Permissions.AccessContentsInformation, 'asJSON') security.declareProtected(Permissions.AccessContentsInformation, 'asJSON')
def asJSON(self): def asJSON(self):
""" """
Generate a JSON representable content for ERP5 object Generate a JSON representable content for ERP5 object
Currently we use `asXML` to first convert the object to its XML Currently we use `XMLExportImport` to first convert the object to its XML
respresentation and then use xmltodict to convert it to dict and JSON respresentation and then use xmltodict to convert it to dict and JSON
format finally format finally
""" """
...@@ -65,10 +65,6 @@ class JSONRepresentableMixin: ...@@ -65,10 +65,6 @@ class JSONRepresentableMixin:
xml_value = f.getvalue() xml_value = f.getvalue()
# Convert the XML to json representation # Convert the XML to json representation
return json.dumps(xmldict.xml_to_dict(xml_value)) return json.dumps(xmltodict.parse(xml_value))
security.declareProtected(Permissions.AccessContentsInformation, 'fromJSON')
def fromJSON(self):
pass
InitializeClass(JSONRepresentableMixin) InitializeClass(JSONRepresentableMixin)
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
import zope.interface import zope.interface
from Products.ERP5.interfaces.patchable import IPatchable from Products.ERP5Type.interfaces.patchable import IPatchable
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment