Trees | Indices | Help |
|
---|
|
object --+ | _SqliteBackend
I am the reference implementation of advene backend instances. A number of conventions are used in all methods. Method naming rationale ======================= When the parameters *or* return type of methods depend on the element type they handle, distinct methods with the element type in their name are defined (e.g. `create_annotation` vs. `create_view`). On the other hand, if neither the parameters nor the return value change (type-wise) w.r.t. the element type, a single method is defined, with the element type as a parameter (e.g. `delete_element`). Note that, as far as the rule above is concerned, tuples of different size have different types, as well as iterators yielding objects of different types. Note also there is a notable exception to that rule: `get_element`, which does not expect the type of an element, but returns a tuple with all the elements attributes. A protocol forcing to first get the element type, then call the appropriate method, whould have been more regular but inconvenient, and probably less efficient. Parameter names and semantics ============================= package_id the package id as returned in second position by `create` or `bind`. The operation will apply to that particular package. package_ids an iterable of package ids as described above. The operation will apply in one shot on all these packages. id an element id. This is always used in conjunction with ``package_id``. element_type one of the constants defined in `advene.model.core.element`. It is always used in conjunction with ``package_id`` and ``id`` and *must* be consistent with them (i.e. be the type of the identified element if it exists). The behaviour of the method is *unspecified* if ``element_type`` is not consistent. As a consequence, the fact that this particular implementation ignores an inconsistent ``element_type`` and works anyway must *not* be relied on.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
Inform the backend that a given package will no longer be used. NB: this implementation is robust to packages forgetting to close themselves, i.e. when packages are garbage collected, this is detected and they are automatically unbound. |
Delete from the backend all the data about a bound package. Obviously, a deleted package does not need to be closed. |
Create a new media. Raise a ModelException if the identifier already exists in the package. |
Create a new annotation and its associated content. Specific parameters ------------------- media id-ref of the media this annotation refs to begin, end int boundaries of the annotated temporal fragment mimetype the mimetype of the annotation content model the id-ref of the content model for the annotation (can be empty) url if non empty, the annotation content will be not be stored, and will be fetched on demand from that URL Raise a ModelException if the identifier already exists in the package. |
Create a new empty relation and its associated content. Specific parameters ------------------- mimetype the mimetype of the annotation content model the id-ref of the content model for the annotation (can be empty) url if non empty, the annotation content will be not be stored, and will be fetched on demand from that URL Raise a ModelException if the identifier already exists in the package. |
Create a new view and its associated content. Specific parameters ------------------- mimetype the mimetype of the view content model the id-ref of the content model the view (can be empty) url if non empty, the view content will be not be stored, and will be fetched on demand from that URL Raise a ModelException if the identifier already exists in the package. |
Create a new resource and its associated content. Specific parameters ------------------- mimetype the mimetype of the resource content model the id-ref of the content model for the resource (can be empty) url if non empty, the resource content will be not be stored, and will be fetched on demand from that URL Raise a ModelException if the identifier already exists in the package. |
Create a new tag. Raise a ModelException if the identifier already exists in the package. |
Create a new empty list. Raise a ModelException if the identifier already exists in the package. |
Create a new query and its associated content. Specific parameters ------------------- mimetype the mimetype of the query content model the id-ref of the content model for the query (can be empty) url if non empty, the query content will be not be stored, and will be fetched on demand from that URL Raise a ModelException if the identifier already exists in the package. |
Create a new import. Raise a ModelException if the identifier already exists in the package. |
Return True if the given package has an element with the given id. If element_type is provided, only return true if the element has the the given type. |
Return the tuple describing a given element. If the element does not exist, None is returned. |
Iter over all the elements relying on the identified element (where `element` is a uri-ref). Yields 3-tuples where the first item one of the given package_ids, the second element is either an element id-ref or an empty string to identify the package itself. The thirs item describes the relation between the second item and the identified element. It can be either: an attribute name with an element as its value in that case, the identified element is the value of the attribute for the element or package identified by the first item. the string ":item %s" where %s is an int i the first item identifies a list, and its i'th item is the identified element the string ":member %s" where %s is an int i the first item identifies a relation, and its i'th item is the identified element the string ":meta %s" where %s is a metadata key in that case, the identified element is the value of that metadata for the element or package identified by the first item. the string ":tag %s" where %s is an id-ref the identified element is a tag, to which this package identified by the first parameter associates the element identified by the id-ref. the string ":tagged %s" where %s is an id-ref this package associates the identified element the tag identified by the id-ref. The attribute names that may be returned are ``media`` and ``content_model``. |
Iter over all the elements relying on the identified import. Yields 3-tuples where the first item is either an element id-ref or an empty string to identify the package itself and the third item is the id (without the importe prefix) of an element imported through the import in question. The second item describes the relation between the first and third ones. It can be either: an attribute name with an element as its value in that case, the imported element is the value of the attribute for the element or package identified by the first item. the string ":item %s" where %s is an int i the first item identifies a list, and its i'th item is the imported element the string ":member %s" where %s is an int i the first item identifies a relation, and its i'th item is the imported element the string ":meta %s" where %s is a metadata key in that case, the imported element is the value of that metadata for the element or package identified by the first item. the string ":tag %s" where %s is an id-ref the identified element is a tag, to which this package identified by the first parameter associates the element identified by the id-ref. the string ":tagged %s" where %s is an id-ref this package associates the identified element the tag identified by the id-ref. The attribute names that may be returned are ``media`` and ``content_model``. |
Yield tuples of the form (ANNOTATION, package_id, id, media, begin, end, mimetype, model, url), ordered by begin, end and media id-ref. ``media`` is the uri-ref of a media or an iterable of uri-refs. |
Return the number of annotations matching the criteria. ``media`` is the uri-ref of a media or an iterable of uri-refs. |
Rename an own elemenent of package_id. NB: element_type must be provided and must be the type constant of the identified element, or the behaviour of this method is unspecified. NB: This does not update references to that element. For that, you must also use `rename_references`. This however does update the id-ref of imported elements if the renamed element is an import. |
Reflect the renaming of an element in several packages. Apply the change of id of an element (formerly known as old_uriref) in all references to that element in package_ids. |
Delete the identified element. NB: This does not delete references to that element, *even* in the same package. The appropriate methods (`iter_references`, `iter_references_with_import`) must be used to detect and delete those references prior to deletion. |
Return information about the content of an element, or None. The information is a tuple of the form (mimetype, model_id, url), where ``model_id`` and ``url`` can be empty strings. None is returned if the element does not exist or has no content. Note that this method will not be used often since this information is provided by get_element for all elements having a content. |
Update the content information of the identified element. ``model`` is the id of an own or directly imported resource, or an empty string to specify no model (not None). If ``url`` is not an empty string, any data stored in the backend for this content will be discarded. |
Return the stored data, as a string, of the content of an element. This method will return an empty string if the content is externally stored (non-empty ``url`` attribute). |
Update the content data of the identified element. If `data` is not an empty string, the ``url`` attribute of the content will be cleared. |
Return tuples of the form (package_id, id) of all the elements with a content having the given model. @param model the uri-ref of a resource |
Iter over the metadata, sorting keys in alphabetical order. Yield tuples of the form (key, val, val_is_id) (cf. `get_meta` and `set_meta`). If package metadata is targeted, id should be an empty string (in that case, element_type will be ignored). |
Return the given metadata of the identified element. Return a tuple of the form (val, val_is_id) where the second item is a boolean, indicating whether the first item must be interpreted as an id-ref, or None if the element has no metadata with that key. If package metadata is targeted, id should be an empty string (in that case, element_type will be ignored). |
Set the given metadata of the identified element. Parameter ``val_is_id`` indicates whether parameter ``val`` must be interpreted as an id-ref rather than a plain string. Note that ``val`` can also be None to unset the corresponding metadata; in that case, val_is_id is ignored. If package metadata is targeted, id should be an empty string (in that case, element_type will be ignored). |
Iter over the metadata whose value is a reference to the element identified by uriref. The returned iterator yields triples of the form (package_id, element_id, metadata_key) where element_id is the empty string for package metadata.d |
Insert a member at the given position. ``member`` is the id-ref of an own or directly imported member. ``pos`` may be any value between -1 and n (inclusive), where n is the current number of members. If -1, the member will be appended at the end (**note** that this is not the same behaviour as ``list.insert`` in python2.5). If non-negative, the member will be inserted at that position. NB: the total number of members, n, if known, may be provided, as an optimization. |
Remobv the member at the given position in the identified relation. ``member`` is the id-ref of an own or directly imported member. |
Count the members of the identified relations. This should return 0 if the relation does not exist. |
Return the id-ref of the member at the given position in the identified relation. NB: the total number of members, n, if known, may be provided, as an optimization. |
Insert an item at the given position. ``item`` is the id-ref of an own or directly imported item. ``pos`` may be any value between -1 and n (inclusive), where n is the current number of items. If -1, the item will be appended at the end (**note** that this is not the same behaviour as ``list.insert`` in python2.5). If non-negative, the item will be inserted at that position. NB: the total number of members, n, if known, may be provided, as an optimization. |
Remobv the item at the given position in the identified list. ``item`` is the id-ref of an own or directly imported item. |
Count the items of the identified lists. This should return 0 if the list does not exist. |
Return the id-ref of the item at the given position in the identified list. NB: the total number of members, n, if known, may be provided, as an optimization. |
Associate a tag to an element. @param element the id-ref of an own or directly imported element @param tag the id-ref of an own or directly imported tag |
Dissociate a tag from an element. @param element the id-ref of an own or directly imported element @param tag the id-ref of an own or directly imported tag |
Iter over all the tags associated to element in the given packages. @param element the uri-ref of an element |
Iter over all the elements associated to tag in the given packages. @param tag the uri-ref of a tag |
Iter over all the packages associating element to tag. @param element the uri-ref of an element @param tag the uri-ref of a tag |
Iter over all tagging involving two imported elements. This is useful for serialization. |
Is not part of the interface. Instances must be created either with the create or the bind module functions. Create a backend, and bind it to the given URL.
|
Begin a transaction. This method must *always* be used to begin a transaction (do *not* use `self._curs.execute("BEGIN")` directly. See `_FlushableIterator` . |
Perform controls and insertions common to all elements. NB: This starts a transaction that must be commited by caller. |
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 8 16:00:01 2009 | http://epydoc.sourceforge.net |