Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFFormController.exportimport.formcontroller Namespace Reference

Classes

class  CMFFormControllerExportConfigurator
class  CMFFormControllerImportConfigurator

Functions

def importCMFFormController
def exportCMFFormController

Variables

tuple _pkgdir = package_home( globals() )
tuple _xmldir = os.path.join( _pkgdir, 'xml' )
string _FILENAME = 'cmfformcontroller.xml'

Function Documentation

Export CMFFormController settings as an XML file.

Definition at line 75 of file formcontroller.py.

00075 
00076 def exportCMFFormController(context):
00077     """ Export CMFFormController settings as an XML file.
00078     """
00079     site = context.getSite()
00080 
00081     fc = getToolByName(site, 'portal_form_controller', None)
00082     if fc is None:
00083         return 'CMFFormController: Nothing to export.'
00084 
00085     fcc = CMFFormControllerExportConfigurator( site ).__of__( site )
00086     text = fcc.generateXML()
00087 
00088     context.writeDataFile( _FILENAME, text, 'text/xml' )
00089 
00090     return 'CMFFormController settings exported.'
00091 

Here is the call graph for this function:

Here is the caller graph for this function:

Import CMFFormController settings from an XML file.

Definition at line 41 of file formcontroller.py.

00041 
00042 def importCMFFormController(context):
00043     """ Import CMFFormController settings from an XML file.
00044     """
00045     site = context.getSite()
00046     fc = getToolByName(site, 'portal_form_controller', None)
00047     if fc is None:
00048         return 'CMFFormController: No tool!'
00049 
00050     body = context.readDataFile(_FILENAME)
00051     if body is None:
00052         return 'CMFFormController: Nothing to import.'
00053 
00054     if context.shouldPurge():
00055         fc.__init__()
00056 
00057     # now act on the settings we've retrieved
00058     configurator = CMFFormControllerImportConfigurator(site)
00059     fc_info = configurator.parseXML(body)
00060 
00061     for validator in fc_info['validators']:
00062         fc.validators.set(FormValidator(validator['object_id'],
00063                                         validator.get('context_type', ''),
00064                                         validator.get('button', ''),
00065                                         str(validator['validators']).split(',')))
00066     for action in fc_info['actions']:
00067         fc.actions.set(FormAction(action['object_id'],
00068                                   action['status'],
00069                                   action.get('context_type', ''),
00070                                   action.get('button', ''),
00071                                   action['action_type'],
00072                                   str(action['action_arg'])))
00073 
00074     return 'CMFFormController settings imported.'

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 39 of file formcontroller.py.

tuple CMFFormController.exportimport.formcontroller._pkgdir = package_home( globals() )

Definition at line 30 of file formcontroller.py.

Definition at line 31 of file formcontroller.py.