Attachment 'PageBundle.py'

Download

   1 #!python
   2 class PageBundle(StorageBase):
   3     
   4     # Managing the text
   5     def text(self):
   6         return self.readText(join(self.path(), '__text__'))
   7     
   8     def setText(self, text):
   9         """ Save a new version, backup the old one """    
  10         # lock the page for other processes, blocking until the lock aquired
  11         self.lock()
  12         old = join(self.path(), '__text__')
  13         backup = join(self.path(), '__versions__', self.versionNumber() + 1) 
  14         os.rename(old, backup)
  15         self.writeText(join(self.path(), '__text__', text))
  16         self.unlock()
  17         
  18     # Managing information about pages
  19     # Meta data from __info__ could be cached in self._info
  20     # lets say, in a PageInfo object
  21     def rename(self, name):
  22         """ Rename while keeping all attachments and sub pages intact"""
  23         self.lock()
  24         old = join(self._root, self._name)
  25         new = join(self._root, name)
  26         os.rename(old, new) 
  27         self._name = name
  28         self.unlock()
  29     
  30     def versionNumber(self):
  31         """ Get the version from the __info__ file """
  32         return self._info.versionNumber()
  33         
  34     def versions(self):
  35         """ Return a list of meta data for all versions """
  36         return self._info.versions()
  37         
  38     def textAsOfVersion(self, number):
  39         """ Return the text form a backup version """
  40         return self.readText(join(self.path(), '__versions__', number))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2004-06-20 10:04:04, 1.4 KB) [[attachment:PageBundle.py]]
  • [get | view] (2004-08-28 04:02:43, 8.7 KB) [[attachment:_contents-hidden.png]]
  • [get | view] (2004-08-28 04:02:31, 10.2 KB) [[attachment:_contents.png]]
  • [get | view] (2004-11-07 22:24:16, 1.1 KB) [[attachment:meta.py]]
  • [get | view] (2004-05-18 02:50:11, 31.2 KB) [[attachment:page-with-subpage.jpg]]
  • [get | view] (2004-05-18 02:49:46, 27.5 KB) [[attachment:simple-page.jpg]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.