Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.wikisync.PickleTagStore Class Reference
Inheritance diagram for MoinMoin.wikisync.PickleTagStore:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.wikisync.PickleTagStore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def load
def commit
def add
def get_all_tags
def get_last_tag
def clear
def fetch
def dump

Public Attributes

 page
 filename
 rlock
 wlock
 tags

Detailed Description

This class manages the storage of tags in pickle files. 

Definition at line 435 of file wikisync.py.


Constructor & Destructor Documentation

def MoinMoin.wikisync.PickleTagStore.__init__ (   self,
  page 
)
Creates a new TagStore that uses pickle files.

@param page: a Page object where the tags should be related to

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 438 of file wikisync.py.

00438 
00439     def __init__(self, page):
00440         """ Creates a new TagStore that uses pickle files.
00441 
00442         @param page: a Page object where the tags should be related to
00443         """
00444 
00445         self.page = page
00446         self.filename = page.getPagePath('synctags', use_underlay=0, check_create=1, isfile=1)
00447         lock_dir = os.path.join(page.getPagePath('cache', use_underlay=0, check_create=1), '__taglock__')
00448         self.rlock = lock.ReadLock(lock_dir, 60.0)
00449         self.wlock = lock.WriteLock(lock_dir, 60.0)
00450 
00451         if not self.rlock.acquire(3.0):
00452             raise EnvironmentError("Could not lock in PickleTagStore")
00453         try:
00454             self.load()
00455         finally:
00456             self.rlock.release()


Member Function Documentation

def MoinMoin.wikisync.PickleTagStore.add (   self,
  kwargs 
)
Adds a Tag object to the current TagStore. 

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 474 of file wikisync.py.

00474 
00475     def add(self, **kwargs):
00476         if not self.wlock.acquire(3.0):
00477             raise EnvironmentError("Could not lock in PickleTagStore")
00478         try:
00479             self.load()
00480             self.tags.append(Tag(**kwargs))
00481             self.commit()
00482         finally:
00483             self.wlock.release()

Here is the call graph for this function:

Removes all tags. 

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 494 of file wikisync.py.

00494 
00495     def clear(self):
00496         self.tags = []
00497         if not self.wlock.acquire(3.0):
00498             raise EnvironmentError("Could not lock in PickleTagStore")
00499         try:
00500             self.commit()
00501         finally:
00502             self.wlock.release()

Here is the call graph for this function:

Writes the memory contents to the data file. 

Definition at line 467 of file wikisync.py.

00467 
00468     def commit(self):
00469         """ Writes the memory contents to the data file. """
00470         datafile = file(self.filename, "wb")
00471         pickle.dump(self.tags, datafile, pickle.HIGHEST_PROTOCOL)
00472         datafile.close()

Here is the caller graph for this function:

def MoinMoin.wikisync.AbstractTagStore.dump (   self) [inherited]
Returns all tags for a given item as a string. 

Definition at line 409 of file wikisync.py.

00409 
00410     def dump(self):
00411         """ Returns all tags for a given item as a string. """
00412         return repr(self.get_all_tags())

Here is the call graph for this function:

def MoinMoin.wikisync.PickleTagStore.fetch (   self,
  iwid_full,
  direction = None 
)
Fetches tags by a special IWID or interwiki name. 

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 503 of file wikisync.py.

00503 
00504     def fetch(self, iwid_full, direction=None):
00505         iwid_full = unpackLine(iwid_full)
00506         matching_tags = []
00507         for t in self.tags:
00508             t_iwid_full = unpackLine(t.remote_wiki)
00509             if ((t_iwid_full[0] == iwid_full[0]) # either match IWID or IW name
00510                 or (len(t_iwid_full) == 2 and len(iwid_full) == 2 and t_iwid_full[1] == iwid_full[1])
00511                 ) and (direction is None or t.direction == direction):
00512                 matching_tags.append(t)
00513         return matching_tags
00514 
00515 
00516 # currently we just have one implementation, so we do not need
# a factory method

Here is the call graph for this function:

Returns a list of all Tag objects associated to this page. 

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 484 of file wikisync.py.

00484 
00485     def get_all_tags(self):
00486         return self.tags[:]

Returns the newest tag. 

Reimplemented from MoinMoin.wikisync.AbstractTagStore.

Definition at line 487 of file wikisync.py.

00487 
00488     def get_last_tag(self):
00489         temp = self.tags[:]
00490         temp.sort()
00491         if not temp:
00492             return None
00493         return temp[-1]

Loads the tags from the data file. 

Definition at line 457 of file wikisync.py.

00457 
00458     def load(self):
00459         """ Loads the tags from the data file. """
00460         try:
00461             datafile = file(self.filename, "rb")
00462             self.tags = pickle.load(datafile)
00463         except (IOError, EOFError):
00464             self.tags = []
00465         else:
00466             datafile.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 445 of file wikisync.py.

Definition at line 444 of file wikisync.py.

Definition at line 447 of file wikisync.py.

Definition at line 461 of file wikisync.py.

Definition at line 448 of file wikisync.py.


The documentation for this class was generated from the following file: