Example #1
0
 def registerDirectory(self, name, _prefix, subdirs=1, ignore=ignore):
     # This what is actually called to register a
     # file system directory to become a FSDV.
     if not isinstance(_prefix, basestring):
         package = getPackageName(_prefix)
         filepath = path.join(getPackageLocation(package), name)
     else:
         warn('registerDirectory() called with deprecated _prefix type. '
              'Support for paths will be removed in CMF 2.3. Please use '
              'globals instead.', DeprecationWarning, stacklevel=2)
         filepath = path.join(_prefix, name)
         (package, name) = _findProductForPath(_prefix, name)
     reg_key = _generateKey(package, name)
     self.registerDirectoryByKey(filepath, reg_key, subdirs, ignore)
Example #2
0
 def registerDirectory(self, name, _prefix, subdirs=1, ignore=ignore):
     # This what is actually called to register a
     # file system directory to become a FSDV.
     if not isinstance(_prefix, basestring):
         package = getPackageName(_prefix)
         filepath = path.join(getPackageLocation(package), name)
     else:
         warn('registerDirectory() called with deprecated _prefix type. '
              'Support for paths will be removed in CMF 2.3. Please use '
              'globals instead.', DeprecationWarning, stacklevel=2)
         filepath = path.join(_prefix, name)
         (package, name) = _findProductForPath(_prefix, name)
     reg_key = _generateKey(package, name)
     self.registerDirectoryByKey(filepath, reg_key, subdirs, ignore)
Example #3
0
def addDirectoryViews(ob, name, _prefix):
    """ Add a directory view for every subdirectory of the given directory.

    Meant to be called by filesystem-based code. Note that registerDirectory()
    still needs to be called by product initialization code to satisfy
    persistence demands.
    """
    if not isinstance(_prefix, basestring):
        package = getPackageName(_prefix)
    else:
        warn('addDirectoryViews() called with deprecated _prefix type. '
             'Support for paths will be removed in CMF 2.3. Please use '
             'globals instead.', DeprecationWarning, stacklevel=2)
        (package, name) = _findProductForPath(_prefix, name)
    reg_key = _generateKey(package, name)
    info = _dirreg.getDirectoryInfo(reg_key)
    if info is None:
        raise ValueError('Not a registered directory: %s' % reg_key)
    for entry in info.getSubdirs():
        entry_reg_key = '/'.join((reg_key, entry))
        createDirectoryView(ob, entry_reg_key, entry)
Example #4
0
def addDirectoryViews(ob, name, _prefix):
    """ Add a directory view for every subdirectory of the given directory.

    Meant to be called by filesystem-based code. Note that registerDirectory()
    still needs to be called by product initialization code to satisfy
    persistence demands.
    """
    if not isinstance(_prefix, basestring):
        package = getPackageName(_prefix)
    else:
        warn('addDirectoryViews() called with deprecated _prefix type. '
             'Support for paths will be removed in CMF 2.3. Please use '
             'globals instead.', DeprecationWarning, stacklevel=2)
        (package, name) = _findProductForPath(_prefix, name)
    reg_key = _generateKey(package, name)
    info = _dirreg.getDirectoryInfo(reg_key)
    if info is None:
        raise ValueError('Not a registered directory: %s' % reg_key)
    for entry in info.getSubdirs():
        entry_reg_key = '/'.join((reg_key, entry))
        createDirectoryView(ob, entry_reg_key, entry)