Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFCore.CachingPolicyManager.CachingPolicyManager Class Reference
Inheritance diagram for CMFCore.CachingPolicyManager.CachingPolicyManager:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.CachingPolicyManager.CachingPolicyManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def listPolicies
def addPolicy
def updatePolicy
def movePolicyUp
def movePolicyDown
def removePolicy
def getHTTPCachingHeaders
def getModTimeAndETag
def ZCacheManager_getCache

Static Public Attributes

string id = 'caching_policy_manager'
string meta_type = 'CMF Caching Policy Manager'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_cachingPolicies = DTMLFile( 'cachingPolicies', _dtmldir )

Private Member Functions

def _addPolicy
def _updatePolicy
def _reorderPolicy
def _removePolicy

Private Attributes

 _policy_ids
 _policies
 _cache

Static Private Attributes

 __implements__ = z2ICachingPolicyManager
int _isCacheManager = 1

Detailed Description

    Manage the set of CachingPolicy objects for the site;  dispatch
    to them from skin methods.

Definition at line 456 of file CachingPolicyManager.py.


Constructor & Destructor Documentation

Definition at line 471 of file CachingPolicyManager.py.

00471 
00472     def __init__( self ):
00473         self._policy_ids = ()
00474         self._policies = PersistentMapping()


Member Function Documentation

def CMFCore.CachingPolicyManager.CachingPolicyManager._addPolicy (   self,
  policy_id,
  predicate,
  mtime_func,
  max_age_secs,
  no_cache,
  no_store,
  must_revalidate,
  vary,
  etag_func,
  s_max_age_secs = None,
  proxy_revalidate = 0,
  public = 0,
  private = 0,
  no_transform = 0,
  enable_304s = 0,
  last_modified = 1,
  pre_check = None,
  post_check = None 
) [private]
    Add a policy to our registry.

Definition at line 710 of file CachingPolicyManager.py.

00710 
00711                   ):
00712         """
00713             Add a policy to our registry.
00714         """
00715         policy_id = str( policy_id ).strip()
00716 
00717         if not policy_id:
00718             raise ValueError, "Policy ID is required!"
00719 
00720         if policy_id in self._policy_ids:
00721             raise KeyError, "Policy %s already exists!" % policy_id
00722 
00723         self._policies[ policy_id ] = CachingPolicy( policy_id
00724                                                    , predicate
00725                                                    , mtime_func
00726                                                    , max_age_secs
00727                                                    , no_cache
00728                                                    , no_store
00729                                                    , must_revalidate
00730                                                    , vary
00731                                                    , etag_func
00732                                                    , s_max_age_secs
00733                                                    , proxy_revalidate
00734                                                    , public
00735                                                    , private
00736                                                    , no_transform
00737                                                    , enable_304s
00738                                                    , last_modified
00739                                                    , pre_check
00740                                                    , post_check
00741                                                    )
00742         idlist = list( self._policy_ids )
00743         idlist.append( policy_id )
00744         self._policy_ids = tuple( idlist )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager._removePolicy (   self,
  policy_id 
) [private]
    Remove a policy from our registry.

Definition at line 808 of file CachingPolicyManager.py.

00808 
00809     def _removePolicy( self, policy_id ):
00810         """
00811             Remove a policy from our registry.
00812         """
00813         if policy_id not in self._policy_ids:
00814             raise KeyError, "Policy %s does not exist!" % policy_id
00815 
00816         del self._policies[ policy_id ]
00817         idlist = list( self._policy_ids )
00818         ndx = idlist.index( policy_id )
00819         idlist = idlist[ :ndx ] + idlist[ ndx+1: ]
00820         self._policy_ids = tuple( idlist )
00821 

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager._reorderPolicy (   self,
  policy_id,
  newIndex 
) [private]
    Reorder a policy in our registry.

Definition at line 793 of file CachingPolicyManager.py.

