Table of Contents

Class: EditableFile ./src/peak/storage/files.py

File whose text can be manipulated, transactionally

Example:

        myfile = EditableFile(self, filename="something")
        print myfile.text   # prints current contents of file

        # Edit the file
        storage.beginTransaction(self)
        myfile.text = myfile.text.replace('foo','bar')
        storage.commitTransaction(self)

Values assigned to text will be converted to strings. Setting text to an empty string truncates the file; deleting text (i.e. del myfile.text) deletes the file. text will be None whenever the file is nonexistent, but do not set it to None unless you want to replace the file's contents with the string "None"!

By default, files are read and written in "text" mode; be sure to supply a fileType="b" keyword argument if you are editing a binary file. Note that under Python 2.3 you can also specify fileType="U" to use "universal newline" mode.

EditableFile subclasses TxnFile, but does not use autocommit mode, because it wants to support "safe" alterations to existing files.

Base Classes   
TxnFile
    TransactionComponent
    FileFactory
Methods   
__close
__setText
__text
abortTransaction
delete
finishTransaction
voteForCommit
  __close 
__close ( self,  write=True )

  __setText 
__setText ( self,  text )

  __text 
__text ( self )

  abortTransaction 
abortTransaction ( self,  txnService )

  delete 
delete ( self,  autocommit=False )

  finishTransaction 
finishTransaction (
        self,
        txnService,
        committed,
        )

  voteForCommit 
voteForCommit ( self,  txnService )


Table of Contents

This document was automatically generated on Mon Mar 25 01:11:05 2024 by HappyDoc version 2.1