Back to index

plone3  3.1.7
Private Member Functions | Static Private Attributes
plone.app.viewletmanager.exportimport.storage.ViewletSettingsStorageNodeAdapter Class Reference
Inheritance diagram for plone.app.viewletmanager.exportimport.storage.ViewletSettingsStorageNodeAdapter:
Inheritance graph
[legend]
Collaboration diagram for plone.app.viewletmanager.exportimport.storage.ViewletSettingsStorageNodeAdapter:
Collaboration graph
[legend]

List of all members.

Private Member Functions

def _exportNode
def _importNode
def _purgeViewletSettings
def _computeValues

Static Private Attributes

 __used_for__ = IViewletSettingsStorage

Detailed Description

Definition at line 55 of file storage.py.


Member Function Documentation

Definition at line 146 of file storage.py.

00146 
00147     def _computeValues(self, values, node):
00148         for child in node.childNodes:
00149             if child.nodeName != 'viewlet':
00150                 continue
00151             viewlet_name = child.getAttribute('name')
00152             if viewlet_name in values:
00153                 values.remove(viewlet_name)
00154 
00155             if child.hasAttribute('insert-before'):
00156                 insert_before = child.getAttribute('insert-before')
00157                 if insert_before == '*':
00158                     values.insert(0, viewlet_name)
00159                     continue
00160                 else:
00161                     try:
00162                         index = values.index(insert_before)
00163                         values.insert(index, viewlet_name)
00164                         continue
00165                     except ValueError:
00166                         pass
00167             elif child.hasAttribute('insert-after'):
00168                 insert_after = child.getAttribute('insert-after')
00169                 if insert_after == '*':
00170                     pass
00171                 else:
00172                     try:
00173                         index = values.index(insert_after)
00174                         values.insert(index+1, viewlet_name)
00175                         continue
00176                     except ValueError:
00177                         pass
00178 
00179             if not child.hasAttribute('remove'):
00180                 values.append(viewlet_name)
00181 
00182         return values
00183 

Here is the caller graph for this function:

Export the object as a DOM node.

Definition at line 58 of file storage.py.

00058 
00059     def _exportNode(self):
00060         """
00061         Export the object as a DOM node.
00062         """
00063         output = self._doc.createElement('object')
00064         for nodename in ('order', 'hidden'):
00065             skins = getattr(self.context, '_'+nodename)
00066             for skin in skins:
00067                 for name in skins[skin]:
00068                     node = self._doc.createElement(nodename)
00069                     node.setAttribute('skinname', skin)
00070                     node.setAttribute('manager', name)
00071                     for viewlet in skins[skin][name]:
00072                         child = self._doc.createElement('viewlet')
00073                         child.setAttribute('name', viewlet)
00074                         node.appendChild(child)
00075                     output.appendChild(node)
00076         return output

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 77 of file storage.py.

00077 
00078     def _importNode(self, node):
00079         """
00080         Import the object from the DOM node.
00081         """
00082         storage = self.context
00083         purge = self.environ.shouldPurge()
00084         if node.getAttribute('purge'):
00085             purge = self._convertToBoolean(node.getAttribute('purge'))
00086         if purge:
00087             self._purgeViewletSettings()
00088         for child in node.childNodes:
00089             nodename = child.nodeName
00090             if nodename not in ('order', 'hidden'):
00091                 continue
00092             purgeChild = False
00093             if child.getAttribute('purge'):
00094                 purgeChild = self._convertToBoolean(
00095                                                   child.getAttribute('purge'))
00096             skinname = child.getAttribute('skinname')
00097             manager = child.getAttribute('manager')
00098             skins = getattr(storage, '_'+nodename)
00099             if skinname == '*':
00100                 for skinname in skins:
00101                     values = []
00102                     if not purgeChild:
00103                         values = list(skins[skinname].get(manager, []))
00104                     values = self._computeValues(values, child)
00105                     if nodename == 'order':
00106                         storage.setOrder(manager, skinname, tuple(values))
00107                     elif nodename == 'hidden':
00108                         storage.setHidden(manager, skinname, tuple(values))
00109 
00110             else:
00111                 values = []
00112                 if skinname in skins and not purgeChild:
00113                     values = list(skins[skinname].get(manager, []))
00114                 basename = child.getAttribute('based-on')
00115                 if basename in skins:
00116                     oldvalues = values
00117                     values = list(skins[basename].get(manager, []))
00118                     for value in oldvalues:
00119                         if value not in values:
00120                             viewlet = self._doc.createElement('viewlet')
00121                             viewlet.setAttribute('name', value)
00122                             if oldvalues.index(value) == 0:
00123                                 viewlet.setAttribute('insert-before', '*')
00124                             else:
00125                                 pos = oldvalues[oldvalues.index(value)-1]
00126                                 viewlet.setAttribute('insert-after', pos)
00127                             child.appendChild(viewlet)
00128                 values = self._computeValues(values, child)
00129                 if nodename == 'order':
00130                     storage.setOrder(manager, skinname, tuple(values))
00131                 elif nodename == 'hidden':
00132                     storage.setHidden(manager, skinname, tuple(values))
00133 
00134                 if child.hasAttribute('make_default'):
00135                     make_default = self._convertToBoolean(
00136                                         child.getAttribute('make_default'))
00137                     if make_default == True:
00138                         storage.setDefault(manager, skinname)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 139 of file storage.py.

00139 
00140     def _purgeViewletSettings(self):
00141         storage = self.context
00142         for key in storage._order:
00143             storage._order[key].clear()
00144         for key in storage._hidden:
00145             storage._hidden[key].clear()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 56 of file storage.py.


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