00793 
00794     def _reorderPolicy( self, policy_id, newIndex ):
00795         """
00796             Reorder a policy in our registry.
00797         """
00798         if policy_id not in self._policy_ids:
00799             raise KeyError, "Policy %s does not exist!" % policy_id
00800 
00801         idlist = list( self._policy_ids )
00802         ndx = idlist.index( policy_id )
00803         pred = idlist[ ndx ]
00804         idlist = idlist[ :ndx ] + idlist[ ndx+1: ]
00805         idlist.insert( newIndex, pred )
00806         self._policy_ids = tuple( idlist )

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager._updatePolicy (   self,
  policy_id,
  predicate,
  mtime_func,
  max_age_secs,
  no_cache,
  no_store,
  must_revalidate,
  vary,
  etag_func,
  s_max_age_secs = None,
  proxy_revalidate = 0,
  public = 0,
  private = 0,
  no_transform = 0,
  enable_304s = 0,
  last_modified = 1,
  pre_check = None,
  post_check = None 
) [private]
    Update a policy in our registry.

Definition at line 765 of file CachingPolicyManager.py.

00765 
00766                      ):
00767         """
00768             Update a policy in our registry.
00769         """
00770         if policy_id not in self._policy_ids:
00771             raise KeyError, "Policy %s does not exist!" % policy_id
00772 
00773         self._policies[ policy_id ] = CachingPolicy( policy_id
00774                                                    , predicate
00775                                                    , mtime_func
00776                                                    , max_age_secs
00777                                                    , no_cache
00778                                                    , no_store
00779                                                    , must_revalidate
00780                                                    , vary
00781                                                    , etag_func
00782                                                    , s_max_age_secs
00783                                                    , proxy_revalidate
00784                                                    , public
00785                                                    , private
00786                                                    , no_transform
00787                                                    , enable_304s
00788                                                    , last_modified
00789                                                    , pre_check
00790                                                    , post_check
00791                                                    )

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.addPolicy (   self,
  policy_id,
  predicate,
  mtime_func,
  max_age_secs,
  no_cache,
  no_store,
  must_revalidate,
  vary,
  etag_func,
  REQUEST = None,
  s_max_age_secs = None # integer,
  seconds,
  def,
  None,
  proxy_revalidate = 0  # boolean (def. 0),
  public = 0            # boolean (def. 0),
  private = 0           # boolean (def. 0),
  no_transform = 0      # boolean (def. 0),
  enable_304s = 0       # boolean (def. 0),
  last_modified = 1     # boolean (def. 1),
  pre_check = None      # integer,
  default,
  None,
  post_check = None     # integer,
  default,
  None 
)
    Add a caching policy.

Definition at line 518 of file CachingPolicyManager.py.

00518 
00519                  ):
00520         """
00521             Add a caching policy.
00522         """
00523         if max_age_secs is None or str(max_age_secs).strip() == '':
00524             max_age_secs = None
00525         else:
00526             max_age_secs = int(max_age_secs)
00527 
00528         if s_max_age_secs is None or str(s_max_age_secs).strip() == '':
00529             s_max_age_secs = None
00530         else:
00531             s_max_age_secs = int(s_max_age_secs)
00532 
00533         if pre_check is None or str(pre_check).strip() == '':
00534             pre_check = None
00535         else:
00536             pre_check = int(pre_check)
00537 
00538         if post_check is None or str(post_check).strip() == '':
00539             post_check = None
00540         else:
00541             post_check = int(post_check)
00542 
00543         self._addPolicy( policy_id
00544                        , predicate
00545                        , mtime_func
00546                        , max_age_secs
00547                        , no_cache
00548                        , no_store
00549                        , must_revalidate
00550                        , vary
00551                        , etag_func
00552                        , s_max_age_secs
00553                        , proxy_revalidate
00554                        , public
00555                        , private
00556                        , no_transform
00557                        , enable_304s
00558                        , last_modified
00559                        , pre_check
00560                        , post_check
00561                        )
00562         if REQUEST is not None: 
00563             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00564                                           + '/manage_cachingPolicies'
00565                                           + '?manage_tabs_message='
00566                                           + 'Policy+added.'
00567                                           )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.getHTTPCachingHeaders (   self,
  content,
  view_method,
  keywords,
  time = None 
)
    Return a list of HTTP caching headers based on 'content',
    'view_method', and 'keywords'.

Definition at line 826 of file CachingPolicyManager.py.

