Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
ResourceRegistries.tools.BaseRegistry.BaseRegistryTool Class Reference
Inheritance diagram for ResourceRegistries.tools.BaseRegistry.BaseRegistryTool:
Inheritance graph
[legend]
Collaboration diagram for ResourceRegistries.tools.BaseRegistry.BaseRegistryTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getitem__
def deferredGetContent
def __bobo_traverse__
def isCacheable
def validateId
def storeResource
def clearResources
def getResourcesDict
def compareResources
def sortResourceKey
def generateId
def finalizeResourceMerging
def finalizeContent
def cookResources
def evaluateExpression
def getResource
def getResourceContent
def moveResourceUp
def moveResourceDown
def moveResourceToTop
def moveResourceToBottom
def moveResourceBefore
def moveResourceAfter
def registerResource
def unregisterResource
def renameResource
def getResourceIds
def getResources
def getCookedResources
def moveResource
def getResourcePosition
def getDebugMode
def setDebugMode
def getAutoGroupingMode
def setAutoGroupingMode
def getEvaluatedResources
def getInlineResource
def getContentType

Public Attributes

 resources
 cookedresources
 concatenatedresources

Static Public Attributes

tuple security = ClassSecurityInfo()
 manage_options = SimpleItem.manage_options
tuple attributes_to_compare = ('getExpression', 'getCookable', 'getCacheable')
string filename_base = 'ploneResources'
string filename_appendix = '.res'
string merged_output_prefix = u''
int cache_duration = 3600
 resource_class = Resource
 debugmode = False
 autogroupingmode = False

Static Private Attributes

 __implements__ = SimpleItem.__implements__

Detailed Description

Base class for a Plone registry managing resource files.

Definition at line 165 of file BaseRegistry.py.


Constructor & Destructor Documentation

Add the storages.

Definition at line 187 of file BaseRegistry.py.

00187 
00188     def __init__(self):
00189         """Add the storages."""
00190         self.resources = ()
00191         self.cookedresources = ()
00192         self.concatenatedresources = {}
00193         self.debugmode = False
00194         self.autogroupingmode = False


Member Function Documentation

Traversal hook.

Definition at line 256 of file BaseRegistry.py.

00256 
00257     def __bobo_traverse__(self, REQUEST, name):
00258         """Traversal hook."""
00259         # First see if it is a skin
00260         skintool = getToolByName(self, 'portal_skins')
00261         skins = skintool.getSkinSelections()
00262         if name in skins:
00263             return Skin(name).__of__(self)
00264 
00265         
00266         if REQUEST is not None and \
00267            self.concatenatedresources.get(name, None) is not None:
00268             # __bobo_traverse__ is called before the authentication has
00269             # taken place, so if some operations require an authenticated
00270             # user (like restrictedTraverse in __getitem__) it will fail.
00271             # Now we can circumvent that by using the post_traverse()
00272             # method from BaseRequest. It temporarely stores a callable
00273             # along with its arguments in a REQUEST instance and calls
00274             # them at the end of BaseRequest.traverse()
00275             deferred = getDummyFileForContent(name, self.getContentType())
00276             # __bobo_traverse__ might be called from within
00277             # OFS.Traversable.Traversable.unrestrictedTraverse()
00278             # which passes a simple dict to the method, instead
00279             # of a "real" REQUEST object
00280             post_traverse = getattr(aq_base(REQUEST), 'post_traverse', None)
00281             if post_traverse is not None:
00282                 post_traverse(self.deferredGetContent, (deferred, name, None))
00283             else:
00284                 self.deferredGetContent(deferred, name, None)
00285             return deferred.__of__(self)
00286         obj = getattr(self, name, None)
00287         if obj is not None:
00288             return obj
00289         raise AttributeError('%s' % (name,))

Here is the call graph for this function:

Return a resource from the registry.

Definition at line 195 of file BaseRegistry.py.

00195 
00196     def __getitem__(self, item):
00197         """Return a resource from the registry."""
00198         original = self.REQUEST.get('original', False)
00199         output = self.getResourceContent(item, self, original)
00200         contenttype = self.getContentType()
00201         return (output, contenttype)

Here is the call graph for this function:

Here is the caller graph for this function:

Clears all resource data.

Convenience funtion for Plone migrations and tests.

Definition at line 319 of file BaseRegistry.py.

