Package kiwi :: Module accessor
[frames | no frames]

Module kiwi.accessor

The accessor module offers two important front-end functions: kgetattr and ksetattr. These functions allow retrieving attribute values from objects much in the same way as getattr/setattr allow, but with two important differences:
Classes
CacheControl  

Exceptions
DefaultValue This can be raised in kgetattr accessors to indicate that the default value should be used

Function Summary
  clear_attr_cache()
Clears the kgetattr cache.
  enable_attr_cache()
Enables the use of the kgetattr cache when using Python versions that do not support weakrefs (1.5.x and earlier).
  get_default_getter(model, attr_name, cache)
Obtains from model a callable through which attr_name can be retrieved.
  get_default_setter(model, attr_name, cache)
Obtains from model a callable through which attr_name can be set.
  kgetattr(model, attr_name, default, flat, ref, TupleType, MethodType, split, kgetattr_guard, getattr, dummycache, LAMBDA_ACCESS, METHOD_ACCESS, TUPLE_ACCESS, NWR_METHOD_ACCESS, NWR_TUPLE_ACCESS, FAST_METHOD_ACCESS, FAST_TUPLE_ACCESS)
Returns the value associated with the attribute in model named by attr_name.
  kgetattr_guard(wref)
  ksetattr(model, attr_name, value, flat, ref, TupleType, MethodType, ksetattr_guard, getattr, dummycache, LAMBDA_ACCESS, METHOD_ACCESS, TUPLE_ACCESS, NWR_METHOD_ACCESS, NWR_TUPLE_ACCESS, FAST_METHOD_ACCESS, FAST_TUPLE_ACCESS)
Set the value associated with the attribute in model named by attr_name.
  ksetattr_guard(wref)

Variable Summary
_Logger log = <kiwi.log._Logger instance at 0x4117f7cc>

Function Details

clear_attr_cache()

Clears the kgetattr cache. It must be called repeatedly to avoid memory leaks in Python 2.0 and earlier.

enable_attr_cache()

Enables the use of the kgetattr cache when using Python versions that do not support weakrefs (1.5.x and earlier). Be warned, using the cache in these versions causes leaked references to accessor methods and models!

get_default_getter(model, attr_name, cache)

Obtains from model a callable through which attr_name can be retrieved. This callable is an accessor named get_foo, where foo is the value of attr_name, or getattr(model, foo) if the accessor does not exist. If the callable exists, it is returned; if getattr() is to be used a tuple in the format (model, attr_name) is returned.

get_default_setter(model, attr_name, cache)

Obtains from model a callable through which attr_name can be set. This callable is an accessor named set_foo, where foo is the value of attr_name, or setattr(model, foo, value) if the accessor does not exist. If the callable exists, it is returned; if setattr() is to be used a tuple in the format (model, attr_name) is returned.

kgetattr(model, attr_name, default=<class kiwi.accessor._AttrUnset at 0x411746bc>, flat=0, ref=<type 'weakref'>, TupleType=<type 'tuple'>, MethodType=<type 'instancemethod'>, split=<function split at 0x4021572c>, kgetattr_guard=<function kgetattr_guard at 0x411824c4>, getattr=<built-in function getattr>, dummycache=<kiwi.accessor.CacheControl object at 0x4117f86c>, LAMBDA_ACCESS=0, METHOD_ACCESS=1, TUPLE_ACCESS=2, NWR_METHOD_ACCESS=3, NWR_TUPLE_ACCESS=4, FAST_METHOD_ACCESS=5, FAST_TUPLE_ACCESS=6)

Returns the value associated with the attribute in model named by attr_name. If default is provided and model does not have an attribute called attr_name, the default value is returned. If flat=1 is specified, no dot path parsing will be done.

ksetattr(model, attr_name, value, flat=0, ref=<type 'weakref'>, TupleType=<type 'tuple'>, MethodType=<type 'instancemethod'>, ksetattr_guard=<function ksetattr_guard at 0x411825a4>, getattr=<built-in function getattr>, dummycache=<kiwi.accessor.CacheControl object at 0x4117f88c>, LAMBDA_ACCESS=0, METHOD_ACCESS=1, TUPLE_ACCESS=2, NWR_METHOD_ACCESS=3, NWR_TUPLE_ACCESS=4, FAST_METHOD_ACCESS=5, FAST_TUPLE_ACCESS=6)

Set the value associated with the attribute in model named by attr_name. If flat=1 is specified, no dot path parsing will be done.

Variable Details

log

Type:
_Logger
Value:
<kiwi.log._Logger instance at 0x4117f7cc>                              

Generated by Epydoc 2.1 on Mon Jan 29 16:43:01 2007 http://epydoc.sf.net