Package advene :: Package model :: Package core :: Module meta :: Class WithMetaMixin
[hide private]
[frames] | no frames]

Class WithMetaMixin

source code

object --+
         |
        WithMetaMixin
Known Subclasses:

Metadata access mixin.

I factorize all metadata-related code for classes Package and PackageElement.

I also provide an alias mechanism to make frequent metadata easily accessible as python properties.

FIXME: expand description with usage example

Instance Methods [hide private]
 
_update_caches(self, old_idref, new_idref, element, relation)
:see-also: `advene.model.core.element.PackageElement._update_caches`
source code
 
iter_meta(self)
Iter over all the metadata of this object.
source code
 
iter_meta_ids(self)
Iter over all the metadata of this object.
source code
 
get_meta(self, key, default=_RAISE)
Return the metadata (string or element) associated to the given key.
source code
 
get_meta_id(self, key, default=_RAISE, _return_id=True)
Return the metadata id (string or element) associated to the given key.
source code
 
_get_meta_id_or_ref(self, key, default=_RAISE, _return_id=True)
Return the metadata id (string or element) associated to the given key.
source code
 
set_meta(self, key, val, val_is_idref=False)
Set the metadata.
source code
 
del_meta(self, key)
Delete the metadata.
source code
 
_tales_meta(self, context=None) source code
 
_get_ns_dict(self) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods [hide private]
 
make_metadata_property(cls, key, alias=None, default=_RAISE, doc=None)
Attempts to create a python property in cls mapping to metadata key.
source code
Class Variables [hide private]
  __cache = None
  __cache_is_complete = False
Properties [hide private]
  meta

Inherited from object: __class__

Method Details [hide private]

iter_meta(self)

source code 

Iter over all the metadata of this object.

Yields (key, value) pairs, where the value is either a string or an element. If the element is unreachable, value is None.

See also `iter_meta_ids`.

iter_meta_ids(self)

source code 

Iter over all the metadata of this object.

Yields (key, value) pairs, where the value is a string with a special attribute ``is_id`` indicating if it represents the id-ref of an element.

See also `iter_meta`.

get_meta(self, key, default=_RAISE)

source code 

Return the metadata (string or element) associated to the given key.

If no metadata is associated to the given key, a KeyError is raised. If the given key references an unreachable element, a `NoSuchElementError` or `UnreachableImportError` is raised.

All exceptions can be avoided by providing a ``default`` value, that will be returned instead of raising an exception.

get_meta_id(self, key, default=_RAISE, _return_id=True)

source code 

Return the metadata id (string or element) associated to the given key.

The returned value is a string with a special attribute ``is_id`` indicating if it represents the id-ref of an element.

If no metadata is associated to the given key, a KeyError is raised, unless ``default`` is provideded, in which case its value is returned instead.

_get_meta_id_or_ref(self, key, default=_RAISE, _return_id=True)

source code 

Return the metadata id (string or element) associated to the given key.

The returned value is a string with a special attribute ``is_id`` indicating if it represents the id-ref of an element.

If no metadata is associated to the given key, a KeyError is raised, unless ``default`` is provideded, in which case its value is returned instead.

set_meta(self, key, val, val_is_idref=False)

source code 

Set the metadata.

``val`` can either be a PackageElement or a string. If an element, it must be directly imported by the package of self, or a ModelError will be raised.

Use `val_is_idref` only if you know what you are doing: it forces `val` to be interpreted as an id-ref rather than a plain string; if the id-ref has an import-prefix, only the existence of the import is checked. This is mainly useful for parsers.

del_meta(self, key)

source code 

Delete the metadata.

Note that if the given key is not in use, this will have no effect.

make_metadata_property(cls, key, alias=None, default=_RAISE, doc=None)
Class Method

source code 

Attempts to create a python property in cls mapping to metadata key.

If alias is None, key is considered as a URI, and the last part of that URI (after # or /) is used.

If default is not provided, an exception is raised whenever the property is accessed when it is not set. Else, the default value will be returned is that case.

If doc is not None or not provided, a simple docstring will be generated.

Raises an AttributeError if cls already has a member with that name.

FIXME: should attach docstring to the property somehow

_tales_meta(self, context=None)

source code 
Decorators:
  • @tales_property

Property Details [hide private]

meta

Get Method:
unreachable.meta(self)