Package amplee :: Package atompub :: Module collection :: Class AtomPubCollection
[show private | hide private]
[frames | no frames]

Type AtomPubCollection

object --+
         |
        AtomPubCollection


Method Summary
  __init__(self, workspace, name_or_id, title, base_uri, base_edit_uri, base_media_edit_uri, xml_attrs, member_extension, member_media_type, accept_media_types, categories, fixed_categories, favorite, editable_media_types)
Atom Publishing Protocol collection handler.
  add_indexer(self, indexer)
Add an initialized amplee.indexer.Indexer instance to the collection
  attach(self, member, member_content, member_id, member_info, media_id, media_info, media_content, check_media_type)
Add a member to this collection by * adding it to the store * adding it to the internal cache if it is enabled You are not forced to pass the resource content through this method if you prefer storing it in a different location without using amplee.
  contains(self, info, as_media)
Does a info belong to the store
  convert_id(self, id)
Take the parameter and returns a tuple such as (member_id, media_id).
  dispatch(self, operation, media_type, *args, **kwargs)
Dispatches the operation based for that media-type to the matching handler
  enable_cache(self)
Enable the internal cache
  get_base_edit_uri(self)
Returns the absolute URI to the collection for editing operations
  get_base_media_edit_uri(self)
Returns the absolute URI to the collection for media-editing operations
  get_base_uri(self)
Returns the absolute URI to the collection public face
  get_content(self, info)
Returns the content of the media resource or None.
  get_content_info(self, id)
Constructs and returns the info to the resource pointed by the id parameter.
  get_handler(self, media_type)
Returns a tuple (handler, memember_type) based on the provided media_type
  get_member(self, member_id)
Returns the requested member or None if not found.
  get_meta_data(self, info)
Returns an object stored as meta-data information in the store for a resource.
  get_meta_data_info(self, id)
Constructs and returns the info to the member pointed by the id parameter.
  get_xml_base(self)
Returns the first available xml:base value from either the collection, its workspace or service.
  load_member(self, member_id, member_info)
Loads a member from its storage and returns it or None if not found.
  prune(self, member_id, media_id)
Removes a member from a collection and the underlying stor.
  register_handler(self, handler)
Registers the provided handler to be available to this collection.
  reload_members(self, limit)
Reloads all or part of existing members.
  reload_members_from_feed(self, source)
Reloads members from a an atom feed.
  reload_members_from_list(self, member_ids)
Given a list of member_ids this will return a list of loaded members.
  store_container(self)
Returns the store carrying this collection
  to_collection(self, prefix, namespace)
Tranforms and returns the collection into a bridge.Element instance
  to_feed(self, members, prefix, namespace, limit, mint)
Generates an atom feed from the list of ``members`` provided, or if not provided, from the store directly up to the ``limit`` provided.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  collection: Tranforms and returns the collection into a bridge.Element instance
  feed: Generates an atom feed from the list of ``members`` provided, or if not provided, from the store directly up to the ``limit`` provided.
  store: Returns the store carrying this collection

Method Details

__init__(self, workspace, name_or_id, title, base_uri, base_edit_uri, base_media_edit_uri=None, xml_attrs=None, member_extension=u'atom', member_media_type=u'application/atom+xml;type=entry', accept_media_types=None, categories=None, fixed_categories=None, favorite=False, editable_media_types=None)
(Constructor)

Atom Publishing Protocol collection handler.

Keyword arguments: workspace -- AtomPubWorkspace instance carrying this collection name_or_id -- Name or identifier by which you reference this collection within the store [eg: 'audio'] base_uri -- Base URI of the content used in links and external content base_edit_uri -- Base URI used for the edit links base_media_edit_uri -- Base URI used for the edit-media links. If None will use base_edit_uri. xml_attrs -- dictionary of XML attributes belonging to the xml namespace (http://www.w3.org/XML/1998/namespace). They will be passed to the top level Atom elements (feed, entry, etc.) member_extension -- Extension used for the Atom entries representing the member resource (default to 'atom') member_media_type -- Media type for the Atom entries representing the member resource default to 'application/atom+xml;type=entry') accept_media_types -- List of a strings of acceptable media-types for this collection accept_media_types -- List of strings of acceptable media-types to be created within this collection editable_media_types -- List of strings of acceptable media-types to be editable within this collection. If not provided it defaults to 'accept_media_types' categories -- List of bridge.Element instances fixed_categories -- True => 'yes', False => 'no', None => undefined favorite -- if True means thiscollection is the preferred one in the workspace
Overrides:
__builtin__.object.__init__

add_indexer(self, indexer)

Add an initialized amplee.indexer.Indexer instance to the collection

attach(self, member, member_content, member_id=None, member_info=None, media_id=None, media_info=None, media_content=None, check_media_type=True)

Add a member to this collection by
 * adding it to the store
 * adding it to the internal cache if it is enabled

You are not forced to pass the resource content through this
method if you prefer storing it in a different location
without using amplee.

This method will throw a amplee.error.FixedCategoriesError
is self.fixed_categories is True and none of the member
categories matches self.categories.

This method will throw a amplee.error.UnsupportedMediaType
exception if check_media_type is True and the media type of
the media resource does not fall into the allowed list.

Keyword arguments:
member -- amplee.atompub.member.* instance
member_content -- Content to be persisted into the storage.
Usually an XML string of the Atom entry
member_id -- Internal id used to reference this member.
Usually equals to the resource_name + collection.member_extension
member_info -- Info under this member is stored
media_id -- Internal id used to reference the resource associated
to this member.
media_info -- Info under the media resource is stored
media_content -- Resource content
check_media_type -- If False the resource media type will not be
checked against collection.accept_media_types

contains(self, info, as_media=False)

Does a info belong to the store

keyword arguments: info -- a info object as returned by get_meta_data_info or get_content_info as_media -- True when the info is to be tested on the media storage

convert_id(self, id)

Take the parameter and returns a tuple such as (member_id, media_id).

Keyword arguments: id -- Can be either member_id or media_id

dispatch(self, operation, media_type, *args, **kwargs)

Dispatches the operation based for that media-type to the matching handler

Keyword arguments: operation -- name of the callback handler media_type -- media-type string

The *args and **kwargs dicts will be passed to the callback.

Returns the result of the callback.

enable_cache(self)

Enable the internal cache

get_base_edit_uri(self)

Returns the absolute URI to the collection for editing operations

get_base_media_edit_uri(self)

Returns the absolute URI to the collection for media-editing operations

get_base_uri(self)

Returns the absolute URI to the collection public face

get_content(self, info)

Returns the content of the media resource or None.

Does not check the existence of the resource.

get_content_info(self, id)

Constructs and returns the info to the resource pointed by the id parameter.

get_handler(self, media_type)

Returns a tuple (handler, memember_type) based on the provided media_type

Raises a KeyError if it cannot be found

Keyword argument: media_type -- media-type string

get_member(self, member_id)

Returns the requested member or None if not found. If the member is not in the collection cache, amplee attempts to load it from the storage.

Keyword argument: member_id -- identifier of the member as returned by convert_id()

get_meta_data(self, info)

Returns an object stored as meta-data information in the store for a resource.

Does not check the existence of the resource.

get_meta_data_info(self, id)

Constructs and returns the info to the member pointed by the id parameter.

get_xml_base(self)

Returns the first available xml:base value from either the collection, its workspace or service. If none is found it returns an empty string

load_member(self, member_id, member_info=None)

Loads a member from its storage and returns it or None if not found. The member is not added to the collection cache at this stage.

Note that if the MLE has been deleted but not the media resource this method will still return None as if both didn't exist anymore. It's up to the application to cleanup the storages from time to time.

Keyword argument: member_id -- identifier of the member as returned by convert_id() member_info -- info as returned by get_meta_data_info(), if not provided it will be computed automatically

prune(self, member_id=None, media_id=None)

Removes a member from a collection and the underlying stor. Removes only objects passed in the id parameters.

Keyword arguments: member_id -- Identifier of the member media_id -- Identifier of the media resource

register_handler(self, handler)

Registers the provided handler to be available to this collection.

Keyword arguments: handler -- class instance which must have an attribute 'member_type' which is an instance of the amplee.handler.MemberType class

A handler is the instance of a class that may have the following callable attributes:

on_error(exception, member) -> None on_create(member, content) -> member, content on_created(member) -> None on_update(existing_member, new_member, new_content) -> new_member, new_content on_updated(new_member) -> None on_delete(member) -> None on_deleted(member) -> None on_get_content(member, content, content_type) -> member, content, content_type on_get_atom(member) -> member, content, content_type on_update_feed(member) -> None

If present those callbacks will be automatically applied. Not being present doesn't constitute a fault.

reload_members(self, limit=0)

Reloads all or part of existing members. Call this at server startup to refresh the collection. Careful as this could be a fairly long process.

Returns the list of loaded members.

Keyword argument limit -- indicate how many members you want to load By default 0 means all of them.

reload_members_from_feed(self, source)

Reloads members from a an atom feed. This can be useful if you want to keep in the collection cache some given entries. You can construct a feed of those member entries and provide it to this method.

Returns the list of loaded members.

Keyword argument: source -- can be a string, a path or a file object representing the feed

reload_members_from_list(self, member_ids)

Given a list of member_ids this will return a list of loaded members.

store_container(self)

Returns the store carrying this collection

to_collection(self, prefix=u'app', namespace=u'http://www.w3.org/2007/app')

Tranforms and returns the collection into a bridge.Element instance

to_feed(self, members=None, prefix=u'atom', namespace=u'http://www.w3.org/2005/Atom', limit=-1, mint=None)

Generates an atom feed from the list of ``members`` provided, or if not provided, from the store directly up to the ``limit`` provided.

The atom:id element's value will be computed from the collection edit URI, and if provided, the ``mint`` value, which therefore must be string or None.

Returns a bridge.Element instance of the feed.

Property Details

collection

Tranforms and returns the collection into a bridge.Element instance
Get Method:
to_collection(self, prefix, namespace)

feed

Generates an atom feed from the list of ``members`` provided, or if not provided, from the store directly up to the ``limit`` provided.

The atom:id element's value will be computed from the collection edit URI, and if provided, the ``mint`` value, which therefore must be string or None.

Returns a bridge.Element instance of the feed.
Get Method:
to_feed(self, members, prefix, namespace, limit, mint)

store

Returns the store carrying this collection
Get Method:
store_container(self)

Generated by Epydoc 2.1 on Thu Jul 19 15:32:16 2007 http://epydoc.sf.net