Back to index

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

List of all members.

Public Member Functions

def __init__
def manage_doCustomize
def get_size
def getModTime
def getObjectFSPath

Public Attributes

 id

Static Public Attributes

string title = ''
tuple security = ClassSecurityInfo()

Private Member Functions

def _createZODBClone
def _readFile
def _updateFromFS

Private Attributes

 __name__
 _filepath
 _file_mod_time
 _parsed

Static Private Attributes

int _file_mod_time = 0
int _parsed = 0

Detailed Description

FSObject is a base class for all filesystem based look-alikes.

Subclasses of this class mimic ZODB based objects like Image and
DTMLMethod, but are not directly modifiable from the management
interface. They provide means to create a TTW editable copy, however.

Definition at line 39 of file FSObject.py.


Constructor & Destructor Documentation

def CMFCore.FSObject.FSObject.__init__ (   self,
  id,
  filepath,
  fullname = None,
  properties = None 
)

Definition at line 56 of file FSObject.py.

00056 
00057     def __init__(self, id, filepath, fullname=None, properties=None):
00058         if properties:
00059             # Since props come from the filesystem, this should be
00060             # safe.
00061             self.__dict__.update(properties)
00062             if fullname and properties.get('keep_extension', 0):
00063                 id = fullname
00064 
00065             cache = properties.get('cache')
00066             if cache:
00067                 self.ZCacheable_setManagerId(cache)
00068 
00069         self.id = id
00070         self.__name__ = id # __name__ is used in traceback reporting
00071         self._filepath = filepath
00072 
00073         try:
00074              self._file_mod_time = stat(filepath)[8]
00075         except:
00076              pass
00077         self._readFile(0)

Here is the call graph for this function:


Member Function Documentation

Create a ZODB (editable) equivalent of this object.

Definition at line 153 of file FSObject.py.

00153 
00154     def _createZODBClone(self):
00155         """Create a ZODB (editable) equivalent of this object."""
00156         raise NotImplementedError, "This should be implemented in a subclass."

Here is the caller graph for this function:

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

Read the file indicated by self._filepath, and parse the
data if necessary.  'reparse' is set when reading the second
time and beyond.

Reimplemented in CMFCore.FSObject.BadFile.

Definition at line 157 of file FSObject.py.

00157 
00158     def _readFile(self, reparse):
00159         """Read the data from the filesystem.
00160 
00161         Read the file indicated by self._filepath, and parse the
00162         data if necessary.  'reparse' is set when reading the second
00163         time and beyond.
00164         """
00165         raise NotImplementedError, "This should be implemented in a subclass."

Here is the caller graph for this function:

def CMFCore.FSObject.FSObject._updateFromFS (   self) [private]

Definition at line 168 of file FSObject.py.

00168 
00169     def _updateFromFS(self):
00170         parsed = self._parsed
00171         if not parsed or Globals.DevelopmentMode:
00172             try:
00173                 mtime = stat(self._filepath)[8]
00174             except:
00175                 mtime = 0
00176             if not parsed or mtime != self._file_mod_time:
00177                 # if we have to read the file again, remove the cache
00178                 self.ZCacheable_invalidate()
00179                 self._readFile(1)
00180                 self._file_mod_time = mtime
00181                 self._parsed = 1

Here is the call graph for this function:

Here is the caller graph for this function:

Get the size of the underlying file.

Definition at line 183 of file FSObject.py.

00183 
00184     def get_size(self):
00185         """Get the size of the underlying file."""
00186         return path.getsize(self._filepath)

Here is the caller graph for this function:

Return the last_modified date of the file we represent.

Returns a DateTime instance.

Definition at line 188 of file FSObject.py.

00188 
00189     def getModTime(self):
00190         """Return the last_modified date of the file we represent.
00191 
00192         Returns a DateTime instance.
00193         """
00194         self._updateFromFS()
00195         return DateTime(self._file_mod_time)

Here is the call graph for this function:

Here is the caller graph for this function:

Return the path of the file we represent

Definition at line 197 of file FSObject.py.

00197 
00198     def getObjectFSPath(self):
00199         """Return the path of the file we represent"""
00200         self._updateFromFS()
00201         return self._filepath
00202 
00203 Globals.InitializeClass(FSObject)
00204 

