[1] | 1 | import os, re |
---|
| 2 | from AccessControl import ModuleSecurityInfo |
---|
| 3 | from Products.CMFCore.utils import getToolByName |
---|
| 4 | |
---|
| 5 | from config import * |
---|
| 6 | from utils import * |
---|
| 7 | from exportingObjects import exportObjects |
---|
| 8 | |
---|
| 9 | security = ModuleSecurityInfo( 'Products.qPloneSkinDump.qPloneSkinDump' ) |
---|
| 10 | |
---|
| 11 | security.declarePublic('getExportingData') |
---|
| 12 | def 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 | |
---|
| 26 | security.declarePublic('getSlotsFormingList') |
---|
| 27 | def getSlotsFormingList(): |
---|
| 28 | return {'default':DEFAULT_SLOT_FORMING \ |
---|
| 29 | ,'data':[[s, s.replace("_"," ").capitalize()] for s in SLOT_FORMING_LIST]} |
---|
| 30 | |
---|
| 31 | security.declarePublic('getMainColumnList') |
---|
| 32 | def getMainColumnList(): |
---|
| 33 | return {'default':DEFAULT_MAIN_COLUMN \ |
---|
| 34 | ,'data':[[s, s.capitalize()] for s in MAIN_COLUMN_LIST]} |
---|
| 35 | |
---|
| 36 | security.declarePublic('isValidProductName') |
---|
| 37 | def isValidProductName(product_name): |
---|
| 38 | """ Check for product presence in installed products list""" |
---|
| 39 | return (product_name not in os.listdir(getProductsFSPath()) \ |
---|
| 40 | and isValidDirName(product_name)) |
---|
| 41 | |
---|
| 42 | DIR_NAME_PATTERN = re.compile("^[a-zA-Z]+[a-zA-Z0-9_]*[a-zA-Z0-9]$") |
---|
| 43 | security.declarePublic('isValidDirName') |
---|
| 44 | def 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 | |
---|
| 49 | security.declarePublic('createProduct') |
---|
| 50 | def 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 | |
---|
| 78 | security.apply(globals()) |
---|