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

Class EntryBase

source code

Known Subclasses:
fileentry.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.

Instance Methods [hide private]
varies
__getitem__(self, key, default=None)
Retrieves an item from this dict based on the key given.
source code
 
__init__(self, request) source code
 
__repr__(self)
Returns a friendly debuggable representation of self.
source code
 
__setitem__(self, key, value)
Sets the metadata[key] to the given value.
source code
 
addToCache(self, entryid, data)
Over-writes the cached dict for key entryid with the data dict.
source code
varies
get(self, key, default=None)
Retrieves an item from the internal dict based on the key given.
source code
string
getData(self)
Returns the data string.
source code
dict or None
getFromCache(self, entryid)
Retrieves information from the cache that pertains to this specific entryid.
source code
string
getId(self)
This should return an id that's unique enough for caching purposes.
source code
varies
getMetadata(self, key, default=None)
Returns a given piece of metadata.
source code
list of strings
getMetadataKeys(self)
Returns the list of keys for which we have values in our stored metadata.
source code
boolean
has_key(self, key)
Returns whether a given key is in the metadata dict.
source code
list of varies
keys(self)
Returns a list of the keys that can be accessed through __getitem__.
source code
 
setData(self, data)
Sets the data content for this entry.
source code
 
setMetadata(self, key, value)
Sets a key/value pair in the metadata dict.
source code
 
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.
source code
 
update(self, newdict)
Updates the contents in this entry with the contents in the dict.
source code
Method Details [hide private]

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

source code 

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 (varies) - the key being sought
  • default (varies) - the default to return if the key does not exist
Returns: varies
the value of self._metadata.get(key, default) or self.getData()

__repr__(self)
(Representation operator)

source code 

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)

source code 

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 (varies) - the given key name
  • value (varies) - the given value

addToCache(self, entryid, data)

source code 

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

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

get(self, key, default=None)

source code 

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 (varies) - the key being sought
  • default (varies) - the default to return if the key does not exist
Returns: varies
the value of self._metadata.get(key, default) or self.getData() (through __getitem__)

getData(self)

source code 

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

Override this.
Returns: string
the data as a string

getFromCache(self, entryid)

source code 

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

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

getId(self)

source code 

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

Override this.
Returns: string
string id

getMetadata(self, key, default=None)

source code 

Returns a given piece of metadata.

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

getMetadataKeys(self)

source code 

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 strings
list of metadata keys

has_key(self, key)

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

keys(self)

source code 
Returns a list of the keys that can be accessed through __getitem__.
Returns: list of varies
list of key names

setData(self, data)

source code 

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 (string) - the data

setMetadata(self, key, value)

source code 

Sets a key/value pair in the metadata dict.

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

setTime(self, timetuple)

source code 
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 (tuple of ints) - the timetuple to use to set the data with--this is the same thing as the mtime/atime portions of an os.stat.

update(self, newdict)

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