00319 
00320     def clearResources(self):
00321         """Clears all resource data.
00322 
00323         Convenience funtion for Plone migrations and tests.
00324         """
00325         self.resources = ()
00326         self.cookedresources = ()
00327         self.concatenatedresources = {}

Here is the caller graph for this function:

Check if two resources are compatible.

Definition at line 341 of file BaseRegistry.py.

00341 
00342     def compareResources(self, s1, s2):
00343         """Check if two resources are compatible."""
00344         for attr in self.attributes_to_compare:
00345             if getattr(s1, attr)() != getattr(s2, attr)():
00346                 return False
00347         return True

Here is the caller graph for this function:

Cook the stored resources.

Definition at line 384 of file BaseRegistry.py.

00384 
00385     def cookResources(self):
00386         """Cook the stored resources."""
00387         if self.ZCacheable_isCachingEnabled():
00388             self.ZCacheable_invalidate()
00389         resources = [r.copy() for r in self.getResources() if r.getEnabled()]
00390         self.concatenatedresources = {}
00391         self.cookedresources = ()
00392         if self.getDebugMode():
00393             results = [x for x in resources]
00394         else:
00395             results = []
00396             if self.getAutoGroupingMode():
00397                 # Sort resources according to their sortkey first, so resources
00398                 # with compatible keys will be merged.
00399                 def _sort_position(r):
00400                     key = self.sortResourceKey(r[0])
00401                     key.append(r[1])
00402                     return key
00403                 # We need to respect the resource position inside the sort groups
00404                 positioned_resources = [(r, resources.index(r)) for r in resources]
00405                 positioned_resources.sort(key=_sort_position)
00406                 resources = [r[0] for r in positioned_resources]
00407             for resource in resources:
00408                 if results:
00409                     previtem = results[-1]
00410                     if resource.getCookable() and previtem.getCookable() \
00411                            and self.compareResources(resource, previtem):
00412                         res_id = resource.getId()
00413                         prev_id = previtem.getId()
00414                         self.finalizeResourceMerging(resource, previtem)
00415                         if self.concatenatedresources.has_key(prev_id):
00416                             self.concatenatedresources[prev_id].append(res_id)
00417                         else:
00418                             magic_id = self.generateId(res_id, prev_id)
00419                             self.concatenatedresources[magic_id] = [prev_id, res_id]
00420                             previtem._setId(magic_id)
00421                     else:
00422                         if resource.getCookable() or resource.getCacheable():
00423                             magic_id = self.generateId(resource.getId())
00424                             self.concatenatedresources[magic_id] = [resource.getId()]
00425                             resource._setId(magic_id)
00426                         results.append(resource)
00427                 else:
00428                     if resource.getCookable() or resource.getCacheable():
00429                         magic_id = self.generateId(resource.getId())
00430                         self.concatenatedresources[magic_id] = [resource.getId()]
00431                         resource._setId(magic_id)
00432                     results.append(resource)
00433 
00434         resources = self.getResources()
00435         for resource in resources:
00436             self.concatenatedresources[resource.getId()] = [resource.getId()]
00437         self.cookedresources = tuple(results)

Here is the call graph for this function:

Here is the caller graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.deferredGetContent (   self,
  deferred,
  name,
  skin = None 
)
uploads data of a resource to deferred 

Definition at line 202 of file BaseRegistry.py.

