Table of Contents

Module: attributes ./src/peak/binding/attributes.py
Imported modules   
import dispatch
from interfaces import IActiveDescriptor
from peak.util import decorators
import protocols
from protocols import adapt
from types import ClassType
Functions   
_boostedMeta
activateClass
declareAttribute
declareCM_None
declareCM_Sequence
declareClassMetadata
declareMetadata
declare_None
declare_Sequence
initAttrs
metadata
supertype
  _boostedMeta 
_boostedMeta (
        meta,
        name,
        cdict,
        )

  activateClass 
activateClass ( klass )

Activate any IActiveDescriptor or classAttr objects in klass

Any IActiveDescriptor objects found in the class dictionary will have their activateInClass() method called with the target class and attribute name. The return value is then placed in a __class_descriptors__ mapping that maps from attribute names to return values.

If the class dictionary contains any binding.classAttr instances, these are attached to a new metaclass for the class, and the class is rebuilt as an instance of the new metaclass.

activateClass() does nothing if the class already possesses a __class_descriptors__ mapping, so it is safe to call it more than once on the same class.

  declareAttribute 
declareAttribute (
        classobj,
        attrname,
        metadata,
        )

Declare metadata about attrname in classobj

This generic function is used to dispatch metadata declarations. You do not normally call it directly, unless implementing a metadata API or attribute descriptor. Instead, you add methods to it, in order to support a new metadata type you've defined.

Note that it's up to your methods to define the semantics, such as where the metadata will be stored. The only predefined semantics are for metadata of None (which is a no-op), and protocols.IBasicSequence types (which recursively invokes declareAttribute() on the sequence's contents).

Also note that many metadata frameworks have a notion of context, such that different metadata might apply to the class in different contexts. If this is the case for your metadata type, the method you add to this function should set metadata for whatever your framework's "default context" is.

  declareCM_None 
declareCM_None (
        classobj,
        attrname,
        metadata,
        )

Declaring attribute metadata of None is a no-op.

  declareCM_Sequence 
declareCM_Sequence ( classobj,  metadata )

Declaring attribute w/a sequence declares all contained items

  declareClassMetadata 
declareClassMetadata ( classobj,  metadata )

Declare metadata about classobj

This generic function is used to dispatch metadata declarations. You do not normally call it directly, unless implementing a metadata API or special class advisor. Instead, you add methods to it, in order to support a new metadata type you've defined.

Note that it's up to your methods to define the semantics, such as where the metadata will be stored. The only predefined semantics are for metadata of None (which is a no-op), and protocols.IBasicSequence types (which recursively invokes declareClassMetadata() on the sequence's contents).

Also note that many metadata frameworks have a notion of context, such that different metadata might apply to the class in different contexts. If this is the case for your metadata type, the method you add to this function should set metadata for whatever your framework's "default context" is.

  declareMetadata 
declareMetadata (
        classobj,
        *args,
        *kw,
        )

Declare metadata for specified class and its attributes

Usage:

        binding.declareAttributes(SomeClass,
            <a href="#AdministratorPermission">[AdministratorPermission]</a>,
            some_attr=[security.Anybody, options.Set('-v',value=True)],
            other_attr=syntax("foo|bar"),
                # etc...
        )

The first argument is the class for which metadata is being declared. The second and subsequent positional arguments, if any are metadata for the class as a whole. Keyword arguments are treated as attribute names, and their values are passed to binding.declareAttribute() in order to declare the given metadata for the containing class.

Please see individual frameworks' documentation for information about what metadata they need or provide, and what that metadata's semantics are.

  declare_None 
declare_None (
        classobj,
        attrname,
        metadata,
        )

Declaring attribute metadata of None is a no-op.

  declare_Sequence 
declare_Sequence (
        classobj,
        attrname,
        metadata,
        )

Declaring attribute w/a sequence declares all contained items

  initAttrs 
initAttrs ( ob,  attrItems )

Initialize ob using attrItems

ob can be any object with a __class__ attribute. attrItems must be an iterable of name/value pairs (such as a dictionary's items() or iteritems()). For each name, if it is a valid attribute of the object's class, then the attribute will be set with setattr(ob,name,value). If the name does not exist as an attribute of the object's class, a TypeError will be raised, identifying the incorrect name/constructor keyword.

Exceptions   
TypeError("%s constructor has no keyword argument %s" %( klass, k ) )
  metadata 
metadata ( *args,  *kw )

Declare metadata for containing class and its attributes

Usage:

        class Foo:
            binding.metadata(baz, a=b, x=y)

is a shortcut for:

        class Foo:
            pass

        binding.declareMetadata(Foo, baz, a=b, x=y)

See binding.declareMetadata() for more details.

  supertype 
supertype ( supertype,  subtype )

Workaround for super() not handling metaclasses well

Note that this will skip any classic classes in the MRO!

Exceptions   
TypeError( "Not sub/supertypes:", supertype, subtype )
Classes   

Activator

Descriptor metadata management

classAttr

Class attribute binding


Table of Contents

This document was automatically generated on Mon Mar 25 01:11:04 2024 by HappyDoc version 2.1