Package gavo :: Package base :: Module meta :: Class MetaMixin
[frames] | no frames]

Class MetaMixin

source code

object --+
         |
        MetaMixin
Known Subclasses:

is a mixin for entities carrying meta information.

The meta mixin provides the followng methods:

When querying meta information, by default all parents are queried as well (propagate=True).

Metadata is not copied when the embedding object is copied. That, frankly, has not been a good design descision, and there should probably be a way to pass copypable=True to the mixin's attribute definition.

Instance Methods
 
__init__(self)
is a constructor for standalone use.
source code
 
addMeta(self, key, metaValue, **moreAttrs)
adds metaItem to self under key.
source code
 
buildRepr(self, key, builder, propagate=True, raiseOnFail=True) source code
 
copyMetaFrom(self, other)
sets a copy of other's meta items on self.
source code
 
delMeta(self, key)
removes a meta item from this meta container.
source code
 
getAllMetaPairs(self)
iterates over all meta items this container has.
source code
 
getMeta(self, key, propagate=True, raiseOnFail=False, default=None, acceptSequence=False) source code
 
getMetaKeys(self) source code
 
getMetaParent(self) source code
 
isEmpty(self) source code
 
iterMeta(self, key, propagate=False)
yields all MetaValues for key.
source code
 
keys(self) source code
 
makeOriginal(self, key)
marks the meta item key, if existing, as original.
source code
 
setMeta(self, key, value, **moreAttrs)
replaces any previous meta content of key (on this container) with value.
source code
 
setMetaParent(self, parent) source code
 
traverse(self, builder) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

is a constructor for standalone use. You do *not* want to call this when mixing into a Structure.

Overrides: object.__init__

addMeta(self, key, metaValue, **moreAttrs)

source code 

adds metaItem to self under key.

moreAttrs can be additional keyword arguments; these are used by the XML constructor to define formats or to pass extra items to special meta types.

For convenience, this returns the meta container.

delMeta(self, key)

source code 

removes a meta item from this meta container.

This will not propagate, i.e., getMeta(key) might still return something unless you give propagate=False.

It is not an error do delete an non-existing meta key.

getAllMetaPairs(self)

source code 

iterates over all meta items this container has.

Each item consists of key, MetaValue. Multiple MetaValues per key may be given.

This will not iterate up, i.e., in general, getMeta will succeed for more keys than what's given here.

iterMeta(self, key, propagate=False)

source code 

yields all MetaValues for key.

This will traverse down all branches necessary to yield, in sequence, all MetaValues reachable by key.

If propagation is enabled, the first meta carrier that has at least one item exhausts the iteration.

(this currently doesn't return an iterator but a sequence; that's an implementation detail, though. You should only assume whatever comes back is iterable)

makeOriginal(self, key)

source code 

marks the meta item key, if existing, as original.

This is for when a meta container has copied metadata. DaCHS' default behaviour is that a subsequent addMeta will clear the copied content. Call this method for the key in question to enable adding to copied metadata.