00202 
00203     def deferredGetContent(self, deferred, name, skin=None):
00204         """ uploads data of a resource to deferred """
00205         # "deferred" was previosly created by a getDummyFileForContent
00206         # call in the __bobo_traverse__ method. As the name suggests,
00207         # the file is merely a traversable dummy with appropriate
00208         # headers and name. Now as soon as REQUEST.traverse
00209         # finishes and gets to the part where it calls the tuples
00210         # register using post_traverse (that's actually happening
00211         # right now) we can be sure, that all necessary security
00212         # stuff has taken place (e.g. authentication).
00213         kw = {'skin':skin,'name':name}
00214         data = None
00215         duration = self.cache_duration  # duration in seconds
00216         if not self.getDebugMode() and self.isCacheable(name):
00217             if self.ZCacheable_isCachingEnabled():
00218                 data = self.ZCacheable_get(keywords=kw)
00219             if data is None:
00220                 # This is the part were we would fail if
00221                 # we would just return the ressource
00222                 # without using the post_traverse hook:
00223                 # self.__getitem__ leads (indirectly) to
00224                 # a restrictedTraverse call which performs
00225                 # security checks. So if a tool (or its ressource)
00226                 # is not "View"able by anonymous - we'd
00227                 # get an Unauthorized exception.
00228                 data = self.__getitem__(name)
00229                 self.ZCacheable_set(data, keywords=kw)
00230         else:
00231             data = self.__getitem__(name)
00232             duration = 0
00233 
00234         output, contenttype = data
00235 
00236         seconds = float(duration)*24.0*3600.0
00237         response = self.REQUEST.RESPONSE
00238         response.setHeader('Expires',rfc1123_date((DateTime() + duration).timeTime()))
00239         response.setHeader('Cache-Control', 'max-age=%d' % int(seconds))
00240 
00241         if isinstance(output, unicode):
00242             portal_props = getToolByName(self, 'portal_properties')
00243             site_props = portal_props.site_properties
00244             charset = site_props.getProperty('default_charset', 'utf-8')
00245             output = output.encode(charset)
00246             if 'charset=' not in contenttype:
00247                 contenttype += ';charset=' + charset
00248         
00249         out = StringIO(output)
00250         out.headers = {'content-type': contenttype}
00251         # At this point we are ready to provide some content
00252         # for our dummy and since it's just a File instance,
00253         # we can "upload" (a quite delusive method name) the
00254         # data and that's it.
00255         deferred.manage_upload(out)
    

Here is the caller graph for this function:

Evaluate an object's TALES condition to see if it should be
displayed.

Definition at line 439 of file BaseRegistry.py.

00439 
00440     def evaluateExpression(self, expression, context):
00441         """Evaluate an object's TALES condition to see if it should be
00442         displayed.
00443         """
00444         try:
00445             if expression and context is not None:
00446                 portal = getToolByName(context, 'portal_url').getPortalObject()
00447 
00448                 # Find folder (code courtesy of CMFCore.ActionsTool)
00449                 if context is None or not hasattr(context, 'aq_base'):
00450                     folder = portal
00451                 else:
00452                     folder = context
00453                     # Search up the containment hierarchy until we find an
00454                     # object that claims it's PrincipiaFolderish.
00455                     while folder is not None:
00456                         if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
00457                             # found it.
00458                             break
00459                         else:
00460                             folder = aq_parent(aq_inner(folder))
00461 
00462                 __traceback_info__ = (folder, portal, context, expression)
00463                 ec = createExprContext(folder, portal, context)
00464                 return Expression(expression)(ec)
00465             else:
00466                 return 1
00467         except AttributeError:
00468             return 1

Here is the call graph for this function:

Here is the caller graph for this function:

Finalize the resource content.

Might be overwritten in subclasses.

Definition at line 376 of file BaseRegistry.py.

00376 
00377     def finalizeContent(self, resource, content):
00378         """Finalize the resource content.
00379 
00380         Might be overwritten in subclasses.
00381         """
00382         return content

Here is the caller graph for this function:

Finalize the resource merging with the previous item.

Might be overwritten in subclasses.

Definition at line 368 of file BaseRegistry.py.

00368 
00369     def finalizeResourceMerging(self, resource, previtem):
00370         """Finalize the resource merging with the previous item.
00371 
00372         Might be overwritten in subclasses.
00373         """
00374         pass

Here is the caller graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.generateId (   self,
  res_id,
  prev_id = None 
)
Generate a random id.

Definition at line 355 of file BaseRegistry.py.

00355 
00356     def generateId(self, res_id, prev_id=None):
00357         """Generate a random id."""
00358         id_parts = res_id.split('.')
00359         if (len(id_parts) > 1):
00360             base = '.'.join(id_parts[:-1])
00361             appendix = ".%s" % id_parts[-1]
00362         else:
00363             base = id_parts[0]
00364             appendix = self.filename_appendix
00365         base = base.replace('++', '').replace('/', '')
00366         return '%s-cachekey%04d%s' % (base, random.randint(0, 9999), appendix)

Here is the caller graph for this function:

Is resource merging disabled?

Definition at line 762 of file BaseRegistry.py.

00762 
00763     def getAutoGroupingMode(self):
00764         """Is resource merging disabled?"""
00765         return self.autogroupingmode

Here is the caller graph for this function:

Return the registry content type.

Should be overwritten by subclasses.

Definition at line 798 of file BaseRegistry.py.

00798 
00799     def getContentType(self):
00800         """Return the registry content type.
00801 
00802         Should be overwritten by subclasses.
00803         """
00804         return 'text/plain'
00805 

