Back to index

plone3  3.1.7
Classes | Functions | Variables
kupu.plone.exportimport Namespace Reference

Classes

class  KupuToolExportConfigurator
class  KupuToolImportConfigurator

Functions

def importKupuSettings
def exportKupuSettings

Variables

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

Function Documentation

Export kupu settings as an XML file.

Definition at line 132 of file exportimport.py.

00132 
00133 def exportKupuSettings(context):
00134     """ Export kupu settings as an XML file.
00135     """
00136     site = context.getSite()
00137 
00138     mhc = KupuToolExportConfigurator( site ).__of__( site )
00139     if mhc.getTool() is None:
00140         return 'Kupu not installed: no settings to export'
00141 
00142     text = mhc.generateXML()
00143 
00144     context.writeDataFile( _FILENAME, text, 'text/xml' )
00145 
00146     return 'Kupu settings exported.'
00147 

Import kupu settings from an XML file.

Definition at line 46 of file exportimport.py.

00046 
00047 def importKupuSettings(context):
00048     """ Import kupu settings from an XML file.
00049     """
00050     site = context.getSite()
00051     kupu = getToolByName(site, 'kupu_library_tool', None)
00052     if kupu is None:
00053         return 'Kupu: No tool!'
00054 
00055     body = context.readDataFile(_FILENAME)
00056     if body is None:
00057         return 'Kupu: Nothing to import.'
00058 
00059     # now act on the settings we've retrieved
00060     configurator = KupuToolImportConfigurator(site, 'utf-8')
00061     info = configurator.parseXML(body)
00062 
00063     config = info['config'][0]
00064     parastyles = config['parastyles']
00065     tableclasses = config['tableclasses']
00066     stylewhitelist = config['filterstyles']
00067     classblacklist = config['filterclasses']
00068     excludedhtml = [ (f['tags'].split(' '), f['attributes'].split(' ')) for f in config['filters']]
00069     
00070     captioning = config['captioning']
00071     userefbrowser = config['userefbrowser']
00072     linkbyuid = config['linkbyuid']
00073     filtersourceedit = config['filtersourceedit']
00074     installbeforeunload = config['installbeforeunload']
00075 
00076     kupu.configure_kupu(
00077         table_classnames = tableclasses,
00078         parastyles=parastyles,
00079         style_whitelist = stylewhitelist,
00080         class_blacklist = classblacklist,
00081         installBeforeUnload=installbeforeunload,
00082         linkbyuid=linkbyuid,
00083         captioning=captioning,
00084         )
00085     kupu.set_html_exclusions(excludedhtml)
00086 
00087     # Set up resources
00088     # XXX whitelist/blacklist handling
00089     resources = info['resources']
00090     types = kupu.zmi_get_resourcetypes()
00091     kupu.deleteResourceTypes([ t.name for t in types])
00092     for k in resources:
00093         kupu.addResourceType(k['id'], k['types'], k['mode'])
00094     kupu.setDefaultResource(info['defaultresource'][0])
00095 
00096     if info.has_key('generatepreviews'):
00097         # This code generates preview URLs automatically from the most
00098         # appropriately sized image (if you have PIL installed) or just an
00099         # image field (if you don't).
00100         #
00101         # If you have content types which don't always have an image, or if
00102         # this picks the wrong preview URL, you might want to change these
00103         # expressions.
00104         PREVIEW_EXPR = 'string:${object_url}/%s'
00105         PREVIEW = [ { 'portal_type': type,
00106             'expression': PREVIEW_EXPR % image,
00107             'normal': None,
00108             'scalefield': image.split('_',1)[0],
00109             } for (type, image) in kupu.getPreviewable() ]
00110         kupu.updatePreviewActions(PREVIEW)
00111     else:
00112         PREVIEW = []
00113 
00114     preview = PREVIEW + list(info['previews'])
00115     kupu.updatePreviewActions(preview)
00116 
00117     # Set up libraries
00118     libraries = info['libraries']
00119     deflib = info['defaultlibrary'][0]
00120     libs = kupu.zmi_get_libraries()
00121     kupu.deleteLibraries(range(len(libs)))
00122     for lib in libraries:
00123         kupu.addLibrary(**lib)
00124     kupu.zmi_set_default_library(deflib)
00125 
00126     
00127     toolbar = info['toolbar'][0]['elements']
00128     globaltoolbar = info['globaltoolbar'][0]
00129     kupu.set_toolbar_filters(toolbar, globaltoolbar)
00130     
00131     return 'Kupu settings imported.'

Here is the call graph for this function:


Variable Documentation

string kupu.plone.exportimport._FILENAME = 'kupu.xml'

Definition at line 44 of file exportimport.py.

tuple kupu.plone.exportimport._pkgdir = package_home( globals() )

Definition at line 38 of file exportimport.py.

tuple kupu.plone.exportimport._xmldir = os.path.join( _pkgdir, 'xml' )

Definition at line 39 of file exportimport.py.