Back to index

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

List of all members.

Public Member Functions

def manage_doCustomize
def __of__

Static Public Attributes

string meta_type = 'Filesystem Properties Object'
tuple manage_options = ({'label':'Customize', 'action':'manage_main'},)
tuple security = ClassSecurityInfo()
tuple manage_main = Globals.DTMLFile('custprops', _dtmldir)

Private Member Functions

def _createZODBClone
def _readFile

Private Attributes

 _properties

Detailed Description

FSPropertiesObjects simply hold properties.

Definition at line 32 of file FSPropertiesObject.py.


Member Function Documentation

Definition at line 136 of file FSPropertiesObject.py.

00136 
00137         def __of__(self, parent):
00138             self = ImplicitAcquisitionWrapper(self, parent)
00139             self._updateFromFS()
00140             return self
00141 
00142 Globals.InitializeClass(FSPropertiesObject)
00143 
00144 registerFileExtension('props', FSPropertiesObject)
00145 registerMetaType('Properties Object', FSPropertiesObject)

Here is the call graph for this function:

Create a ZODB (editable) equivalent of this object.

Definition at line 75 of file FSPropertiesObject.py.

00075 
00076     def _createZODBClone(self):
00077         """Create a ZODB (editable) equivalent of this object."""
00078         # Create a Folder to hold the properties.
00079         obj = Folder()
00080         obj.id = self.getId()
00081         map = []
00082         for p in self._properties:
00083             # This should be secure since the properties come
00084             # from the filesystem.
00085             setattr(obj, p['id'], getattr(self, p['id']))
00086             map.append({'id': p['id'],
00087                         'type': p['type'],
00088                         'mode': 'wd',})
00089         obj._properties = tuple(map)
00090 
00091         return obj

def CMFCore.FSPropertiesObject.FSPropertiesObject._readFile (   self,
  reparse 
) [private]
Read the data from the filesystem.

Definition at line 92 of file FSPropertiesObject.py.

00092 
00093     def _readFile(self, reparse):
00094         """Read the data from the filesystem.
00095         """
00096         file = open(self._filepath, 'r') # not 'rb', as this is a text file!
00097         try:
00098             lines = file.readlines()
00099         finally:
00100             file.close()
00101 
00102         map = []
00103         lino=0
00104 
00105         for line in lines:
00106 
00107             lino = lino + 1
00108             line = line.strip()
00109 
00110             if not line or line[0] == '#':
00111                 continue
00112 
00113             try:
00114                 propname, proptv = line.split(':',1)
00115                 #XXX multi-line properties?
00116                 proptype, propvstr = proptv.split( '=', 1 )
00117                 propname = propname.strip()
00118                 proptype = proptype.strip()
00119                 propvstr = propvstr.strip()
00120                 converter = get_converter( proptype, lambda x: x )
00121                 propvalue = converter( propvstr )
00122                 # Should be safe since we're loading from
00123                 # the filesystem.
00124                 setattr(self, propname, propvalue)
00125                 map.append({'id':propname,
00126                             'type':proptype,
00127                             'mode':'',
00128                             'default_value':propvalue,
00129                             })
00130             except:
00131                 raise ValueError, ( 'Error processing line %s of %s:\n%s'
00132                                   % (lino,self._filepath,line) )
00133         self._properties = tuple(map)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.FSPropertiesObject.FSPropertiesObject.manage_doCustomize (   self,
  folder_path,
  RESPONSE = None,
  root = None,
  obj = None 
)
Makes a ZODB Based clone with the same data.

Calls _createZODBClone for the actual work.

Definition at line 56 of file FSPropertiesObject.py.

00056 
00057                            root=None, obj=None):
00058         """Makes a ZODB Based clone with the same data.
00059 
00060         Calls _createZODBClone for the actual work.
00061         """
00062         # Overridden here to provide a different redirect target.
00063 
00064         FSObject.manage_doCustomize(self, folder_path, RESPONSE, \
00065                                     root=root, obj=obj)
00066 
00067         if RESPONSE is not None:
00068             if folder_path == '.':
00069                 fpath = ()
00070             else:
00071                 fpath = tuple(folder_path.split('/'))
00072             folder = self.restrictedTraverse(fpath)
00073             RESPONSE.redirect('%s/%s/manage_propertiesForm' % (
00074                 folder.absolute_url(), self.getId()))


Member Data Documentation

Definition at line 132 of file FSPropertiesObject.py.

tuple CMFCore.FSPropertiesObject.FSPropertiesObject.manage_main = Globals.DTMLFile('custprops', _dtmldir) [static]

Definition at line 43 of file FSPropertiesObject.py.

tuple CMFCore.FSPropertiesObject.FSPropertiesObject.manage_options = ({'label':'Customize', 'action':'manage_main'},) [static]

Definition at line 38 of file FSPropertiesObject.py.

string CMFCore.FSPropertiesObject.FSPropertiesObject.meta_type = 'Filesystem Properties Object' [static]

Definition at line 36 of file FSPropertiesObject.py.

tuple CMFCore.FSPropertiesObject.FSPropertiesObject.security = ClassSecurityInfo() [static]

Definition at line 40 of file FSPropertiesObject.py.


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