Here is the caller graph for this function:

Get the cooked resource data.

Definition at line 715 of file BaseRegistry.py.

00715 
00716     def getCookedResources(self):
00717         """Get the cooked resource data."""
00718         result = []
00719         for item in self.cookedresources:
00720             if isinstance(item, dict):
00721                 # BBB we used dicts before
00722                 item = item.copy()
00723                 item_id = item['id']
00724                 del item['id']
00725                 obj = self.resource_class(item_id, **item)
00726                 result.append(obj)
00727             else:
00728                 result.append(item)
00729         return tuple(result)

Here is the caller graph for this function:

Is resource merging disabled?

Definition at line 751 of file BaseRegistry.py.

00751 
00752     def getDebugMode(self):
00753         """Is resource merging disabled?"""
00754         return self.debugmode

Here is the caller graph for this function:

Return the filtered evaluated resources.

Definition at line 773 of file BaseRegistry.py.

00773 
00774     def getEvaluatedResources(self, context):
00775         """Return the filtered evaluated resources."""
00776         results = self.getCookedResources()
00777 
00778         # filter results by expression
00779         results = [item for item in results
00780                    if self.evaluateExpression(item.getExpression(), context)]
00781 
00782         return results

Here is the call graph for this function:

Return a resource as inline code, not as a file object.

Needs to take care not to mess up http headers.

Definition at line 784 of file BaseRegistry.py.

00784 
00785     def getInlineResource(self, item, context):
00786         """Return a resource as inline code, not as a file object.
00787 
00788         Needs to take care not to mess up http headers.
00789         """
00790         headers = self.REQUEST.RESPONSE.headers.copy()
00791         # Save the RESPONSE headers
00792         output = self.getResourceContent(item, context)
00793         # File objects and other might manipulate the headers,
00794         # something we don't want. we set the saved headers back
00795         self.REQUEST.RESPONSE.headers = headers
00796         return output

Here is the call graph for this function:

Get resource object by id.

If any property of the resource is changed, then cookResources of the
registry must be called.

Definition at line 470 of file BaseRegistry.py.

00470 
00471     def getResource(self, id):
00472         """Get resource object by id.
00473         
00474         If any property of the resource is changed, then cookResources of the
00475         registry must be called."""
00476         resources = self.getResourcesDict()
00477         resource = resources.get(id, None)
00478         if resource is not None:
00479             return ExplicitAcquisitionWrapper(resource, self)
00480         return None

Here is the call graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.getResourceContent (   self,
  item,
  context,
  original = False 
)
Fetch resource content for delivery.

Definition at line 482 of file BaseRegistry.py.

