Back to index

plone3  3.1.7
Static Public Attributes | Private Member Functions | Static Private Attributes
PloneLanguageTool.exportimport.LanguageToolXMLAdapter Class Reference
Inheritance diagram for PloneLanguageTool.exportimport.LanguageToolXMLAdapter:
Inheritance graph
[legend]
Collaboration diagram for PloneLanguageTool.exportimport.LanguageToolXMLAdapter:
Collaboration graph
[legend]

List of all members.

Static Public Attributes

string name = 'portal_languages'
list boolean_fields
list list_fields = [ "supported_langs" ]

Private Member Functions

def _exportNode
def _importNode
def _purgeProperties
def _initProperties
def _extractProperties

Static Private Attributes

 __used_for__ = ILanguageTool
string _LOGGER_ID = 'portal_languages'

Detailed Description

Definition at line 9 of file exportimport.py.


Member Function Documentation

Export the object as a DOM node

Definition at line 23 of file exportimport.py.

00023 
00024     def _exportNode(self):
00025         """Export the object as a DOM node"""
00026 
00027         node=self._extractProperties()
00028         self._logger.info('Plone language tool exported.')
00029 
00030         return node

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 70 of file exportimport.py.

00070 
00071     def _extractProperties(self):
00072         node=self._doc.createElement('object')
00073         child=self._doc.createElement('default_language')
00074         child.setAttribute('value', self.context.getDefaultLanguage())
00075         node.appendChild(child)
00076 
00077         for field in self.boolean_fields:
00078             child=self._doc.createElement(field)
00079             child.setAttribute('value', str(bool(getattr(self.context, field))))
00080             node.appendChild(child)
00081 
00082         for field in self.list_fields:
00083             child=self._doc.createElement(field)
00084             value=getattr(self.context, field)
00085             for item in value:
00086                 element = self._doc.createElement('element')
00087                 element.setAttribute('value', item)
00088                 child.appendChild(element)
00089             node.appendChild(child)
00090 
00091         return node
00092 
00093 

Here is the call graph for this function:

Here is the caller graph for this function:

Import the object from the DOM node

Definition at line 31 of file exportimport.py.

00031 
00032     def _importNode(self, node):
00033         """Import the object from the DOM node"""
00034 
00035         if self.environ.shouldPurge():
00036             self._purgeProperties()
00037 
00038         self._initProperties(node)
00039 
00040         self._logger.info('Plone language tool imported.')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 52 of file exportimport.py.

00052 
00053     def _initProperties(self, node):
00054         for child in node.childNodes:
00055             if child.nodeName in self.boolean_fields:
00056                 value = self._convertToBoolean(child.getAttribute('value'))
00057                 setattr(self.context, child.nodeName, value)
00058             elif child.nodeName in self.list_fields:
00059                 purge = self._convertToBoolean(child.getAttribute('purge') or 'True') 
00060                 if purge:
00061                     value = []
00062                 else:
00063                     value = getattr(self.context, child.nodeName)
00064                 for element in child.childNodes:
00065                     if element.nodeName=='element':
00066                         value.append(str(element.getAttribute('value')))
00067                 setattr(self.context, child.nodeName, value)
00068             elif child.nodeName=='default_language':
00069                 self.context.setDefaultLanguage(str(child.getAttribute('value')))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 41 of file exportimport.py.

00041 
00042     def _purgeProperties(self):
00043         self.context.supported_langs = [ 'en' ]
00044         self.context.use_path_negotiation = 1
00045         self.context.use_cookie_negotiation = 1
00046         self.context.use_request_negotiation = 1
00047         self.context.use_cctld_negotiation = 0
00048         self.context.use_combined_language_codes = 0
00049         self.context.display_flags = 1
00050         self.context.start_neutral = 1
00051         self.context.setDefaultLanguage("en")

Here is the caller graph for this function:


Member Data Documentation

Definition at line 11 of file exportimport.py.

string PloneLanguageTool.exportimport.LanguageToolXMLAdapter._LOGGER_ID = 'portal_languages' [static, private]

Definition at line 13 of file exportimport.py.

Initial value:
[ "use_path_negotiation", "use_cookie_negotiation",
                        "use_request_negotiation", "use_cctld_negotiation",
                        "use_combined_language_codes", "display_flags",
                        "start_neutral" ]

Definition at line 17 of file exportimport.py.

Definition at line 21 of file exportimport.py.

string PloneLanguageTool.exportimport.LanguageToolXMLAdapter.name = 'portal_languages' [static]

Definition at line 15 of file exportimport.py.


The documentation for this class was generated from the following file: