Package entropy :: Package client :: Package services :: Module interfaces :: Class Document

Class Document

source code


User Generated Content Document object. It inherits a dictionary and contains metadata bound to a single content item (such as, a user comment, image, etc). Since the metadata format is "volatile" at the moment, you should use Document.get() to retrieve metadata objects (this is a hash table) rather than relying on __getitem__ (using obj[item_key]).

Instance Methods
new empty dictionary

__init__(self, repository_id, document_id, document_type_id)
Document constructor.
source code
string
repository_id(self)
Return the currently set repository identifier.
source code
int
document_id(self)
Return the currently set document unique identifier.
source code
int
document_type(self)
Return the document type identifier, which is always one of: Document.UNKNOWN_TYPE_ID, Document.COMMENT_TYPE_ID, Document.BBCODE_TYPE_ID, Document.IMAGE_TYPE_ID, Document.FILE_TYPE_ID, Document.VIDEO_TYPE_ID
source code
object or None
document_data(self)
Return encapsulated document data.
source code
string
document_keywords(self)
Return a string containing space separated keywords bound to this document.
source code
float
document_timestamp(self)
Return the document timestamp.
source code
string or None
document_url(self)
Return the document url, if any.
source code
bool
is_icon(self)
Return whether this Document is an Icon document.
source code
bool
is_image(self)
Return whether this Document is an Image document.
source code
bool
is_comment(self)
Return whether this Document is a Comment document.
source code
bool
is_file(self)
Return whether this Document is a File document.
source code
bool
is_video(self)
Return whether this Document is a Video document.
source code
string or None
local_document(self)
Return the local document data file path.
source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables
  UNKNOWN_TYPE_ID = -1
  COMMENT_TYPE_ID = 1
  IMAGE_TYPE_ID = 3
  FILE_TYPE_ID = 4
  VIDEO_TYPE_ID = 5
  ICON_TYPE_ID = 6
  SUPPORTED_TYPES = (1, 3, 4, 5, 6)
  DESCRIPTION_PLURAL = {-1: u'Unknown documents', 1: u'Comments'...
  DESCRIPTION_SINGULAR = {-1: u'Unknown document', 1: u'Comment'...
  PACKAGE_ICON_TITLE_ID = '__icon__'
  DOCUMENT_REPOSITORY_ID = 'repository_id'
  DOCUMENT_DOCUMENT_ID = 'document_id'
  DOCUMENT_DOCUMENT_TYPE_ID = 'document_type_id'
  DOCUMENT_DATA_ID = 'ddata'
  DOCUMENT_TITLE_ID = 'title'
  DOCUMENT_DESCRIPTION_ID = 'description'
  DOCUMENT_KEYWORDS_ID = 'keywords'
  DOCUMENT_TIMESTAMP_ID = 'ts'
  DOCUMENT_URL_ID = 'url'

Inherited from dict: __hash__

Properties

Inherited from object: __class__

Method Details

__init__(self, repository_id, document_id, document_type_id)
(Constructor)

source code 

Document constructor.

Parameters:
  • repository_id (string) - repository identifier
  • document_id (int) - document unique identifier
  • document_id (int) - document type identifier
Returns:
new empty dictionary

Overrides: object.__init__

repository_id(self)

source code 

Return the currently set repository identifier.

Returns: string
the repository identifier

document_id(self)

source code 

Return the currently set document unique identifier.

Returns: int
document unique identifier

document_type(self)

source code 

Return the document type identifier, which is always one of: Document.UNKNOWN_TYPE_ID, Document.COMMENT_TYPE_ID, Document.BBCODE_TYPE_ID, Document.IMAGE_TYPE_ID, Document.FILE_TYPE_ID, Document.VIDEO_TYPE_ID

Returns: int
the document type identifier

document_data(self)

source code 

Return encapsulated document data. This is an opaque object, usually string, that depends on the document type. If there is no document data, None is returned.

Returns: object or None
document data

document_keywords(self)

source code 

Return a string containing space separated keywords bound to this document. string is always returned, even if metadatum is not available.

Returns: string
document keywords

document_timestamp(self)

source code 

Return the document timestamp. If value is not available (unlikely) the returned value will be 0.0.

Returns: float
document timestamp

document_url(self)

source code 

Return the document url, if any.

Returns: string or None
document URL

is_icon(self)

source code 

Return whether this Document is an Icon document.

Returns: bool
True, if Document is representing an icon

is_image(self)

source code 

Return whether this Document is an Image document.

Returns: bool
True, if Document is representing an image

is_comment(self)

source code 

Return whether this Document is a Comment document.

Returns: bool
True, if Document is representing a Comment

is_file(self)

source code 

Return whether this Document is a File document.

Returns: bool
True, if Document is representing a File

is_video(self)

source code 

Return whether this Document is a Video document.

Returns: bool
True, if Document is representing a Video

local_document(self)

source code 

Return the local document data file path. This is where the fetched document data (pointed at "url" metadatum) should be placed. If the file is available, it means that the document data has been already fetched on disk. This method can return None, in case there is no URL associated with it.

Returns: string or None
the local document data file path

Class Variable Details

DESCRIPTION_PLURAL

Value:
{-1: u'Unknown documents',
 1: u'Comments',
 3: u'Images/Screenshots',
 4: u'Generic Files',
 5: u'Videos',
 6: u'Icons'}

DESCRIPTION_SINGULAR

Value:
{-1: u'Unknown document',
 1: u'Comment',
 3: u'Image/Screenshot',
 4: u'Generic File',
 5: u'Video',
 6: u'Icon'}