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

Class Package

source code

                object --+    
                         |    
        meta.WithMetaMixin --+
                             |
                object --+   |
                         |   |
    events.WithEventsMixin --+
                             |
                object --+   |
                         |   |
tales.WithAbsoluteUrlMixin --+
                             |
                    object --+
                             |
                            Package
Known Subclasses:

FIXME: missing docstring.

Nested Classes [hide private]
  annotation_factory
FIXME: missing docstring.
  all_factory
FIXME: missing docstring.
  import_factory
  list_factory
I expose the protocol of a basic collection, to give access to the items of a list.
  media_factory
  relation_factory
I expose the protocol of a basic collection, to give access to the members of a relation.
  resource_factory
  own_factory
  query_factory
  tag_factory
  view_factory
Instance Methods [hide private]
 
__init__(self, url, create=False, readonly=False, force=False)
FIXME: missing docstring.
source code
 
_make_event_delegate(self)
Required by WithEventsMixin.
source code
 
_make_transient_backend(self)
FIXME: missing docstring.
source code
 
_update_backends_dict(self, _firsttime=False)
FIXME: missing docstring.
source code
 
_get_referrers(self)
Return a dict whose keys are backends, and whose values are dicts whose keys are package ids, and whose keys are packages.
source code
 
close(self)
Free all external resources used by the package's backend.
source code
 
_do_close(self) source code
 
_finish_close(self)
FIXME: missing docstring.
source code
 
save(self, serializer=None)
Save the package to disk if its URL is in the "file:" scheme.
source code
 
save_as(self, url, change_url=False, serializer=None, erase=False)
Save the package under the given URL (if it is in the 'file:' scheme).
source code
 
_get_url(self)
The URL from which this package has been fetched.
source code
 
_get_readonly(self) source code
 
_get_uri(self)
The URI identifying this package.
source code
 
_set_uri(self, uri) source code
 
_get_own(self) source code
 
_get_all(self) source code
 
has_element(self, id, element_type=None) source code
 
get_element(self, id, default=_RAISE)
Get the element with the given id-ref or uri-ref.
source code
 
get(self, id, default=None) source code
 
get_element_by_uriref(self, uriref, default=_RAISE)
Get the element with the given uri-ref.
source code
 
__getitem__(self, id, default=_RAISE)
Get the element with the given id-ref or uri-ref.
source code
 
_get_own_element(self, id, tuple=None, default=_RAISE)
Get the element whose id is given from the own package's elements.
source code
 
_can_reference(self, element)
Return True iff element is owned or directly imported by this package.
source code
 
make_id_for(self, pkg, id)
Compute an id-ref in this package for an element.
source code
 
__iter__(self) source code
 
create_media(self, id, url, frame_of_reference='http://advene.liris.cnrs.fr/ns/frame_of_reference/ms;o=0')
FIXME: missing docstring.
source code
 
create_annotation(self, id, media, begin, end, mimetype, model=None, url='')
FIXME: missing docstring.
source code
 
create_relation(self, id, mimetype='x-advene/none', model=None, url='', members=())
FIXME: missing docstring.
source code
 
create_view(self, id, mimetype, model=None, url='')
FIXME: missing docstring.
source code
 
create_resource(self, id, mimetype, model=None, url='')
FIXME: missing docstring.
source code
 
create_tag(self, id)
FIXME: missing docstring.
source code
 
create_list(self, id, items=())
FIXME: missing docstring.
source code
 
create_query(self, id, mimetype, model=None, url='')
FIXME: missing docstring.
source code
 
create_import(self, id, package)
FIXME: missing docstring.
source code
 
_create_import_in_parser(self, id, url, uri)
As it name implies, this method is stricly reserved to parsers for creating imports without actually loading them.
source code
 
associate_tag(self, element, tag)
Associate the given element to the given tag on behalf of this package.
source code
 
dissociate_tag(self, element, tag)
Dissociate the given element to the given tag on behalf of this package.
source code
 
_get_namespaces_as_dict(self)
Return a dict representing the parser-meta:namespaces metadata, with URIs as keys and prefixes as values.
source code
 
_set_namespaces_with_dict(self, d)
Set the parser-meta:namespaces metadata with a dict like the one returned by ``_get_namespaces_as_dict``.
source code
 
_compute_absolute_url(self, aliases)
Used by `WithAbsoluteUrlMixin`
source code

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

    Inherited from meta.WithMetaMixin
 
_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
 
_get_ns_dict(self) source code
 
_tales_meta(self, context=None) source code
 
_update_caches(self, old_idref, new_idref, element, relation)
:see-also: `advene.model.core.element.PackageElement._update_caches`
source code
 
del_meta(self, key)
Delete the metadata.
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
 
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
 
set_meta(self, key, val, val_is_idref=False)
Set the metadata.
source code
    Inherited from events.WithEventsMixin
 
block_handler(self, handler_id)
Prevent the handler identified by handler_id to be invoked until it is unblocked.
source code
 
connect(self, detailed_signal, handler, *args)
Connect the given handler to the (optionally detailed) signal.
source code
 
disconnect(self, handler_id)
Disconnect the handler associated to the given handler_id.
source code
 
emit(self, detailed_signal, *args)
Cause the object to emit the signal specified by detailed_signal.
source code
 
emit_lazy(self, lazy_params)
Like emit, but lazy_params is assumed to be a function returning an iterable of the params to send to emit.
source code
 
enter_no_event_section(self)
Disable all event emission for this object, until `exit_no_event_section` is called.
source code
 
exit_no_event_section(self)
Re-enables all event emission for this object.
source code
 
handler_block(self, handler_id)
Prevent the handler identified by handler_id to be invoked until it is unblocked.
source code
 
handler_is_connected(self, handler_id)
Return True iff the given handler_id represents a connected handler.
source code
 
handler_unblock(self, handler_id)
Unblock the blocked handler identified by handler_id so it can be invoked again.
source code
 
has_handler(self, handler_id)
Return True iff the given handler_id represents a connected handler.
source code
 
stop_emission(self, detailed_signal)
Stop the current emission of the signal specified by detailed_signal.
source code
 
unblock_handler(self, handler_id)
Unblock the blocked handler identified by handler_id so it can be invoked again.
source code
    Inherited from tales.WithAbsoluteUrlMixin
 
_absolute_url_fail(self, msg='') source code
 
_tales_absolute_url(self, context)
See class documentation.
source code
Class Methods [hide private]
    Inherited from meta.WithMetaMixin
 
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
Properties [hide private]
  closed
  _tales_medias
  _tales_annotations
  _tales_relations
  _tales_lists
  _tales_tags
  _tales_imports
  _tales_queries
  _tales_views
  _tales_resources
  all
  own
  readonly
  uri
The URI identifying this package.
  url
The URL from which this package has been fetched.

Inherited from object: __class__

    Inherited from meta.WithMetaMixin
  meta
Method Details [hide private]

__init__(self, url, create=False, readonly=False, force=False)
(Constructor)

source code 

FIXME: missing docstring.

Parameters:
  • url (string) - the URL of the package
  • create (boolean) - should the package be created ?
  • readonly (boolean) - should the package be readonly (in the case of loading an existing package) ?
  • force (boolean) - ???
Overrides: object.__init__

_get_referrers(self)

source code 

Return a dict whose keys are backends, and whose values are dicts whose keys are package ids, and whose keys are packages. This dict contains all the direct importers of this package, plus this package itself.

close(self)

source code 

Free all external resources used by the package's backend.

It is an error to close a package that is imported by another one, unless they are part of an import cycle. In the latter case, this package will be closed, and the other packages in the cycle will be closed as well.

It is an error to use a package or any of its elements or attributes when the package has been closed. The behaviour is undefined.

save(self, serializer=None)

source code 

Save the package to disk if its URL is in the "file:" scheme.

A specific serializer module can be provided, else if the package was parsed and the parser had a corresponding serializer, that one will be used; else, the extension of the filename will be used to guess the serializer to use.

Note that the file will be silently erased if it already exists.

save_as(self, url, change_url=False, serializer=None, erase=False)

source code 

Save the package under the given URL (if it is in the 'file:' scheme).

If `change_url` is set, the URL of the package will be modified to the corresponding ``file:`` URL.

A specific serializer module can be provided, else the extension of the filename will be used to guess the serializer to use.

Note that if the file exists, an exception will be raised.

_get_url(self)

source code 

The URL from which this package has been fetched.

Decorators:
  • @autoproperty

_get_readonly(self)

source code 
Decorators:
  • @autoproperty

_get_uri(self)

source code 

The URI identifying this package.

It may be different from the URL from which the package has actually been fetched.

Decorators:
  • @autoproperty

_set_uri(self, uri)

source code 
Decorators:
  • @autoproperty

_get_own(self)

source code 
Decorators:
  • @autoproperty

_get_all(self)

source code 
Decorators:
  • @autoproperty

get_element(self, id, default=_RAISE)

source code 

Get the element with the given id-ref or uri-ref.

If the element does not exist, an exception is raised (see below) unless ``default`` is provided, in which case its value is returned.

If 'id' contains a '#', it is assumed to be a URI-ref, else it is assumed to be an ID-ref. In both cases, all imported packages are searched for the element

An `UnreachableImportError` is raised if the given id involves an nonexistant or unreachable import. A `NoSuchElementError` is raised if the last item of the id-ref is not the id of an element in the corresponding package.

Note that packages are also similar to python dictionaries, so `__getitem__` and `get` can also be used to get elements.

get(self, id, default=None)

source code 
Decorators:
  • @tales_path1_function

get_element_by_uriref(self, uriref, default=_RAISE)

source code 

Get the element with the given uri-ref.

If the element does not exist, an exception is raised (see below) unless ``default`` is provided, in which case its value is returned.

An `UnreachableImportError` is raised if the given id involves an nonexistant or unreachable import. A `NoSuchElementError` is raised if the last item of the id-ref is not the id of an element in the corresponding package.

__getitem__(self, id, default=_RAISE)
(Indexing operator)

source code 

Get the element with the given id-ref or uri-ref.

If the element does not exist, an exception is raised (see below) unless ``default`` is provided, in which case its value is returned.

If 'id' contains a '#', it is assumed to be a URI-ref, else it is assumed to be an ID-ref. In both cases, all imported packages are searched for the element

An `UnreachableImportError` is raised if the given id involves an nonexistant or unreachable import. A `NoSuchElementError` is raised if the last item of the id-ref is not the id of an element in the corresponding package.

Note that packages are also similar to python dictionaries, so `__getitem__` and `get` can also be used to get elements.

_get_own_element(self, id, tuple=None, default=_RAISE)

source code 

Get the element whose id is given from the own package's elements.

Id may be a simple id or a path id.

If necessary, it is made from backend data, then stored (as a weak ref) in self._elements to prevent several instances of the same element to be produced.

_can_reference(self, element)

source code 

Return True iff element is owned or directly imported by this package.

element can be either an instance of PackageElement or an id-ref. Note that if element is the id-ref of an imported element, its existence in the imported package is *not* checked (but it is checked that the import exists).

make_id_for(self, pkg, id)

source code 

Compute an id-ref in this package for an element.

The element is identified by ``id`` in the package ``pkg``. It is of course assumed that pkg is imported by this package.

See also `PackageElement.make_id_in`.

_create_import_in_parser(self, id, url, uri)

source code 

As it name implies, this method is stricly reserved to parsers for creating imports without actually loading them. It *must not* be called elsewhere (it would corrupt the package w.r.t. imports).

associate_tag(self, element, tag)

source code 

Associate the given element to the given tag on behalf of this package.

`element` must normally be a PackageElement instance and `tag` a TAG instance. In the case one of them is an imported element, the id-ref can actually be given instead of the actual element, but this should be used only in situation where robustness to unreachable elements is desirable (e.g. parsers).

_get_namespaces_as_dict(self)

source code 

Return a dict representing the parser-meta:namespaces metadata, with URIs as keys and prefixes as values.

Note that changing this dict does not affect the metadata. For this, use ``_set_namespaces_with_dict``.


Property Details [hide private]

closed

Get Method:
unreachable.closed(self)

_tales_medias

Get Method:
unreachable._tales_medias(self)

_tales_annotations

Get Method:
unreachable._tales_annotations(self)

_tales_relations

Get Method:
unreachable._tales_relations(self)

_tales_lists

Get Method:
unreachable._tales_lists(self)

_tales_tags

Get Method:
unreachable._tales_tags(self)

_tales_imports

Get Method:
unreachable._tales_imports(self)

_tales_queries

Get Method:
unreachable._tales_queries(self)

_tales_views

Get Method:
unreachable._tales_views(self)

_tales_resources

Get Method:
unreachable._tales_resources(self)

all

Get Method:
_get_all(self)

own

Get Method:
_get_own(self)

readonly

Get Method:
_get_readonly(self)

uri

The URI identifying this package.

It may be different from the URL from which the package has actually been fetched.

Get Method:
_get_uri(self) - The URI identifying this package.
Set Method:
_set_uri(self, uri)

url

The URL from which this package has been fetched.

Get Method:
_get_url(self) - The URL from which this package has been fetched.