Back to index

plone3  3.1.7
Classes | Functions
plone.app.viewletmanager.exportimport.storage Namespace Reference

Classes

class  ViewletSettingsStorageNodeAdapter

Functions

def importViewletSettingsStorage
def exportViewletSettingsStorage

Function Documentation

Export viewlet settings.

Definition at line 36 of file storage.py.

00036 
00037 def exportViewletSettingsStorage(context):
00038     """Export viewlet settings."""
00039     logger = context.getLogger('plone.app.viewletmanager')
00040 
00041     storage = queryUtility(IViewletSettingsStorage)
00042 
00043     if storage is None:
00044         logger.info("Nothing to export")
00045         return
00046 
00047     exporter = queryMultiAdapter((storage, context), IBody)
00048     if exporter is None:
00049         logger.warning("Export adapter missing.")
00050         return
00051 
00052     context.writeDataFile('viewlets.xml', exporter.body, exporter.mime_type)
00053     logger.info("Exported.")
00054 

Here is the caller graph for this function:

Import viewlet settings.

Definition at line 10 of file storage.py.

00010 
00011 def importViewletSettingsStorage(context):
00012     """Import viewlet settings."""
00013     logger = context.getLogger('plone.app.viewletmanager')
00014 
00015     body = context.readDataFile('viewlets.xml')
00016     if body is None:
00017         logger.info("Nothing to import")
00018         return
00019 
00020     storage = getUtility(IViewletSettingsStorage)
00021 
00022     importer = queryMultiAdapter((storage, context), IBody)
00023     if importer is None:
00024         logger.warning("Import adapter missing.")
00025         return
00026         
00027     # set filename on importer so that syntax errors can be reported properly
00028     try:
00029         subdir = context._profile_path
00030     except AttributeError:
00031         subdir = ''
00032     importer.filename = os.path.join( subdir, 'viewlets.xml' )
00033 
00034     importer.body = body
00035     logger.info("Imported.")

Here is the caller graph for this function: