Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
GenericSetup.utils.ImportConfiguratorBase Class Reference
Inheritance diagram for GenericSetup.utils.ImportConfiguratorBase:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.utils.ImportConfiguratorBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def parseXML

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _extractNode
def _getSharedImportMapping
def _convertToBoolean
def _convertToUnique

Private Attributes

 _site
 _encoding

Detailed Description

Synthesize data from XML description.

Definition at line 196 of file utils.py.


Constructor & Destructor Documentation

def GenericSetup.utils.ImportConfiguratorBase.__init__ (   self,
  site,
  encoding = None 
)

Definition at line 203 of file utils.py.

00203 
00204     def __init__(self, site, encoding=None):
00205 
00206         self._site = site
00207         self._encoding = encoding


Member Function Documentation

Definition at line 297 of file utils.py.

00297 
00298     def _convertToBoolean(self, val):
00299 
00300         return val.lower() in ('true', 'yes', '1')

Here is the caller graph for this function:

Definition at line 301 of file utils.py.

00301 
00302     def _convertToUnique(self, val):
00303 
00304         assert len(val) == 1
00305         return val[0]
00306 
00307 InitializeClass(ImportConfiguratorBase)
00308 

Here is the caller graph for this function:

def GenericSetup.utils.ImportConfiguratorBase._extractNode (   self,
  node 
) [private]
Please see docs/configurator.txt for information about the
import mapping syntax.

Definition at line 222 of file utils.py.

00222 
00223     def _extractNode(self, node):
00224         """ Please see docs/configurator.txt for information about the
00225         import mapping syntax.
00226         """
00227         nodes_map = self._getImportMapping()
00228         if node.nodeName not in nodes_map:
00229             nodes_map = self._getSharedImportMapping()
00230             if node.nodeName not in nodes_map:
00231                 raise ValueError('Unknown node: %s' % node.nodeName)
00232         node_map = nodes_map[node.nodeName]
00233         info = {}
00234 
00235         for name, val in node.attributes.items():
00236             key = node_map[name].get( KEY, str(name) )
00237             val = self._encoding and val.encode(self._encoding) or val
00238             info[key] = val
00239 
00240         for child in node.childNodes:
00241             name = child.nodeName
00242 
00243             if name == '#comment':
00244                 continue
00245 
00246             if not name == '#text':
00247                 key = node_map[name].get(KEY, str(name) )
00248                 info[key] = info.setdefault( key, () ) + (
00249                                                     self._extractNode(child),)
00250 
00251             elif '#text' in node_map:
00252                 key = node_map['#text'].get(KEY, 'value')
00253                 val = child.nodeValue.lstrip()
00254                 val = self._encoding and val.encode(self._encoding) or val
00255                 info[key] = info.setdefault(key, '') + val
00256 
00257         for k, v in node_map.items():
00258             key = v.get(KEY, k)
00259 
00260             if DEFAULT in v and not key in info:
00261                 if isinstance( v[DEFAULT], basestring ):
00262                     info[key] = v[DEFAULT] % info
00263                 else:
00264                     info[key] = v[DEFAULT]
00265 
00266             elif CONVERTER in v and key in info:
00267                 info[key] = v[CONVERTER]( info[key] )
00268 
00269             if key is None:
00270                 info = info[key]
00271 
00272         return info

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 273 of file utils.py.

00273 
00274     def _getSharedImportMapping(self):
00275 
00276         return {
00277           'object':
00278             { 'i18n:domain':     {},
00279               'name':            {KEY: 'id'},
00280               'meta_type':       {},
00281               'insert-before':   {},
00282               'insert-after':    {},
00283               'property':        {KEY: 'properties', DEFAULT: ()},
00284               'object':          {KEY: 'objects', DEFAULT: ()},
00285               'xmlns:i18n':      {} },
00286           'property':
00287             { 'name':            {KEY: 'id'},
00288               '#text':           {KEY: 'value', DEFAULT: ''},
00289               'element':         {KEY: 'elements', DEFAULT: ()},
00290               'type':            {},
00291               'select_variable': {},
00292               'i18n:translate':  {} },
00293           'element':
00294             { 'value':           {KEY: None} },
00295           'description':
00296             { '#text':           {KEY: None, DEFAULT: ''} } }

Here is the caller graph for this function:

Pseudo API.

Definition at line 209 of file utils.py.

00209 
00210     def parseXML(self, xml):
00211         """ Pseudo API.
00212         """
00213         reader = getattr(xml, 'read', None)
00214 
00215         if reader is not None:
00216             xml = reader()
00217 
00218         dom = parseString(xml)
00219         root = dom.documentElement
00220 
00221         return self._extractNode(root)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 206 of file utils.py.

Definition at line 205 of file utils.py.

tuple GenericSetup.utils.ImportConfiguratorBase.security = ClassSecurityInfo() [static]

Definition at line 200 of file utils.py.


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