| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
AtomPubCollection
|
|||
|
__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',
accept_media_types=None,
categories=None,
fixed_categories=None,
favorite=False) Atom Publishing Protocol collection handler. |
||
|
store_container(self) ... |
||
|
attach(self,
member,
member_content,
member_id=None,
member_path=None,
media_id=None,
media_path=None,
media_content=None,
check_media_type=True) Add a member to this collection by * adding it to the store * adding it to the self.members dictionary You are not forced to pass the resource content through this method if you prefer storing it in a different location without using amplee. |
||
|
prune(self,
member_id=None,
media_id=None) Removes a member from a collection and the underlying stor. |
||
|
convert_id(self,
id) Take the parameter and returns a tuple such as (member_id, media_id). |
||
|
contains(self,
path) ... |
||
|
get_meta_data_path(self,
id) Constructs and returns the path to the member pointed by the id parameter. |
||
|
get_content_path(self,
id) Constructs and returns the path to the resource pointed by the id parameter. |
||
|
get_meta_data(self,
path) Returns an object stored as meta-data information in the store for a resource. |
||
|
get_content(self,
path) Returns the content of the media resource or None. |
||
|
to_feed(self,
prefix=ATOM10_PREFIX,
namespace=ATOM10_NS) ... |
||
|
to_collection(self,
prefix=ATOMPUB_PREFIX,
namespace=ATOMPUB_NS) ... |
||
|
reload_members(self) Reloads every existing members into self.members. |
||
|
Inherited from |
|||
|
|||
| store | ||
| feed | ||
| collection | ||
|
Inherited from |
|||
|
|||
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')
accept_media_types -- List of a strings of acceptable media-types for
this collection
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
Once an instance created you can set on_create, on_update and on_delete
attributes to a callback that will be applied before the
new member is being attached to the collection.
If the callback raise amplee.error.ResourceOperationException
it will not attach the resource but instead will force the
HTTP method handler to returns the error code and message
defines in the exception. This allows extra processing on the
member and resource before it being stored.
on_create take two arguments:
amplee.atompub.member.* -- newly created or existing member
string object -- new resource content
returns member, content to be persisted into the store
on_update takes three arguments:
amplee.atompub.member.EntryMember -- existing member in the store
amplee.atompub.member.* -- newly created or existing member
string object -- new resource content
returns member, content to be persisted into the store
on_delete takes:
amplee.atompub.member.* -- existing member
returns None
Becareful when you update a resource, the on_update member provides
the existing entry member as well as the new member generated frm the
updated content provided. Amplee will not try to be smarter than you.
This means that if your callback does nothing at all the existing
member will be entirely replaced by the one generated. It would be wise
that your callback keeps at least the id and published elements.
For instance:
def on_update_cb(existing_member, new_member, new_content):
# Ensure that atom:id stays the same throughout of the
# life of the resource
if new_member.atom.has_element('id', ATOM10_NS):
del new_member.atom.id
Element(u'id', content=unicode(existing_member.atom.id),
prefix=new_member.atom.xml_prefix, namespace=new_member.atom.xml_ns,
parent=new_member.atom)
if new_member.atom.has_element('published', ATOM10_NS):
del new_member.atom.published
Element(u'published', content=unicode(existing_member.atom.published),
prefix=new_member.atom.xml_prefix, namespace=new_member.atom.xml_ns,
parent=new_member.atom)
new_member.member_id = existing_member.member_id
new_member.media_id = existing_member.media_id
return new_member, new_content
Although this seems heavy work it allows the developer to have a very fine
granularity over resources.
|
Returns the store carrying this collection |
Add a member to this collection by * adding it to the store * adding it to the self.members dictionary 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.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_path -- Path under this member is stored media_id -- Internal id used to reference the resource associated to this member. media_path -- Path 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 |
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 |
Take the parameter and returns a tuple such as (member_id, media_id). Keyword arguments: id -- Can be either member_id or media_id |
Does a path belong to the store |
Constructs and returns the path to the member pointed by the id parameter. |
Constructs and returns the path to the resource pointed by the id parameter. |
Returns an object stored as meta-data information in the store for a resource. Does not check the existence of the resource. |
Returns the content of the media resource or None. Does not check the existence of the resource. |
Transforms and returns the collection into an bridge.Element instance |
Tranforms and returns the collection into a bridge.Element instance |
Reloads every existing members into self.members. Call this at server startup to refresh the collection. Careful as this could be a fairly long process. |
|
|||
storeNone
|
feedNone
|
collectionNone
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0alpha3 on Sat Nov 18 23:31:57 2006 | http://epydoc.sourceforge.net |