00826 
00827     def getHTTPCachingHeaders( self, content, view_method, keywords, time=None):
00828         """
00829             Return a list of HTTP caching headers based on 'content',
00830             'view_method', and 'keywords'.
00831         """
00832         # XXX: this method violates the rules for tools/utilities:
00833         # createCPContext depends on a non-utility tool
00834         context = createCPContext( content, view_method, keywords, time=time )
00835         for policy_id, policy in self.listPolicies():
00836 
00837             headers = policy.getHeaders( context )
00838             if headers:
00839                 return headers
00840 
00841         return ()

Here is the call graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.getModTimeAndETag (   self,
  content,
  view_method,
  keywords,
  time = None 
)
Return the modification time and ETag for the content object,
    view method, and keywords as the tuple (modification_time, etag,
    set_last_modified_header), where modification_time is a DateTime,
    or None.

Definition at line 843 of file CachingPolicyManager.py.

00843 
00844     def getModTimeAndETag( self, content, view_method, keywords, time=None):
00845         """ Return the modification time and ETag for the content object,
00846             view method, and keywords as the tuple (modification_time, etag,
00847             set_last_modified_header), where modification_time is a DateTime,
00848             or None.
00849         """
00850         # XXX: this method violates the rules for tools/utilities:
00851         # createCPContext depends on a non-utility tool
00852         context = createCPContext( content, view_method, keywords, time=time )
00853         for policy_id, policy in self.listPolicies():
00854             if policy.getEnable304s() and policy.testPredicate(context):
00855 
00856                 last_modified = policy._mtime_func(context)
00857                 if type(last_modified) is type(''):
00858                     last_modified = DateTime(last_modified)
00859 
00860                 content_etag = None
00861                 if policy.getETagFunc():
00862                     content_etag = policy._etag_func(context)
00863 
00864                 return (last_modified, content_etag, policy.getLastModified())
00865 
00866         return None

Here is the call graph for this function:

List '(id, (policy, typeObjectName))' tuples for all policies.

Definition at line 492 of file CachingPolicyManager.py.

00492 
00493     def listPolicies( self ):
00494         """List '(id, (policy, typeObjectName))' tuples for all policies.
00495         """
00496         return tuple([ (id, self._policies[id]) for id in self._policy_ids ])

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.movePolicyDown (   self,
  policy_id,
  REQUEST = None 
)
    Move a caching policy down in the list.

Definition at line 658 of file CachingPolicyManager.py.

00658 
00659     def movePolicyDown( self, policy_id, REQUEST=None ):
00660         """
00661             Move a caching policy down in the list.
00662         """
00663         policy_ids = list( self._policy_ids )
00664         ndx = policy_ids.index( policy_id )
00665         if ndx == len( policy_ids ) - 1:
00666             msg = "Policy+already+last."
00667         else:
00668             self._reorderPolicy( policy_id, ndx + 1 )
00669             msg = "Policy+moved."
00670         if REQUEST is not None:
00671             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00672                               + '/manage_cachingPolicies'
00673                               + '?manage_tabs_message=%s' % msg
00674                               )

Here is the call graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.movePolicyUp (   self,
  policy_id,
  REQUEST = None 
)
    Move a caching policy up in the list.

Definition at line 640 of file CachingPolicyManager.py.

00640 
00641     def movePolicyUp( self, policy_id, REQUEST=None ):
00642         """
00643             Move a caching policy up in the list.
00644         """
00645         policy_ids = list( self._policy_ids )
00646         ndx = policy_ids.index( policy_id )
00647         if ndx == 0:
00648             msg = "Policy+already+first."
00649         else:
00650             self._reorderPolicy( policy_id, ndx - 1 )
00651             msg = "Policy+moved."
00652         if REQUEST is not None:
00653             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00654                               + '/manage_cachingPolicies'
00655                               + '?manage_tabs_message=%s' % msg
00656                               )

Here is the call graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.removePolicy (   self,
  policy_id,
  REQUEST = None 
)
    Remove a caching policy.

Definition at line 676 of file CachingPolicyManager.py.

