source: products/qPloneSkinDump/branches/multipleslots/qPloneSkinDump.py @ 1591

Last change on this file since 1591 was 1, checked in by myroslav, 15 years ago

Building directory structure

File size: 3.3 KB
Line 
1import os, re
2from AccessControl import ModuleSecurityInfo
3from Products.CMFCore.utils import getToolByName
4
5from config import *
6from utils import *
7from exportingObjects import exportObjects
8
9security = ModuleSecurityInfo( 'Products.qPloneSkinDump.qPloneSkinDump' )
10
11security.declarePublic('getExportingData')
12def getExportingData(context):
13    result_list = { 'default_import_policy':DEFAULT_IMPORTING_POLICY
14                   ,'import_policy_list':{}
15                   ,'export_object_id_list':[] }
16    # Form allowed id list for exporting
17    portal_ids = getToolByName(context, 'portal_url').getPortalObject().objectIds()
18    result_list['export_object_id_list'] = [id for id in portal_ids \
19                                            if id not in FORBIDDEN_EXP_NAMES \
20                                            and not FORBIDDEN_EXP_PREFIXES.match(id)]
21    # Form importing_policy_list dictionary with readable names
22    result_list['import_policy_list'] = ipols = {}
23    [ipols.update({ip:ip.replace("_"," ").capitalize()}) for ip in IMPORTING_POLICY_LIST]
24    return result_list
25
26security.declarePublic('getSlotsFormingList')
27def getSlotsFormingList():
28    return {'default':DEFAULT_SLOT_FORMING \
29           ,'data':[[s, s.replace("_"," ").capitalize()] for s in SLOT_FORMING_LIST]}
30
31security.declarePublic('getMainColumnList')
32def getMainColumnList():
33    return {'default':DEFAULT_MAIN_COLUMN \
34           ,'data':[[s, s.capitalize()] for s in MAIN_COLUMN_LIST]}
35
36security.declarePublic('isValidProductName')
37def isValidProductName(product_name):
38    """ Check for product presence in installed products list"""
39    return (product_name not in get_product_listdirs() \
40            and isValidDirName(product_name))
41
42DIR_NAME_PATTERN = re.compile("^[a-zA-Z]+[a-zA-Z0-9_]*[a-zA-Z0-9]$")
43security.declarePublic('isValidDirName')
44def isValidDirName(dir_name):
45    """ Check for validity directory name"""
46    m = DIR_NAME_PATTERN.match(dir_name)
47    return m and dir_name == m.group()
48
49security.declarePublic('createProduct')
50def createProduct(context, \
51                  zmi_skin_name='custom', \
52                  zmi_base_skin_name='', \
53                  subdir=None,\
54                  fs_skin_directory='custom',\
55                  fs_product_name='QSkinTemplate',\
56                  erase_from_skin=0,\
57                  doesCustomizeSlots=None,\
58                  left_slots=[],\
59                  right_slots=[],\
60                  slot_forming=DEFAULT_SLOT_FORMING,\
61                  main_column=DEFAULT_MAIN_COLUMN,\
62                  doesExportObjects=None,\
63                  import_policy=DEFAULT_IMPORTING_POLICY,\
64                  exporting_objects=[], \
65                  dump_CSS=True, \
66                  dump_JS=True ):
67    """ Main Skin Product creating procedure."""
68    makeNewProduct(context, fs_product_name, fs_skin_directory, \
69                   zmi_skin_name, zmi_base_skin_name, subdir, \
70                   doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \
71                   doesExportObjects, import_policy, \
72                   dump_CSS, dump_JS )
73    dumpSkin(context, zmi_skin_name, subdir, fs_skin_directory.lower(),
74             fs_product_name, erase_from_skin)
75    result = exportObjects(context, doesExportObjects, exporting_objects, fs_product_name)
76    return result
77
78security.apply(globals())
Note: See TracBrowser for help on using the repository browser.