Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
plone.memoize.instance.Memojito Class Reference
Collaboration diagram for plone.memoize.instance.Memojito:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def clear
def clearbefore
def clearafter
def memoize

Static Public Attributes

string propname = '_memojito_'

Detailed Description

Definition at line 10 of file instance.py.


Member Function Documentation

def plone.memoize.instance.Memojito.clear (   self,
  inst 
)

Definition at line 12 of file instance.py.

00012 
00013     def clear(self, inst):
00014         if hasattr(inst, self.propname):
00015             delattr(inst, self.propname)
        

Here is the caller graph for this function:

def plone.memoize.instance.Memojito.clearafter (   self,
  func 
)

Definition at line 23 of file instance.py.

00023 
00024     def clearafter(self, func):
00025         def clear(*args, **kwargs):
00026             inst=args[0]
00027             val = func(*args, **kwargs)
00028             self.clear(inst)
00029             return val 
00030         return clear

Here is the call graph for this function:

def plone.memoize.instance.Memojito.clearbefore (   self,
  func 
)

Definition at line 16 of file instance.py.

00016 
00017     def clearbefore(self, func):
00018         def clear(*args, **kwargs):
00019             inst=args[0]
00020             self.clear(inst)
00021             return func(*args, **kwargs)
00022         return clear

Here is the call graph for this function:

def plone.memoize.instance.Memojito.memoize (   self,
  func 
)

Definition at line 31 of file instance.py.

00031 
00032     def memoize(self, func):
00033         def memogetter(*args, **kwargs):
00034             inst = args[0]
00035             cache = getattr(inst, self.propname, _marker)
00036             if cache is _marker:
00037                 setattr(inst, self.propname, dict())
00038                 cache = getattr(inst, self.propname)
00039 
00040             # XXX this could be potentially big, a custom key should
00041             # be used if the arguments are expected to be big
00042 
00043             key = (func.__name__, args, frozenset(kwargs.items()))
00044             val = cache.get(key, _marker)
00045             if val is _marker:
00046                 val=func(*args, **kwargs)
00047                 cache[key]=val
00048                 setattr(inst, self.propname, cache)
00049             return val
00050         return memogetter
00051 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

string plone.memoize.instance.Memojito.propname = '_memojito_' [static]

Definition at line 11 of file instance.py.


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