Back to index

plone3  3.1.7
Public Member Functions | Private Attributes
CMFCore.DirectoryView.DirectoryRegistry Class Reference

List of all members.

Public Member Functions

def __init__
def registerFileExtension
def registerMetaType
def getTypeByExtension
def getTypeByMetaType
def registerDirectory
def registerDirectoryByKey
def registerDirectoryByPath
def reloadDirectory
def getDirectoryInfo
def listDirectories
def getCurrentKeyFormat

Private Attributes

 _meta_types
 _object_types
 _directories

Detailed Description

Definition at line 314 of file DirectoryView.py.


Constructor & Destructor Documentation

Definition at line 316 of file DirectoryView.py.

00316 
00317     def __init__(self):
00318         self._meta_types = {}
00319         self._object_types = {}
00320         self._directories = {}


Member Function Documentation

Definition at line 382 of file DirectoryView.py.

00382 
00383     def getCurrentKeyFormat(self, reg_key):
00384         # BBB: method will be removed in CMF 2.3
00385 
00386         if reg_key in self._directories:
00387             return reg_key
00388 
00389         # for DirectoryViews created with CMF versions before 2.1
00390         # a path relative to Products/ was used
00391         dirpath = reg_key.replace('\\', '/')
00392         if dirpath.startswith('Products/'):
00393             dirpath = dirpath[9:]
00394         product = ['Products']
00395         dirparts = dirpath.split('/')
00396         while dirparts:
00397             product.append(dirparts[0])
00398             dirparts = dirparts[1:]
00399             possible_key = _generateKey('.'.join(product), '/'.join(dirparts))
00400             if possible_key in self._directories:
00401                 return possible_key
00402 
00403         # for DirectoryViews created with CMF versions before 1.5
00404         # this is basically the old minimalpath() code
00405         dirpath = normalize(reg_key)
00406         index = dirpath.rfind('Products')
00407         if index == -1:
00408             index = dirpath.rfind('products')
00409         if index != -1:
00410             dirpath = dirpath[index+len('products/'):]
00411             product = ['Products']
00412             dirparts = dirpath.split('/')
00413             while dirparts:
00414                 product.append(dirparts[0])
00415                 dirparts = dirparts[1:]
00416                 possible_key = _generateKey('.'.join(product),
00417                                             '/'.join(dirparts))
00418                 if possible_key in self._directories:
00419                     return possible_key
00420 
00421         raise ValueError('Unsupported key given: %s' % reg_key)
00422 

Here is the call graph for this function:

Definition at line 372 of file DirectoryView.py.

00372 
00373     def getDirectoryInfo(self, reg_key):
00374         # This is called when we need to get hold of the information
00375         # for a minimal path. Can return None.
00376         return self._directories.get(reg_key, None)

Here is the caller graph for this function:

Definition at line 327 of file DirectoryView.py.

00327 
00328     def getTypeByExtension(self, ext):
00329         return self._object_types.get(ext, None)

Definition at line 330 of file DirectoryView.py.

00330 
00331     def getTypeByMetaType(self, mt):
00332         return self._meta_types.get(mt, None)

Definition at line 377 of file DirectoryView.py.

00377 
00378     def listDirectories(self):
00379         dirs = self._directories.keys()
00380         dirs.sort()
00381         return dirs

def CMFCore.DirectoryView.DirectoryRegistry.registerDirectory (   self,
  name,
  _prefix,
  subdirs = 1,
  ignore = ignore 
)

Definition at line 333 of file DirectoryView.py.

00333 
00334     def registerDirectory(self, name, _prefix, subdirs=1, ignore=ignore):
00335         # This what is actually called to register a
00336         # file system directory to become a FSDV.
00337         if not isinstance(_prefix, basestring):
00338             package = getPackageName(_prefix)
00339             filepath = path.join(getPackageLocation(package), name)
00340         else:
00341             warn('registerDirectory() called with deprecated _prefix type. '
00342                  'Support for paths will be removed in CMF 2.3. Please use '
00343                  'globals instead.', DeprecationWarning, stacklevel=2)
00344             filepath = path.join(_prefix, name)
00345             (package, name) = _findProductForPath(_prefix, name)
00346         reg_key = _generateKey(package, name)
00347         self.registerDirectoryByKey(filepath, reg_key, subdirs, ignore)

Here is the call graph for this function:

def CMFCore.DirectoryView.DirectoryRegistry.registerDirectoryByKey (   self,
  filepath,
  reg_key,
  subdirs = 1,
  ignore = ignore 
)

Definition at line 349 of file DirectoryView.py.

00349 
00350                                ignore=ignore):
00351         info = DirectoryInformation(filepath, reg_key, ignore)
00352         self._directories[reg_key] = info
00353         if subdirs:
00354             for entry in info.getSubdirs():
00355                 entry_filepath = path.join(filepath, entry)
00356                 entry_reg_key = '/'.join((reg_key, entry))
00357                 self.registerDirectoryByKey(entry_filepath, entry_reg_key,
00358                                             subdirs, ignore)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.DirectoryView.DirectoryRegistry.registerDirectoryByPath (   self,
  filepath,
  subdirs = 1,
  ignore = ignore 
)

Definition at line 359 of file DirectoryView.py.

00359 
00360     def registerDirectoryByPath(self, filepath, subdirs=1, ignore=ignore):
00361         warn('registerDirectoryByPath() is deprecated and will be removed in '
00362              'CMF 2.3. Please use registerDirectoryByKey() instead.',
00363              DeprecationWarning, stacklevel=2)
00364         (package, subdir) = _findProductForPath(filepath)
00365         reg_key = _generateKey(package, subdir)
00366         self.registerDirectoryByKey(filepath, reg_key, subdirs, ignore)

Here is the call graph for this function:

Definition at line 321 of file DirectoryView.py.

00321 
00322     def registerFileExtension(self, ext, klass):
00323         self._object_types[ext] = klass

Definition at line 324 of file DirectoryView.py.

00324 
00325     def registerMetaType(self, mt, klass):
00326         self._meta_types[mt] = klass

Definition at line 367 of file DirectoryView.py.

00367 
00368     def reloadDirectory(self, reg_key):
00369         info = self.getDirectoryInfo(reg_key)
00370         if info is not None:
00371             info.reload()

Here is the call graph for this function:


Member Data Documentation

Definition at line 319 of file DirectoryView.py.

Definition at line 317 of file DirectoryView.py.

Definition at line 318 of file DirectoryView.py.


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