Here is the call graph for this function:

def CMFCore.FSObject.FSObject.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 80 of file FSObject.py.

00080 
00081                            root=None, obj=None):
00082         """Makes a ZODB Based clone with the same data.
00083 
00084         Calls _createZODBClone for the actual work.
00085         """
00086 
00087         if obj is None:
00088             obj = self._createZODBClone()
00089         parent = aq_parent(aq_inner(self))
00090 
00091         # Preserve cache manager associations
00092         cachemgr_id = self.ZCacheable_getManagerId()
00093         if ( cachemgr_id and
00094              getattr(obj, 'ZCacheable_setManagerId', None) is not None ):
00095             obj.ZCacheable_setManagerId(cachemgr_id)
00096 
00097         # If there are proxy roles we preserve them
00098         proxy_roles = getattr(aq_base(self), '_proxy_roles', None)
00099         if proxy_roles is not None and isinstance(proxy_roles, tuple):
00100             obj._proxy_roles = tuple(self._proxy_roles)
00101 
00102         # Also, preserve any permission settings that might have come
00103         # from a metadata file or from fiddling in the ZMI
00104         old_info = [x[:2] for x in self.ac_inherited_permissions(1)]
00105         for old_perm, value in old_info:
00106             p = Permission(old_perm, value, self)
00107             acquired = int(isinstance(p.getRoles(default=[]), list))
00108             rop_info = self.rolesOfPermission(old_perm)
00109             roles = [x['name'] for x in rop_info if x['selected'] != '']
00110             try:
00111                 # if obj is based on OFS.ObjectManager an acquisition context is
00112                 # required for _subobject_permissions()
00113                 obj.__of__(parent).manage_permission(old_perm, roles=roles,
00114                                                      acquire=acquired)
00115             except ValueError:
00116                 # The permission was invalid, never mind
00117                 pass
00118 
00119         skins_tool_namegetter = getattr(self, 'getSkinsFolderName', None)
00120         if skins_tool_namegetter is not None:
00121             skins_tool_name = skins_tool_namegetter()
00122         else:
00123             skins_tool_name = 'portal_skins'
00124 
00125         id = obj.getId()
00126         fpath = tuple( folder_path.split('/') )
00127         if root is None:
00128             portal_skins = getToolByName(self, skins_tool_name)
00129         else:
00130             portal_skins = root
00131         if folder_path == '.':
00132             fpath = ()
00133         folder = portal_skins.restrictedTraverse(fpath)
00134         if id in folder.objectIds():
00135             # we cant catch the badrequest so
00136             # we'll that to check before hand
00137             obj = folder._getOb(id)
00138             if RESPONSE is not None:
00139                 RESPONSE.redirect('%s/manage_main?manage_tabs_message=%s' % (
00140                     obj.absolute_url(), html_quote("An object with this id already exists")
00141                     ))
00142         else:
00143             folder._verifyObjectPaste(obj, validate_src=0)
00144             folder._setObject(id, obj)
00145 
00146             if RESPONSE is not None:
00147                 RESPONSE.redirect('%s/%s/manage_main' % (
00148                 folder.absolute_url(), id))
00149 
00150         if RESPONSE is not None:
00151             RESPONSE.redirect('%s/%s/manage_main' % (
00152                 folder.absolute_url(), id))

Here is the call graph for this function:


Member Data Documentation

Definition at line 69 of file FSObject.py.

int CMFCore.FSObject.FSObject._file_mod_time = 0 [static, private]

Definition at line 50 of file FSObject.py.

Definition at line 73 of file FSObject.py.

Definition at line 70 of file FSObject.py.

int CMFCore.FSObject.FSObject._parsed = 0 [static, private]

Definition at line 51 of file FSObject.py.

Definition at line 180 of file FSObject.py.

Definition at line 68 of file FSObject.py.

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

Reimplemented in CMFCore.FSObject.BadFile.

Definition at line 53 of file FSObject.py.

string CMFCore.FSObject.FSObject.title = '' [static]

Definition at line 49 of file FSObject.py.


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