Package Pyblosxom :: Package entries :: Module base :: Class EntryBase
[show private | hide private]
[frames | no frames]

Class EntryBase

Known Subclasses:
FileEntry

EntryBase is the base class for all the Entry classes. Each instance of an Entry class represents a single entry in the weblog, whether it came from a file, or a database, or even somewhere off the InterWeeb.
Method Summary
  __init__(self, request)
varies __getitem__(self, key, default)
Retrieves an item from this dict based on the key given.
  __repr__(self)
Returns a friendly debuggable representation of self.
  __setitem__(self, key, value)
Sets the metadata[key] to the given value.
  addToCache(self, id, data)
Over-writes the cached dict for key id with the data dict.
varies get(self, key, default)
Retrieves an item from the internal dict based on the key given.
string getData(self)
Returns the data string.
dict or None getFromCache(self, id)
Retrieves information from the cache that pertains to this specific id.
string getId(self)
This should return an id that's unique enough for caching purposes.
varies getMetadata(self, key, default)
Returns a given piece of metadata.
list of strings getMetadataKeys(self)
Returns the list of keys for which we have values in our stored metadata.
boolean has_key(self, key)
Returns whether a given key is in the metadata dict.
list of varies keys(self)
Returns a list of the keys that can be accessed through __getitem__.
  setData(self, data)
Sets the data content for this entry.
  setMetadata(self, key, value)
Sets a key/value pair in the metadata dict.
  setTime(self, timeTuple)
This takes in a given time tuple and sets all the magic metadata variables we have according to the items in the time tuple.
  update(self, newdict)
Updates the contents in this entry with the contents in the dict.

Method Details

__getitem__(self, key, default=None)
(Indexing operator)

Retrieves an item from this dict based on the key given. If the item does not exist, then we return the default.

If the item is CONTENT_KEY then we return the result from self.getData().

This is just a convenience method for getData(...) and getMetadata(...).

There's no reason to override this--override getData and getMetadata instead.
Parameters:
key - the key being sought
           (type=varies)
default - the default to return if the key does not exist
           (type=varies)
Returns:
the value of self._metadata.get(key, default) or self.getData()
           (type=varies)

__repr__(self)
(Representation operator)

Returns a friendly debuggable representation of self. Useful to know on what entry pyblosxom fails on you (though unlikely)

returns: Identifiable representation of object rtype: string

__setitem__(self, key, value)
(Index assignment operator)

Sets the metadata[key] to the given value.

This is a convenience method for setData(...) and setMetadata(...).

There's no reason to override this. Override setData and setMetadata.
Parameters:
key - the given key name
           (type=varies)
value - the given value
           (type=varies)

addToCache(self, id, data)

Over-writes the cached dict for key id with the data dict.

This is a helper method--call this to add data to the cache. Do not override it.
Parameters:
id - a unique key for the information you're storing
           (type=string)
data - the data to store--this should probably be a dict
           (type=dict)

get(self, key, default=None)

Retrieves an item from the internal dict based on the key given.

All this does is turn aroun and call __getitem__.

There's no reason to override this--override getData and getMetadata instead.
Parameters:
key - the key being sought
           (type=varies)
default - the default to return if the key does not exist
           (type=varies)
Returns:
the value of self._metadata.get(key, default) or self.getData() (through __getitem__)
           (type=varies)

getData(self)

Returns the data string. This method should be overridden to provide from pulling the data from other places.

Override this.
Returns:
the data as a string
           (type=string)

getFromCache(self, id)

Retrieves information from the cache that pertains to this specific id.

This is a helper method--call this to get data from the cache. Do not override it.
Parameters:
id - a unique key for the information you're retrieving
           (type=string)
Returns:
dict with the values or None if there's nothing for that id
           (type=dict or None)

getId(self)

This should return an id that's unique enough for caching purposes.

Override this.
Returns:
string id
           (type=string)

getMetadata(self, key, default=None)

Returns a given piece of metadata.

Override this.
Parameters:
key - the key being sought
           (type=varies)
default - the default to return if the key does not exist
           (type=varies)
Returns:
either the default (if the key did not exist) or the value of the key in the metadata dict
           (type=varies)

getMetadataKeys(self)

Returns the list of keys for which we have values in our stored metadata.

Note: This list gets modified later downstream. If you cache your list of metadata keys, then this method should return a copy of that list and not the list itself lest it get adjusted.

Override this.
Returns:
list of metadata keys
           (type=list of strings)

has_key(self, key)

Returns whether a given key is in the metadata dict. If the key is the CONTENT_KEY, then we automatically return true.
Parameters:
key - the key to check in the metadata dict for
           (type=varies)
Returns:
whether (1) or not (0) the key exists
           (type=boolean)

keys(self)

Returns a list of the keys that can be accessed through __getitem__.
Returns:
list of key names
           (type=list of varies)

setData(self, data)

Sets the data content for this entry. If you are not creating the entry, then you have no right to set the data of the entry. Doing so could be hazardous depending on what EntryBase subclass you're dealing with.

Override this.
Parameters:
data - the data
           (type=string)

setMetadata(self, key, value)

Sets a key/value pair in the metadata dict.

Override this.
Parameters:
key - the key string
           (type=string)
value - the value string
           (type=string (or an object with a __str__ method))

setTime(self, timeTuple)

This takes in a given time tuple and sets all the magic metadata variables we have according to the items in the time tuple.
Parameters:
timeTuple - the timetuple to use to set the data with--this is the same thing as the mtime/atime portions of an os.stat.
           (type=tuple of ints)

update(self, newdict)

Updates the contents in this entry with the contents in the dict. It does so by calling setData and setMetadata.
Parameters:
newdict - the dict we're updating this one with
           (type=dict)

Generated by Epydoc 2.1 on Tue Feb 7 21:43:57 2006 http://epydoc.sf.net