Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Attributes
kss.core.pluginregistry._concatresource.concatfileresource.ConcatFiles Class Reference

List of all members.

Public Member Functions

def __init__
def getPathList
def getFilesList
def getLastMod
def getContents

Public Attributes

 pathlist_base
 compress_level
 caching
 lmt_check_period
 pathlist
 

XXX We have two choices:

1.


 fileslist_changed
 fileslist

Private Attributes

 __name__

Detailed Description

A resource that concatenates files and compresses the result

It is also possible to extend the statically given list via
a utility.

Definition at line 23 of file concatfileresource.py.


Constructor & Destructor Documentation

def kss.core.pluginregistry._concatresource.concatfileresource.ConcatFiles.__init__ (   self,
  pathlist,
  name,
  compress_level,
  caching,
  lmt_check_period 
)

Definition at line 31 of file concatfileresource.py.

00031 
00032     def __init__(self, pathlist, name, compress_level, caching, lmt_check_period):
00033         # Path is now a list.
00034         assert isinstance(pathlist, (list, tuple))
00035         # check all files, just to raise error if don't exist
00036         for path in pathlist:
00037             file(path, 'rb').close()
00038         #
00039         self.pathlist_base = pathlist
00040         self.__name__ = name
00041         self.compress_level = compress_level
00042         self.caching = caching
00043         self.lmt_check_period = lmt_check_period
00044         # markers for pathlist modification
00045         self.pathlist = []
00046         self.fileslist_changed = None
00047         self.fileslist = []

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

Definition at line 86 of file concatfileresource.py.

00086 
00087     def getContents(self):
00088         fileslist = self.getFilesList()
00089         assert fileslist, 'Must contain at least one resource.'
00090         result = fileslist[0].getContents()
00091         content_type = result['content_type']
00092         data = [result['data']]
00093         for subres in fileslist[1:]:
00094             d = subres.getContents()
00095             # all elements must have the same content type.
00096             assert d['content_type'] == content_type
00097             data.append(d['data'])
00098         result['data'] = '\n'.join(data)
00099         result['compress_level'] = self.compress_level
00100         # Do compression on the result
00101         result['data'] = compress(**result)
00102         return result

Here is the call graph for this function:

Definition at line 60 of file concatfileresource.py.

00060 
00061     def getFilesList(self):
00062         'Gets the list of files'
00063         ## # XXX We have two choices:
00064         ## # 1. We only calculate the list once, on startup
00065         ## # that is, we suppose that the file resource is
00066         ## # called up after the extension reg has been finished
00067         ## # and that it never changes later.
00068         ## # 2. but it also could be like this to allow changes later:
00069         pathlist = self.getPathList()
00070         if pathlist != self.pathlist:
00071         ##if not self.pathlist:
00072             ##pathlist = self.getPathList()
00073             # mark pathlist modification
00074             self.pathlist = pathlist
00075             self.fileslist_changed = time.time()
00076             fileslist = self.fileslist = [File(path, self.__name__) for path in pathlist]
00077         else:
00078             fileslist = self.fileslist
00079         return fileslist

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 80 of file concatfileresource.py.

00080 
00081     def getLastMod(self):
00082         # We take in consideration that the pathlist
00083         # itself could have changed too.
00084         return max([f.getLastMod() for f in self.getFilesList()] +
00085             [self.fileslist_changed])

Here is the call graph for this function:

Definition at line 48 of file concatfileresource.py.

00048 
00049     def getPathList(self):
00050         'Gets the extended pathlist'
00051         # we allow the list to be extended via an utility
00052         try:
00053             registry = zope.component.getUtility(IConcatResourceAddon, self.__name__)
00054         except ComponentLookupError:
00055             extend = []
00056         else:
00057             extend = registry.getAddonFiles()
00058         pathlist = self.pathlist_base + extend
00059         return pathlist

Here is the caller graph for this function:


Member Data Documentation

Definition at line 39 of file concatfileresource.py.

Definition at line 41 of file concatfileresource.py.

Definition at line 40 of file concatfileresource.py.

Definition at line 46 of file concatfileresource.py.

Definition at line 45 of file concatfileresource.py.

Definition at line 42 of file concatfileresource.py.

XXX We have two choices:

1.

We only calculate the list once, on startup

that is, we suppose that the file resource is

called up after the extension reg has been finished

and that it never changes later.

2. but it also could be like this to allow changes later:

if not self.pathlist: pathlist = self.getPathList() mark pathlist modification

Definition at line 44 of file concatfileresource.py.

Definition at line 38 of file concatfileresource.py.


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