- class PloneLocalFolderNG(BaseContent):
PloneLocalFolderNG (part of the CMF Collective project on SourceForge) is a Plone2-only product to mount a local filesystem as a folder into a Plone site.
Essentially, PloneLocalFolderNG (aka PLFNG) provides a convenient way to make a (large) set of files accessible in a Plone site without the overhead of importing the files as Plone objects. A single PLFNG object instance in a Plone site proxies the entire contents of a specific filesystem path on the Plone site server as pseudo Plone objects. These proxy`d files are NOT 1st-class Plone citizens, so they don`t have the rich set of Plone object features like workflow state, individually assignable access permissions, etc.
So why use PLFNG? lets say you have lots of files (e.g., thousands of .pdf`s, or maybe more autogenerated javadoc/doxygen/etc files than you you really care to actually count) that you need to make available on your Plone site, but don`t want to crush your Plone server`s underlying Zope object store (ZODB) by creating a Zope object instance for each of these files. With PLFNG, you can simply upload (HTMLFormUploadFile method) through the regular portal web interface a .zip file containing all of these files, and then unpack (unpackFile method) its contents. If you have TextIndexNG2 installed, you can then catalog the textual contents of the proxy`d files (including filetypes like .html, .pdf, .ppt., and .doc) for search operations.
overview of PLFNG`s features:
- basic file / folder actions (add/upload, delete, move)
- file unpacking (just .zip format for now)
- metadata for files and folders
- file backup & revisioning support (when files deleted or overwritten)
- ZCatalog text indexing of file contents (via TextIndexNG2)
- filters for hiding files and/or folders
- support for counting (via mxmCount) and/or logging file accesses
- file space quota limit support
- MD5-based file integrity testing
- support for and/or disregard of OS file permissions settings
- auto-load of a 'default file' on PLFNG base object access
- configurable settings for most PLFNG features
As you might imagine, these features are need-driven from a variety of real-world use cases, including (but not limited to) the following:
I am a Plone site manager that needs to be able to quickly add a bunch of files to my Plone site.
(handled by adding PLFNG instance to Plone site & copying the files to Plone site server`s filesystem)My Plone site users need to be able to upload either a couple or a bunch of files to the Plone site.
(handled by PLFNG web-based file upload with optional ability to unpack .zip files 'in place' on the Plone site)My Plone site users need to be able to provide useful metadata (such as comments/notes, descriptive titles, etc) to files on the Plone site.
(handled by PLFNG's item-level metadata support)Sometimes previous revisions of files need to be kept in case my Plone site users inadvertantly delete or overwrite them.
(handled by PLFNG's file backup and file revision metadata mechanisms)My Plone site users need to be able to perform key word searches on a bunch of files on the Plone site.
(handled by PLFNG's Zcatalog text indexing mechanism, which can be configured to exclude cataloging of certain file types)I need to hide the existance of certain files and/or folders (based on name prefix, suffix, and or exact name match) from my Plone site users. For example, hide any files beginning with '.' (eg '.bashrc') or ending with '.metadata'. Also, hide all of the CVS-related folders (eg, folders named 'CVS').
(handled by PLFNG's file and folder hiding mechanisms)I am a Plone site manager that needs to know how many times specific files on my Plone site have been accessed.
(handled by PLFNG's support of the mxmCount-based hit counter)I am a Plone site manager that needs to know which users have accessed specific files.
(handled by PLFNG's file access logging mechanism)=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- __bobo_traverse__(REQUEST, name, RESPONSE=None):
- This will make this container traversable
- __call__(REQUEST=None, RESPONSE=None, *args, **kw):
Invokes a particular action on an item contained by the PLFNG instance. The item to take action on is identified via the '_e' field of self.REQUEST. The action to take is identified via the 'action' field of self.REQUEST.
Parameters:
- REQUEST: the standard HTML request data structure.
- RESPONSE: the standard HTML response data structure.
- *args: unused by this method.
- **kw: unused by this method.
Return:
- refer to following table:
item type REQUEST.get('action') return value file 'catalog' self.catalogContents() 'deleteFile' present results of deleteFile action via portal_status_message 'plfng_view' redirect on file's parent 'editMetadata' 'plfng_editMetadata' redirect on file's parent 'unpack' present results of deleteFile action via portal_status_message 'plfng_view' redirect on file's parent None redirect to showFile() on file subfolder 'deleteFolder' present results of deleteFile action via portal_status_message 'plfng_view' redirect on folder's parent None If 'default_page' field for the PLFNG object is set, return showFile() on the file by the subfolder) with the name specified in 'default_page'. Otherwise, 'plfng_view' redirect on the subfolder. the base PLFNG obj n/a
- if REQUEST == None :
- return None
- else :
- 'plfng_view' redirect to self redirect to self
- addFile(sourceFSfullPath, destPLFNGrelativePath='', destBasename=None, moveFile=0, inputMD5=None):
add a file on the Plone site`s filesystem to the file space of the PLFNG instance. This method supports a variety of enhanced PLFNG features, including file space quota limit support, file backup & revisioning support, and MD5-based file integrity testing. It also screens for illegal destination file and path names.
Parameters:
- sourceFSfullPath: the full path name of the file on the filesystem that is to be added to the PLFNG instance.
- destPLFNGrelativePath: the relative path within the PLFNG instance that the file is to be added to. If the does not exist, it will be created.
- destBasename: (default=None) the optional name for the newly added file. If not provided, the name of the added file will be the same as the source file name.
- moveFile: (default=0) flag to control whether the source file is to be copied (moveFile=0) or moved (moveFile=1) to the file space of the PLFNG instance.
- inputMD5: (default=None) the optional MD5 checksum, in 32 character long hexadecimal format, for the file that is to be added to the PLFNG instance. If provided, it must match the server-generated MD5 checksum for the file in order for file to be added to the PLFNG instance. Note, this mainly to support the file uploads via HTMLFormUploadFile() with MD5 validation.
Return:
- refer to following table:
- allowedContentTypes():
- List type info objects for types which can be added in this folder.
- breadcrumbs(instance):
- breadcrumbs
- contentValues(spec=None, filter=None, sort_on=None, reverse=0):
- CMFPlone.PloneFolder.PloneFolder.contentValues
- create_directory(dirname, REQUEST):
- create a sub-directory
- deleteFile(fileToDelete, REQUEST, RESPONSE):
- delete the file
- deleteFolder(folderToDelete):
- delete the folder
- folderlistingFolderContents(spec=None, contentFilter=None, suppressHiddenFiles=0):
- Calls listFolderContents in protected only by ACI so that folder_listing can work without the List folder contents permission, as in CMFDefault
- getAddressDisplayStyleVocab():
- vocabulary method for 'folder_address_display_style' attribute
- getAvailableQuotaSpace():
- get the remaining space in # of bytes that are available for storage by the PLFNG instance without violating its byte quantity quota limit. A positive or zero return value indicates remaining space in # of bytes. A negative return value indicates that parent-level quota_maxbytes attribute is to be used to determine the remaining space in # of bytes
- getFileMetadata(section="GENERAL", option="comment", rel_dir=''):
wrapper method of util.getMetadataElement() to enable page templates to get a specified subset of the metadata for a file or folder contained by the PLFNG instance.
Parameters:
- section:
- option:
- rel_dir:
Return:
- the specified subset of the metadata for the item.
- getFileRealPath():
get the real (file system) path for the file
Parameters:
- none
Return:
- the file system path for the file.
- getFilteredContents(rel_dir=None):
- list filtered content of local filesystem
- getFilteredOutContents(rel_dir=None):
- list filtered out content of local filesystem
- getMoveActionRestrictionsVocab():
- Not documented.
- getProperties(REQUEST=None):
- get the summary properties for the local filesystem directory for this class instance
- get_size():
- return the size of the underlying contents
- HTMLFormUploadFile(upload, comment, clientMD5=None):
- upload a file via HTML form-based file upload mechanism
- listFolderContents(spec=None, contentFilter=None, suppressHiddenFiles=0, REQUEST=None, RESPONSE=None):
- list content of local filesystem
- moveFile(sourceFSfullPath, destFSfullPath):
- move a file. destFSfullPath can be a file or folder
- setFileMetadata(section, option, newvalue):
- set the metadata for the file
- showFile(destpath, REQUEST, RESPONSE):
- view file
- unpackFile(plfngRelativeDir, FSpackedFile, REQUEST, RESPONSE):
- unpack a file
- updateMD5Metadatum(PLFNGrelativePath='', mode='', output='redir'):
update (or test) the MD5 metadatum for a file
Parameters:
- PLFNGrelativePath: if PLFNGrelativePath is provided, it will be
used by _getFSFullPath() to determine which target file this method will operate on. Otherwise, _getFSFullPath() will use the '_e' field of self.REQUEST to determine the target file.
- mode: specify one of the following operation modes for this method
- 'testonly' -> the MD5 metadatum for the file will only be tested
- 'MD5only' -> only the current MD5 for the file will be generated
- 'update' -> the MD5 metadatum for the file will be updated
- output: specify the output/return behavior for this method
- 'redir' -> the textual result of this method is provided through portal_status_message via plfng_editMetadata
- otherwise, return either the MD5 string for the file or an integer value per the following table:
Return:
- refer to following table:
existing metadata valid? parameters output/return behavior mode output yes 'testonly' 'redir' redirect: 'MD5 valid' no 'testonly' 'redir' redirect: 'MD5 invalid warning' yes 'testonly' -1 no 'testonly' 0 yes 'update' -1 no 'update' 1 ** yes 'update' 'redir' redirect: 'MD5 valid, no update' no 'update' 'redir' redirect: 'MD5 metadata updated' yes 'MD5only' 'redir' redirect: 'file MD5 is <md5>' no 'MD5only' 'redir' redirect: 'file MD5 is <md5>' yes 'MD5only' <md5> no 'MD5only' <md5> ** return value will be 1 only if setMetadata() succeeds; otherwise 0 will be returned
- validFolder():
- determine if the requested folder path is legal and exists
- view(REQUEST, RESPONSE):
Invokes the default view.
Parameters:
- REQUEST: the standard HTML request data structure.
- RESPONSE: the standard HTML response data structure.
Return:
- the return value of the invoked default view.
modify_fti(fti):
make_url(content, *args):