Package amplee :: Package atompub :: Package member :: Module helper :: Class MemberHelper
[hide private]
[frames] | no frames]

Class MemberHelper

source code

object --+
         |
        MemberHelper

Instance Methods [hide private]
 
__init__(self, collection, existing_member=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
initiate(self, id)
Creates a default Atom entry document with its id, published, updated and edited children set.
source code
 
add_edit_link(self, edit_url)
Adds an atom:link rel='edit' to the entry
source code
 
add_edit_media_link(self, edit_url, media_type, length=None)
Adds an atom:link rel='edit-media' to the entry
source code
 
add_remote_content(self, media_id, media_type)
Adds an atom:content element with src and type attributes.
source code
amara.bindery.root_base subclass
add_element(self, name, content=None, attributes=None, prefix=None, ns=None, parent=None)
Adds a child to an element
source code
amara.bindery.root_base subclass
copy_element(self, name, source=None, destination=None, ns=None)
Copies an element into another element
source code
 
copy_elements(self, name, source=None, destination=None, ns=None)
Copies a list of elements into another element
source code
bool
is_draft(self, source)
Checks to see if source is a draft or not.
source code
bool
requires_summary(self)
Returns True if the entry requires an atom:summary to be added based on section 4.1.2 of RFC 4287.
source code
bool
requires_author(self)
Returns True if the entry requires an atom:author to be added based on section 4.1.2 of RFC 4287.
source code
 
validate(self)
Validates this entry by following section 4.1.2 of RFC 4287
source code
 
remove_duplicates(self, name, ns, prefix)
Removes duplicate elements in the entry and keeps only the first one found.
source code
 
copy_from(self, entry, include_content=True)
Copies elements from the entry into self.entry and ensures this process keeps self.entry valid as per RFC 4287.
source code
 
clone(self, entry, preserve_id=False, preserve_dates=False, include_content=True)
Makes a clone of the provided entry but keeps from self.entry some element values based on the parameters of the function call.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, collection, existing_member=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

initiate(self, id)

source code 

Creates a default Atom entry document with its id, published, updated and edited children set. If the collection has a xml_base attribute set it will also set it.

Parameters:
  • id (unicode) - identifier of the entry

add_edit_link(self, edit_url)

source code 

Adds an atom:link rel='edit' to the entry

Parameters:
  • member_id (unicode) - identifier of the member resource

add_edit_media_link(self, edit_url, media_type, length=None)

source code 

Adds an atom:link rel='edit-media' to the entry

Parameters:
  • media_id (unicode) - identifier of the member resource
  • media_type (unicode) - mime type of the resource
  • length (unicode) - if provided an unicode object to fill the length attribute of the link

add_remote_content(self, media_id, media_type)

source code 

Adds an atom:content element with src and type attributes. The src value will be computed based on internal the collection.base_uri attribute and the media_id.

Parameters:
  • media_id (unicode) - value to be used for the last segment of the IRI
  • media_type (unicode) - the mime type of the remote resource

add_element(self, name, content=None, attributes=None, prefix=None, ns=None, parent=None)

source code 

Adds a child to an element

Parameters:
  • name (unicode) - name of the element
  • content (unicode) - value of the element
  • attributes (dict) - dictionnary of attributes to set (keys and values must be unicode)
  • prefix (unicode) - XML prefix (if not provided defaults to the one from self.entry
  • ns (unicode) - XML namespace (if not provided defaults to the one from self.entry)
  • parent (amara.bindery.root_base or subclass) - if provided the child will be attached to parent, otherwise parent will default to self.entry
Returns: amara.bindery.root_base subclass
the newly created and added child

copy_element(self, name, source=None, destination=None, ns=None)

source code 

Copies an element into another element

Parameters:
  • name (unicode) - name of the element to copy
  • source (amara.bindery.root_base subclass) - element containing a child name
  • destination (unicode) - element to which attached the copy
  • ns (unicode) - XML namespace to match (if not provided defaults from self.entry)
Returns: amara.bindery.root_base subclass
the newly copied element

copy_elements(self, name, source=None, destination=None, ns=None)

source code 

Copies a list of elements into another element

Parameters:
  • name (unicode) - name of the elements to copy
  • source (amara.bindery.root_base subclass) - element containing a child name
  • destination (unicode) - element to which attached the copy
  • ns (unicode) - XML namespace to match (if not provided defaults from self.entry)

is_draft(self, source)

source code 

Checks to see if source is a draft or not.

Parameters:
  • source (amara.bindery.root_base) - amara instance against which to test the following XPath 'app:control/app:draft'
Returns: bool
True it's a draft, False otherwise

requires_summary(self)

source code 

Returns True if the entry requires an atom:summary to be added based on section 4.1.2 of RFC 4287.

Returns: bool
returns True if the entry requires an atom:summary

requires_author(self)

source code 

Returns True if the entry requires an atom:author to be added based on section 4.1.2 of RFC 4287.

Returns: bool
returns True if the entry requires an atom:author

remove_duplicates(self, name, ns, prefix)

source code 

Removes duplicate elements in the entry and keeps only the first one found.

Parameters:
  • ns (unicode) - namespace of the element to lookup and remove
  • prefix (unicode) - prefix of the element to lookup and remove
  • name (unicode)

copy_from(self, entry, include_content=True)

source code 

Copies elements from the entry into self.entry and ensures this process keeps self.entry valid as per RFC 4287.

Parameters:
  • entry (amara.bindery.root_base) - source entry
  • include_content (bool) - indicates whether or not we are interested in copying the content as well

clone(self, entry, preserve_id=False, preserve_dates=False, include_content=True)

source code 

Makes a clone of the provided entry but keeps from self.entry some element values based on the parameters of the function call.

At the end of the function, self.entry is set to the clone of entry.

Parameters:
  • entry (amara.bindery.root_base) - entry that should be cloned and set to self.entry
  • preserve_id (bool) - indicates if self.entry.id must be kept.
  • preserve_dates (bool) - if False then self.entry.published, self.entry.updated and self.entry.edited are kept from self.entry Otherwise, use the ones provided in the clone.