00482 
00483     def getResourceContent(self, item, context, original=False):
00484         """Fetch resource content for delivery."""
00485         ids = self.concatenatedresources.get(item, None)
00486         resources = self.getResourcesDict()
00487         if ids is not None:
00488             ids = ids[:]
00489         output = u""
00490         if len(ids) > 1:
00491             output = output + self.merged_output_prefix
00492 
00493         portal = getToolByName(context, 'portal_url').getPortalObject()
00494 
00495         if context == self and portal is not None:
00496             context = portal
00497 
00498         portal_props = getToolByName(self, 'portal_properties')
00499         site_props = portal_props.site_properties
00500         default_charset = site_props.getProperty('default_charset', 'utf-8')
00501 
00502         for id in ids:
00503             try:
00504                 if portal is not None:
00505                     obj = context.restrictedTraverse(id)
00506                 else:
00507                     #Can't do anything other than attempt a getattr
00508                     obj = getattr(context, id)
00509             except (AttributeError, KeyError):
00510                 output += u"\n/* XXX ERROR -- could not find '%s'*/\n" % id
00511                 content = u''
00512                 obj = None
00513             except Unauthorized:
00514                 #If we're just returning a single resource, raise an Unauthorized,
00515                 #otherwise we're merging resources in which case just log an error
00516                 if len(ids) > 1:
00517                     #Object probably isn't published yet
00518                     output += u"\n/* XXX ERROR -- access to '%s' not authorized */\n" % id
00519                     content = u''
00520                     obj = None
00521                 else:
00522                     raise
00523 
00524             if obj is not None:
00525                 if isinstance(obj, z3_Resource):
00526                     # z3 resources
00527                     # XXX this is a temporary solution, we wrap the five resources
00528                     # into our mechanism, where it should be the other way around.
00529                     #
00530                     # First thing we must be aware of: resources give a complete
00531                     # response so first we must save the headers.
00532                     # Especially, we must delete the If-Modified-Since, because
00533                     # otherwise we might get a 30x response status in some cases.
00534                     response_headers = self.REQUEST.RESPONSE.headers.copy()
00535                     if_modif = self.REQUEST.get_header('If-Modified-Since', None)
00536                     try:
00537                         del self.REQUEST.environ['IF_MODIFIED_SINCE']
00538                     except KeyError:
00539                         pass
00540                     try:
00541                         del self.REQUEST.environ['HTTP_IF_MODIFIED_SINCE']
00542                     except KeyError:
00543                         pass
00544                     # Now, get the content.
00545                     method = obj.__browser_default__(self.REQUEST)[1][0]
00546                     method = method == 'HEAD' and 'GET' or method
00547                     content = getattr(obj, method)()
00548                     if not isinstance(content, unicode): 
00549                         contenttype = self.REQUEST.RESPONSE.headers.get('content-type', '')
00550                         contenttype = getCharsetFromContentType(contenttype, default_charset)
00551                         content = unicode(content, contenttype)
00552                     # Now restore the headers and for safety, check that we
00553                     # have a 20x response. If not, we have a problem and
00554                     # some browser would hang indefinitely at this point.
00555                     assert int(self.REQUEST.RESPONSE.getStatus()) / 100 == 2
00556                     self.REQUEST.environ['HTTP_IF_MODIFIED_SINCE'] = if_modif
00557                     self.REQUEST.RESPONSE.headers = response_headers
00558                 elif hasattr(aq_base(obj),'meta_type') and  obj.meta_type in ['DTML Method', 'Filesystem DTML Method']:
00559                     content = obj(client=self.aq_parent, REQUEST=self.REQUEST,
00560                                   RESPONSE=self.REQUEST.RESPONSE)
00561                     contenttype = self.REQUEST.RESPONSE.headers.get('content-type', '')
00562                     contenttype = getCharsetFromContentType(contenttype, default_charset)
00563                     content = unicode(content, contenttype)
00564                 elif hasattr(aq_base(obj),'meta_type') and obj.meta_type == 'Filesystem File':
00565                     obj._updateFromFS()
00566                     content = obj._readFile(0)
00567                     contenttype = getCharsetFromContentType(obj.content_type, default_charset)
00568                     content = unicode(content, contenttype)
00569                 elif hasattr(aq_base(obj),'meta_type') and obj.meta_type == 'ATFile':
00570                     f = obj.getFile()
00571                     contenttype = getCharsetFromContentType(f.getContentType(), default_charset)
00572                     content = unicode(str(f), contenttype)
00573                 # We should add more explicit type-matching checks
00574                 elif hasattr(aq_base(obj), 'index_html') and callable(obj.index_html):
00575                     content = obj.index_html(self.REQUEST,
00576                                              self.REQUEST.RESPONSE)
00577                     if not isinstance(content, unicode):
00578                         content = unicode(content, default_charset)
00579                 elif callable(obj):
00580                     content = obj(self.REQUEST, self.REQUEST.RESPONSE)
00581                     if not isinstance(content, unicode):
00582                         content = unicode(content, default_charset)
00583                 else:
00584                     content = str(obj)
00585                     content = unicode(content, default_charset)
00586 
00587             # Add start/end notes to the resource for better
00588             # understanding and debugging
00589             if content:
00590                 output += u'\n/* - %s - */\n' % (id,)
00591                 if original:
00592                     output += content
00593                 else:
00594                     output += self.finalizeContent(resources[id], content)
00595                 output += u'\n'
00596         return output

Here is the call graph for this function:

Here is the caller graph for this function:

Return the ids of all resources.

Definition at line 691 of file BaseRegistry.py.

00691 
00692     def getResourceIds(self):
00693         """Return the ids of all resources."""
00694         return tuple([x.getId() for x in self.getResources()])

Here is the call graph for this function:

Here is the caller graph for this function:

Get the position (order) of an resource given its id.

Definition at line 745 of file BaseRegistry.py.

00745 
00746     def getResourcePosition(self, id):
00747         """Get the position (order) of an resource given its id."""
00748         resource_ids = list(self.getResourceIds())
00749         return resource_ids.index(id)

Here is the call graph for this function:

Here is the caller graph for this function:

