Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
GenericSetup.context.SnapshotExportContext Class Reference
Inheritance diagram for GenericSetup.context.SnapshotExportContext:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.context.SnapshotExportContext:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def writeDataFile
def getSnapshotURL
def getSnapshotFolder
def getSite
def getSetupTool
def getEncoding
def getLogger
def listNotes
def clearNotes
def shouldPurge

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _createObjectByType
def _ensureSnapshotsFolder

Private Attributes

 _snapshot_id

Detailed Description

Definition at line 445 of file context.py.


Constructor & Destructor Documentation

def GenericSetup.context.SnapshotExportContext.__init__ (   self,
  tool,
  snapshot_id,
  encoding = None 
)

Definition at line 451 of file context.py.

00451 
00452     def __init__( self, tool, snapshot_id, encoding=None ):
00453 
00454         BaseContext.__init__( self, tool, encoding )
00455         self._snapshot_id = snapshot_id


Member Function Documentation

def GenericSetup.context.SnapshotExportContext._createObjectByType (   self,
  name,
  body,
  content_type 
) [private]

Definition at line 492 of file context.py.

00492 
00493     def _createObjectByType( self, name, body, content_type ):
00494 
00495         if isinstance( body, unicode ):
00496             encoding = self.getEncoding()
00497             if encoding is None:
00498                 body = body.encode()
00499             else:
00500                 body = body.encode( encoding )
00501 
00502         if name.endswith('.py'):
00503 
00504             ob = PythonScript( name )
00505             ob.write( body )
00506 
00507         elif name.endswith('.dtml'):
00508 
00509             ob = DTMLDocument( '', __name__=name )
00510             ob.munge( body )
00511 
00512         elif content_type in ('text/html', 'text/xml' ):
00513 
00514             ob = ZopePageTemplate( name, body
00515                                  , content_type=content_type )
00516 
00517         elif content_type[:6]=='image/':
00518 
00519             ob=Image( name, '', body, content_type=content_type )
00520 
00521         else:
00522             ob=File( name, '', body, content_type=content_type )
00523 
00524         return ob

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.context.SnapshotExportContext._ensureSnapshotsFolder (   self,
  subdir = None 
) [private]
Ensure that the appropriate snapshot folder exists.

Definition at line 526 of file context.py.

00526 
00527     def _ensureSnapshotsFolder( self, subdir=None ):
00528 
00529         """ Ensure that the appropriate snapshot folder exists.
00530         """
00531         path = [ 'snapshots', self._snapshot_id ]
00532 
00533         if subdir is not None:
00534             path.extend( subdir.split( '/' ) )
00535 
00536         current = self._tool
00537 
00538         for element in path:
00539 
00540             if element not in current.objectIds():
00541                 # No Unicode IDs!
00542                 current._setObject( str( element ), Folder( element ) )
00543 
00544             current = current._getOb( element )
00545 
00546         return current
00547 
00548 InitializeClass( SnapshotExportContext )
00549 

Here is the caller graph for this function:

def GenericSetup.context.BaseContext.clearNotes (   self) [inherited]
See ISetupContext.

Definition at line 172 of file context.py.

00172 
00173     def clearNotes(self):
00174 
00175         """ See ISetupContext.
00176         """
00177         self._messages[:] = []
00178 

See ISetupContext.

Definition at line 152 of file context.py.

00152 
00153     def getEncoding( self ):
00154 
00155         """ See ISetupContext.
00156         """
00157         return self._encoding

Here is the caller graph for this function:

def GenericSetup.context.BaseContext.getLogger (   self,
  name 
) [inherited]
See ISetupContext.

Reimplemented from GenericSetup.context.SetupEnviron.

Definition at line 159 of file context.py.

00159 
00160     def getLogger( self, name ):
00161         """ See ISetupContext.
00162         """
00163         return self._loggers.setdefault(name, Logger(name, self._messages))

See ISetupContext.

Definition at line 145 of file context.py.

00145 
00146     def getSetupTool( self ):
00147 
00148         """ See ISetupContext.
00149         """
00150         return self._tool

def GenericSetup.context.BaseContext.getSite (   self) [inherited]
See ISetupContext.

Definition at line 138 of file context.py.

00138 
00139     def getSite( self ):
00140 
00141         """ See ISetupContext.
00142         """
00143         return aq_self(self._site)

See IExportContext.

Definition at line 482 of file context.py.

00482 
00483     def getSnapshotFolder( self ):
00484 
00485         """ See IExportContext.
00486         """
00487         return self._ensureSnapshotsFolder()

Here is the call graph for this function:

See IExportContext.

Definition at line 475 of file context.py.

00475 
00476     def getSnapshotURL( self ):
00477 
00478         """ See IExportContext.
00479         """
00480         return '%s/%s' % ( self._tool.absolute_url(), self._snapshot_id )

def GenericSetup.context.BaseContext.listNotes (   self) [inherited]
See ISetupContext.

Definition at line 165 of file context.py.

00165 
00166     def listNotes(self):
00167 
00168         """ See ISetupContext.
00169         """
00170         return self._messages[:]

When installing, should the existing setup be purged?

Reimplemented in GenericSetup.context.SnapshotImportContext, and GenericSetup.context.TarballImportContext.

Definition at line 118 of file context.py.

00118 
00119     def shouldPurge(self):
00120         """When installing, should the existing setup be purged?
00121         """
00122         return self._should_purge
00123 

def GenericSetup.context.SnapshotExportContext.writeDataFile (   self,
  filename,
  text,
  content_type,
  subdir = None 
)
See IExportContext.

Definition at line 457 of file context.py.

00457 
00458     def writeDataFile( self, filename, text, content_type, subdir=None ):
00459 
00460         """ See IExportContext.
00461         """
00462         if subdir is not None:
00463             filename = '/'.join( ( subdir, filename ) )
00464 
00465         sep = filename.rfind('/')
00466         if sep != -1:
00467             subdir = filename[:sep]
00468             filename = filename[sep+1:]
00469         folder = self._ensureSnapshotsFolder( subdir )
00470 
00471         # TODO: switch on content_type
00472         ob = self._createObjectByType( filename, text, content_type )
00473         folder._setObject( str( filename ), ob ) # No Unicode IDs!

Here is the call graph for this function:


Member Data Documentation

Definition at line 454 of file context.py.

tuple GenericSetup.context.SnapshotExportContext.security = ClassSecurityInfo() [static]

Reimplemented from GenericSetup.context.BaseContext.

Definition at line 449 of file context.py.


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