source: products/qPloneSkinDump/trunk/qPloneSkinDump.py @ 3220

Last change on this file since 3220 was 74, checked in by chervol, 19 years ago

initial plone2.0.5 branch import

File size: 4.0 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('getProductsPath')
12def getProductsPath():
13    return PRODUCTS_PATH
14
15security.declarePublic('getExportingData')
16def getExportingData(context):
17    result_list = { 'default_import_policy':DEFAULT_IMPORTING_POLICY
18                   ,'import_policy_list':{}
19                   ,'export_object_id_list':[] }
20    # Form allowed id list for exporting
21    portal_ids = getToolByName(context, 'portal_url').getPortalObject().objectIds()
22    result_list['export_object_id_list'] = [id for id in portal_ids \
23                                            if id not in FORBIDDEN_EXP_NAMES \
24                                            and not FORBIDDEN_EXP_PREFIXES.match(id)]
25    # Form importing_policy_list dictionary with readable names
26    result_list['import_policy_list'] = ipols = {}
27    [ipols.update({ip:ip.replace("_"," ").capitalize()}) for ip in IMPORTING_POLICY_LIST]
28    return result_list
29
30security.declarePublic('getSlotsFormingList')
31def getSlotsFormingList():
32    return {'default':DEFAULT_SLOT_FORMING \
33           ,'data':[[s, s.replace("_"," ").capitalize()] for s in SLOT_FORMING_LIST]}
34
35security.declarePublic('getMainColumnList')
36def getMainColumnList():
37    return {'default':DEFAULT_MAIN_COLUMN \
38           ,'data':[[s, s.capitalize()] for s in MAIN_COLUMN_LIST]}
39
40security.declarePublic('isValidProductName')
41def isValidProductName(product_name, fs_dest_directory):
42    """ Check for product presence in installed products list"""
43    if not fs_dest_directory==PRODUCTS_PATH:
44       return (not product_name in os.listdir(fs_dest_directory)) \
45              and isValidDirName(product_name)
46
47    return (not product_name in get_product_listdirs()) \
48           and isValidDirName(product_name)
49
50security.declarePublic('isValidDestinationDir')
51def isValidDestinationDir(destination_dir):
52    """ Check for existance of destination directory."""
53    return os.path.isdir(destination_dir)
54
55DIR_NAME_PATTERN = re.compile("^[a-zA-Z]+[a-zA-Z0-9_]*[a-zA-Z0-9]$")
56security.declarePublic('isValidDirName')
57def isValidDirName(dir_name):
58    """ Check for validity directory name"""
59    m = DIR_NAME_PATTERN.match(dir_name)
60    return m and dir_name == m.group()
61
62security.declarePublic('createProduct')
63def createProduct(context, \
64                  zmi_skin_names=['custom',], \
65                  zmi_base_skin_name='', \
66                  subdir=None,\
67                  fs_dest_directory=PRODUCTS_PATH, \
68                  fs_skin_directory='custom',\
69                  fs_product_name='QSkinTemplate',\
70                  erase_from_skin=0,\
71                  doesCustomizeSlots=None,\
72                  left_slots=[],\
73                  right_slots=[],\
74                  slot_forming=DEFAULT_SLOT_FORMING,\
75                  main_column=DEFAULT_MAIN_COLUMN,\
76                  doesExportObjects=None,\
77                  import_policy=DEFAULT_IMPORTING_POLICY,\
78                  exporting_objects=[], \
79                  dump_CSS=True, \
80                  dump_JS=True, \
81                  dump_portlets=0, \
82                  dump_policy='root', \
83                  dump_portlets_selection=[], \
84                  dump_custom_views=False):
85    """ Main Skin Product creating procedure."""
86    makeNewProduct(context, fs_dest_directory, fs_product_name, fs_skin_directory, \
87                   zmi_skin_names, zmi_base_skin_name, subdir, \
88                   doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \
89                   doesExportObjects, import_policy, \
90                   dump_CSS, dump_JS, dump_portlets, dump_policy, dump_portlets_selection, dump_custom_views)
91    dumpSkin(context, zmi_skin_names, fs_dest_directory, fs_product_name, erase_from_skin)
92    result = exportObjects(context, doesExportObjects, exporting_objects, fs_dest_directory, fs_product_name)
93    return result
94
95security.apply(globals())
Note: See TracBrowser for help on using the repository browser.