Get all the registered resource data, uncooked.

For management screens.

Definition at line 696 of file BaseRegistry.py.

00696 
00697     def getResources(self):
00698         """Get all the registered resource data, uncooked.
00699 
00700         For management screens.
00701         """
00702         result = []
00703         for item in self.resources:
00704             if isinstance(item, dict):
00705                 # BBB we used dicts before
00706                 item = item.copy()
00707                 item_id = item['id']
00708                 del item['id']
00709                 obj = self.resource_class(item_id, **item)
00710                 result.append(obj)
00711             else:
00712                 result.append(item)
00713         return tuple(result)

Here is the caller graph for this function:

Get the resources as a dictionary instead of an ordered list.

Good for lookups. Internal.

Definition at line 329 of file BaseRegistry.py.

00329 
00330     def getResourcesDict(self):
00331         """Get the resources as a dictionary instead of an ordered list.
00332 
00333         Good for lookups. Internal.
00334         """
00335         resources = self.getResources()
00336         d = {}
00337         for s in resources:
00338             d[s.getId()] = s
00339         return d

Here is the call graph for this function:

Here is the caller graph for this function:

Return a boolean whether the resource is cacheable or not.

Definition at line 291 of file BaseRegistry.py.

00291 
00292     def isCacheable(self, name):
00293         """Return a boolean whether the resource is cacheable or not."""
00294         resource_id = self.concatenatedresources.get(name, [None])[0]
00295         if resource_id is None:
00296             return False
00297         resources = self.getResourcesDict()
00298         resource = resources.get(resource_id, None)
00299         result = resource.getCacheable()
00300         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Move a registered resource to the given position.

Definition at line 731 of file BaseRegistry.py.

00731 
00732     def moveResource(self, id, position):
00733         """Move a registered resource to the given position."""
00734         index = self.getResourcePosition(id)
00735         if index == position:
00736             return
00737         elif position < 0:
00738             position = 0
00739         resources = list(self.getResources())
00740         resource = resources.pop(index)
00741         resources.insert(position, resource)
00742         self.resources = tuple(resources)
00743         self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.moveResourceAfter (   self,
  id,
  dest_id,
  REQUEST = None 
)
Move the resource after the resource with dest_id.

Definition at line 644 of file BaseRegistry.py.

00644 
00645     def moveResourceAfter(self, id, dest_id, REQUEST=None):
00646         """Move the resource after the resource with dest_id."""
00647         index = self.getResourcePosition(id)
00648         dest_index = self.getResourcePosition(dest_id)
00649         if index < dest_index:
00650             self.moveResource(id, dest_index)
00651         else:
00652             self.moveResource(id, dest_index + 1)
00653         if REQUEST:
00654             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.moveResourceBefore (   self,
  id,
  dest_id,
  REQUEST = None 
)
Move the resource before the resource with dest_id.

Definition at line 632 of file BaseRegistry.py.

00632 
00633     def moveResourceBefore(self, id, dest_id, REQUEST=None):
00634         """Move the resource before the resource with dest_id."""
00635         index = self.getResourcePosition(id)
00636         dest_index = self.getResourcePosition(dest_id)
00637         if index < dest_index:
00638             self.moveResource(id, dest_index - 1)
00639         else:
00640             self.moveResource(id, dest_index)
00641         if REQUEST:
00642             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.moveResourceDown (   self,
  id,
  steps = 1,
  REQUEST = None 
)
Move the resource down 'steps' number of steps.

Definition at line 610 of file BaseRegistry.py.

00610 
00611     def moveResourceDown(self, id, steps=1, REQUEST=None):
00612         """Move the resource down 'steps' number of steps."""
00613         index = self.getResourcePosition(id)
00614         self.moveResource(id, index + steps)
00615         if REQUEST:
00616             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

Move the resource to the last position.

Definition at line 625 of file BaseRegistry.py.

00625 
00626     def moveResourceToBottom(self, id, REQUEST=None):
00627         """Move the resource to the last position."""
00628         self.moveResource(id, len(self.resources))
00629         if REQUEST:
00630             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

Move the resource to the first position.

Definition at line 618 of file BaseRegistry.py.

00618 
00619     def moveResourceToTop(self, id, REQUEST=None):
00620         """Move the resource to the first position."""
00621         self.moveResource(id, 0)
00622         if REQUEST:
00623             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.moveResourceUp (   self,
  id,
  steps = 1,
  REQUEST = None 
)
Move the resource up 'steps' number of steps.

Definition at line 602 of file BaseRegistry.py.

00602 
00603     def moveResourceUp(self, id, steps=1, REQUEST=None):
00604         """Move the resource up 'steps' number of steps."""
00605         index = self.getResourcePosition(id)
00606         self.moveResource(id, index - steps)
00607         if REQUEST:
00608             REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER'])

Here is the call graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.registerResource (   self,
  id,
  expression = '',
  enabled = True,
  cookable = True,
  cacheable = True 
)
Register a resource.

Definition at line 661 of file BaseRegistry.py.

00661 
00662                          cookable=True, cacheable=True):
00663         """Register a resource."""
00664         resource = Resource(id,
00665                             expression=expression,
00666                             enabled=enabled,
00667                             cookable=cookable,
00668                             cacheable=cacheable)
00669         self.storeResource(resource)

Here is the call graph for this function:

Here is the caller graph for this function:

Change the id of a registered resource.

Definition at line 679 of file BaseRegistry.py.

00679 
00680     def renameResource(self, old_id, new_id):
00681         """Change the id of a registered resource."""
00682         self.validateId(new_id, self.getResources())
00683         resources = list(self.resources)
00684         for resource in resources:
00685             if resource.getId() == old_id:
00686                 resource._setId(new_id)
00687                 break
00688         self.resources = tuple(resources)
00689         self.cookResources()

Here is the call graph for this function:

Set whether resource merging should be disabled.

Definition at line 767 of file BaseRegistry.py.

00767 
00768     def setAutoGroupingMode(self, value):
00769         """Set whether resource merging should be disabled."""
00770         self.autogroupingmode = bool(value)
00771         self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

Set whether resource merging should be disabled.

Definition at line 756 of file BaseRegistry.py.

00756 
00757     def setDebugMode(self, value):
00758         """Set whether resource merging should be disabled."""
00759         self.debugmode = value
00760         self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

Returns a sort key for the resource.

Definition at line 349 of file BaseRegistry.py.

00349 
00350     def sortResourceKey(self, resource):
00351         """Returns a sort key for the resource."""
00352         return [getattr(resource, attr)() for attr in
00353                 self.attributes_to_compare]

Here is the caller graph for this function:

def ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.storeResource (   self,
  resource,
  skipCooking = False 
)
Store a resource.

Definition at line 309 of file BaseRegistry.py.

00309 
00310     def storeResource(self, resource, skipCooking=False):
00311         """Store a resource."""
00312         self.validateId(resource.getId(), self.getResources())
00313         resources = list(self.resources)
00314         resources.append(resource)
00315         self.resources = tuple(resources)
00316         if not skipCooking:
00317             self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

Unregister a registered resource.

Definition at line 671 of file BaseRegistry.py.

00671 
00672     def unregisterResource(self, id):
00673         """Unregister a registered resource."""
00674         resources = [item for item in self.getResources()
00675                      if item.getId() != id]
00676         self.resources = tuple(resources)
00677         self.cookResources()

Here is the call graph for this function:

Here is the caller graph for this function:

Safeguard against duplicate ids.

Definition at line 302 of file BaseRegistry.py.

00302 
00303     def validateId(self, id, existing):
00304         """Safeguard against duplicate ids."""
00305         for sheet in existing:
00306             if sheet.getId() == id:
00307                 raise ValueError, 'Duplicate id %s' %(id)

Here is the caller graph for this function:


Member Data Documentation

ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.__implements__ = SimpleItem.__implements__ [static, private]

Definition at line 170 of file BaseRegistry.py.

tuple ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.attributes_to_compare = ('getExpression', 'getCookable', 'getCacheable') [static]

Definition at line 173 of file BaseRegistry.py.

Definition at line 181 of file BaseRegistry.py.

Definition at line 177 of file BaseRegistry.py.

Definition at line 191 of file BaseRegistry.py.

Definition at line 190 of file BaseRegistry.py.

Definition at line 180 of file BaseRegistry.py.

Definition at line 175 of file BaseRegistry.py.

Definition at line 174 of file BaseRegistry.py.

Definition at line 171 of file BaseRegistry.py.

Definition at line 176 of file BaseRegistry.py.

Definition at line 178 of file BaseRegistry.py.

Definition at line 189 of file BaseRegistry.py.

Definition at line 168 of file BaseRegistry.py.


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