00676 
00677     def removePolicy( self, policy_id, REQUEST=None ):
00678         """
00679             Remove a caching policy.
00680         """
00681         self._removePolicy( policy_id )
00682         if REQUEST is not None:
00683             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00684                               + '/manage_cachingPolicies'
00685                               + '?manage_tabs_message=Policy+removed.'
00686                               )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.CachingPolicyManager.CachingPolicyManager.updatePolicy (   self,
  policy_id,
  predicate,
  mtime_func,
  max_age_secs,
  no_cache,
  no_store,
  must_revalidate,
  vary,
  etag_func,
  REQUEST = None,
  s_max_age_secs = None # integer,
  seconds,
  def,
  proxy_revalidate = 0  # boolean (def. 0),
  public = 0            # boolean (def. 0),
  private = 0           # boolean (def. 0),
  no_transform = 0      # boolean (def. 0),
  enable_304s = 0       # boolean (def. 0),
  last_modified = 1     # boolean (def. 1),
  pre_check = 0         # integer,
  default = None,
  post_check = 0        # integer,
  default = None 
)
    Update a caching policy.

Definition at line 589 of file CachingPolicyManager.py.

00589 
00590                     ):
00591         """
00592             Update a caching policy.
00593         """
00594         if max_age_secs is None or str(max_age_secs).strip() == '':
00595             max_age_secs = None
00596         else:
00597             max_age_secs = int(max_age_secs)
00598 
00599         if s_max_age_secs is None or str(s_max_age_secs).strip() == '':
00600             s_max_age_secs = None
00601         else:
00602             s_max_age_secs = int(s_max_age_secs)
00603 
00604         if pre_check is None or str(pre_check).strip() == '':
00605             pre_check = None
00606         else:
00607             pre_check = int(pre_check)
00608 
00609         if post_check is None or str(post_check).strip() == '':
00610             post_check = None
00611         else:
00612             post_check = int(post_check)
00613 
00614         self._updatePolicy( policy_id
00615                           , predicate
00616                           , mtime_func
00617                           , max_age_secs
00618                           , no_cache
00619                           , no_store
00620                           , must_revalidate
00621                           , vary
00622                           , etag_func
00623                           , s_max_age_secs
00624                           , proxy_revalidate
00625                           , public
00626                           , private
00627                           , no_transform
00628                           , enable_304s
00629                           , last_modified
00630                           , pre_check
00631                           , post_check
00632                           )
00633         if REQUEST is not None: 
00634             REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00635                                           + '/manage_cachingPolicies'
00636                                           + '?manage_tabs_message='
00637                                           + 'Policy+updated.'
00638                                           )

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve a cache object

Definition at line 871 of file CachingPolicyManager.py.

00871 
00872     def ZCacheManager_getCache(self):
00873         """ Retrieve a cache object
00874         """
00875         cache = getattr(self, '_cache', None)
00876 
00877         if cache is None:
00878             self._cache = CPMCache()
00879             cache = self._cache
00880 
00881         return cache
00882 
00883 
00884 InitializeClass( CachingPolicyManager )
00885 registerToolInterface('caching_policy_manager', ICachingPolicyManager)
00886 


Member Data Documentation

CMFCore.CachingPolicyManager.CachingPolicyManager.__implements__ = z2ICachingPolicyManager [static, private]

Definition at line 463 of file CachingPolicyManager.py.

Definition at line 877 of file CachingPolicyManager.py.

Definition at line 467 of file CachingPolicyManager.py.

Definition at line 473 of file CachingPolicyManager.py.

Definition at line 472 of file CachingPolicyManager.py.

string CMFCore.CachingPolicyManager.CachingPolicyManager.id = 'caching_policy_manager' [static]

Definition at line 465 of file CachingPolicyManager.py.

tuple CMFCore.CachingPolicyManager.CachingPolicyManager.manage_cachingPolicies = DTMLFile( 'cachingPolicies', _dtmldir ) [static]

Definition at line 489 of file CachingPolicyManager.py.

Initial value:
( ( { 'label'  : 'Policies'
                         , 'action' : 'manage_cachingPolicies'
                         , 'help'   : ('CMFCore', 'CPMPolicies.stx')
                         }
                       ,
                       )
                     + CacheManager.manage_options
                     + SimpleItem.manage_options
                     )

Definition at line 478 of file CachingPolicyManager.py.

string CMFCore.CachingPolicyManager.CachingPolicyManager.meta_type = 'CMF Caching Policy Manager' [static]

Definition at line 466 of file CachingPolicyManager.py.

tuple CMFCore.CachingPolicyManager.CachingPolicyManager.security = ClassSecurityInfo() [static]

Definition at line 469 of file CachingPolicyManager.py.


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