Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.web.contexts.EnvironProxy Class Reference

List of all members.

Public Member Functions

def __init__
def get
def set
def delete
def __repr__

Public Attributes

 name
 default

Detailed Description

Proxy attribute lookups to keys in the environ. 

Definition at line 29 of file contexts.py.


Constructor & Destructor Documentation

def MoinMoin.web.contexts.EnvironProxy.__init__ (   self,
  name,
  default = NoDefault 
)
An entry will be proxied to the supplied name in the .environ
object of the property holder. A factory can be supplied, for
values that need to be preinstantiated. If given as first
parameter name is taken from the callable too.

@param name: key (or factory for convenience)
@param default: literal object or callable

Definition at line 31 of file contexts.py.

00031 
00032     def __init__(self, name, default=NoDefault):
00033         """
00034         An entry will be proxied to the supplied name in the .environ
00035         object of the property holder. A factory can be supplied, for
00036         values that need to be preinstantiated. If given as first
00037         parameter name is taken from the callable too.
00038 
00039         @param name: key (or factory for convenience)
00040         @param default: literal object or callable
00041         """
00042         if not isinstance(name, basestring):
00043             default = name
00044             name = default.__name__
00045         self.name = 'moin.' + name
00046         self.default = default
00047         property.__init__(self, self.get, self.set, self.delete)


Member Function Documentation

Definition at line 67 of file contexts.py.

00067 
00068     def __repr__(self):
00069         return "<%s for '%s'>" % (self.__class__.__name__,
00070                                   self.name)

def MoinMoin.web.contexts.EnvironProxy.delete (   self,
  obj 
)

Definition at line 64 of file contexts.py.

00064 
00065     def delete(self, obj):
00066         del obj.environ[self.name]

def MoinMoin.web.contexts.EnvironProxy.get (   self,
  obj 
)

Definition at line 48 of file contexts.py.

00048 
00049     def get(self, obj):
00050         if self.name in obj.environ:
00051             res = obj.environ[self.name]
00052         else:
00053             factory = self.default
00054             if factory is NoDefault:
00055                 raise AttributeError(self.name)
00056             elif hasattr(factory, '__call__'):
00057                 res = obj.environ.setdefault(self.name, factory(obj))
00058             else:
00059                 res = obj.environ.setdefault(self.name, factory)
00060         return res

Here is the caller graph for this function:

def MoinMoin.web.contexts.EnvironProxy.set (   self,
  obj,
  value 
)

Definition at line 61 of file contexts.py.

00061 
00062     def set(self, obj, value):
00063         obj.environ[self.name] = value

Here is the caller graph for this function:


Member Data Documentation

Definition at line 45 of file contexts.py.

Definition at line 44 of file contexts.py.


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