Package Pyblosxom :: Package entries :: Module fileentry :: Class FileEntry
[hide private]
[frames] | no frames]

Class FileEntry

source code

base.EntryBase --+
                 |
                FileEntry

This class gets it's data and metadata from the file specified by the filename argument.

Instance Methods [hide private]
 
__init__(self, request, filename, root, datadir='') source code
 
__repr__(self)
Returns a representation of this instance with the filename and root.
source code
 
setTimeLazy(self, timetuple)
Set the time without populating the entry.
source code
string
getId(self)
Returns the id for this content item--in this case, it's the filename.
source code
string
getData(self)
Returns the data for this file entry.
source code
varies
getMetadata(self, key, default=None)
This overrides the base.EntryBase getMetadata method.
source code
 
__populatedata(self)
Fills the metadata dict with metadata about the given file.
source code
    Inherited from base.EntryBase
varies
__getitem__(self, key, default=None)
Retrieves an item from this dict based on the key given.
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
dict or None
getFromCache(self, entryid)
Retrieves information from the cache that pertains to this specific entryid.
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]

__init__(self, request, filename, root, datadir='')
(Constructor)

source code 
Parameters:
  • request (Request) - the Request object
  • filename (string) - the complete filename for the file in question including path
  • root (string) - i have no clue what this is
  • datadir (string) - the datadir
Overrides: base.EntryBase.__init__

__repr__(self)
(Representation operator)

source code 
Returns a representation of this instance with the filename and root.
Overrides: base.EntryBase.__repr__

setTimeLazy(self, timetuple)

source code 
Set the time without populating the entry.
Parameters:
  • timetuple (tuple of 9 ints) - the mtime of the file (same as returned by time.localtime(...))

getId(self)

source code 
Returns the id for this content item--in this case, it's the filename.
Returns: string
the id of the fileentry (the filename)
Overrides: base.EntryBase.getId

getData(self)

source code 
Returns the data for this file entry. The data is the parsed (via the entryparser) content of the entry. We do this on-demand by checking to see if we've gotten it and if we haven't then we get it at that point.
Returns: string
the content for this entry
Overrides: base.EntryBase.getData

getMetadata(self, key, default=None)

source code 

This overrides the base.EntryBase getMetadata method.

Note: We populate our metadata lazily--only when it's requested. This delays parsing of the file as long as we can.
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
Overrides: base.EntryBase.getMetadata

__populatedata(self)

source code 
Fills the metadata dict with metadata about the given file. This metadata consists of things we pick up from an os.stat call as well as knowledge of the filename and the root directory. We then parse the file and fill in the rest of the information that we know.