Changeset 1109
- Timestamp:
- 04/10/08 07:49:00
- Files:
-
- qPloneSkinDump/branches/plone_3.0/exportingObjects.py (modified) (2 diffs)
- qPloneSkinDump/branches/plone_3.0/qPloneSkinDump.py (modified) (4 diffs)
- qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config.cpt (modified) (3 diffs)
- qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config_script.cpy (modified) (3 diffs)
- qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/validate_qploneskindump_form.vpy (modified) (3 diffs)
- qPloneSkinDump/branches/plone_3.0/utils.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneSkinDump/branches/plone_3.0/exportingObjects.py
r932 r1109 34 34 ## EXPORTING ## 35 35 ############################################################### 36 def exportObjects(context, doesExportObjects, exporting_objects, product_name): 36 def exportObjects(context, doesExportObjects, exporting_objects, 37 fs_dest_directory, product_name): 37 38 # Check whether should perform exporting 38 39 if not doesExportObjects: 39 40 return None 40 41 # Get Instance's exported and Product's imoprt pathes 41 instance_epath, product_epath = getImportedPathes( product_name)42 instance_epath, product_epath = getImportedPathes(fs_dest_directory, product_name) 42 43 # Move same named files from Instance export dir to Temp dir 43 44 temp_dir_path, product_elist = moveSameFilesToTemp(instance_epath, product_epath, exporting_objects) … … 63 64 return fail_export 64 65 65 def getImportedPathes( product_name):66 def getImportedPathes(fs_dest_directory, product_name): 66 67 # Based on instance path, construct import pathes 67 68 cfg = getConfiguration() 68 69 instance_epath = cfg.clienthome 69 product_epath = osp.join( PRODUCTS_PATH, product_name, "import")70 product_epath = osp.join(fs_dest_directory, product_name, "import") 70 71 # Check presence of Product import directory 71 72 if not osp.isdir(product_epath): qPloneSkinDump/branches/plone_3.0/qPloneSkinDump.py
r999 r1109 8 8 9 9 security = ModuleSecurityInfo( 'Products.qPloneSkinDump.qPloneSkinDump' ) 10 11 security.declarePublic('getProductsPath') 12 def getProductsPath(): 13 return PRODUCTS_PATH 10 14 11 15 security.declarePublic('getExportingData') … … 35 39 36 40 security.declarePublic('isValidProductName') 37 def isValidProductName(product_name ):41 def isValidProductName(product_name, fs_dest_directory): 38 42 """ Check for product presence in installed products list""" 39 return (product_name not in get_product_listdirs() \ 40 and isValidDirName(product_name)) 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 50 security.declarePublic('isValidDestinationDir') 51 def isValidDestinationDir(destination_dir): 52 """ Check for existance of destination directory.""" 53 return os.path.isdir(destination_dir) 41 54 42 55 DIR_NAME_PATTERN = re.compile("^[a-zA-Z]+[a-zA-Z0-9_]*[a-zA-Z0-9]$") … … 52 65 zmi_base_skin_name='', \ 53 66 subdir=None,\ 67 fs_dest_directory=PRODUCTS_PATH, \ 54 68 fs_skin_directory='custom',\ 55 69 fs_product_name='QSkinTemplate',\ … … 70 84 dump_custom_views=False): 71 85 """ Main Skin Product creating procedure.""" 72 makeNewProduct(context, fs_ product_name, fs_skin_directory, \86 makeNewProduct(context, fs_dest_directory, fs_product_name, fs_skin_directory, \ 73 87 zmi_skin_names, zmi_base_skin_name, subdir, \ 74 88 doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \ 75 89 doesExportObjects, import_policy, \ 76 90 dump_CSS, dump_JS, dump_portlets, dump_policy, dump_portlets_selection, dump_custom_views) 77 dumpSkin(context, zmi_skin_names, fs_ product_name, erase_from_skin)78 result = exportObjects(context, doesExportObjects, exporting_objects, fs_ product_name)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) 79 93 return result 80 94 qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config.cpt
r1027 r1109 42 42 <fieldset id="fieldset-product" 43 43 tal:define="error_fsSkinDir python:errors.get('FSSkinDirectory'); 44 error_fsProdName python:errors.get('FSProductName')"> 44 error_fsProdName python:errors.get('FSProductName'); 45 error_fsDestinationDir python:errors.get('FSDestinationDirectory');"> 45 46 <legend id="fieldsetlegend-product"> 46 47 <label style="font-size: 110%" i18n:translate="label_product">Product</label> … … 57 58 <div i18n:translate="help_FSProductName" 58 59 class="formHelp"> 59 Name for dumped product. This name should be unique in your Products directory of Plone's instance. The name must begin with alphabetical character, following with an alphanumeric combination, also underscore accepts, but not on boundaries.60 Name for dumped product. This name should be unique in Destination directory. The name must begin with alphabetical character, following with an alphanumeric combination, also underscore accepts, but not on boundaries. 60 61 </div> 61 62 <div tal:condition="error_fsProdName" … … 91 92 size="50" 92 93 tal:attributes="value request/FSSkinDirectory|nothing" /> 94 </div> 95 <p /> 96 <div class="FSDestinationDirectory" 97 tal:define="destinationDir python:modules['Products.qPloneSkinDump.qPloneSkinDump'].getProductsPath();" 98 tal:attributes="class python: test(error_fsDestinationDir, 'FSDestinationDirectory error', 'FSDestinationDirectory');"> 99 <label class="FSDestinationDirectory_title" 100 i18n:translate="label_FSDestinationDirectory">Destination directory</label> 101 <span class="fieldRequired" 102 title="Required" 103 i18n:translate="label_required" 104 i18n:attributes="title title_required;">(Required)</span> 105 <div i18n:translate="help_FSDestinationDirectory" 106 class="formHelp"> 107 Absolute path to directory, where SkinProduct will be created. 108 </div> 109 <div tal:condition="error_fsDestinationDir" 110 tal:content="error_fsDestinationDir" i18n:translate="">Validation Error</div> 111 112 <input class="FSDestinationDirectory_input" 113 type="text" 114 name="FSDestinationDirectory" 115 value="" 116 size="50" 117 tal:attributes="value request/FSDestinationDirectory|destinationDir" /> 93 118 </div> 94 119 </fieldset> qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config_script.cpy
r999 r1109 20 20 21 21 # File system data 22 fs_dest_directory = REQUEST.get("FSDestinationDirectory") 22 23 fs_skin_directory = REQUEST.get('FSSkinDirectory') 23 24 fs_product_name = REQUEST.get('FSProductName') … … 61 62 result = createProduct(context, zmi_skin_names=zmi_skin_names,\ 62 63 zmi_base_skin_name=zmi_base_skin_name,\ 64 fs_dest_directory=fs_dest_directory, \ 63 65 fs_skin_directory=fs_skin_directory,\ 64 66 fs_product_name=fs_product_name,\ … … 75 77 dump_JS=dump_JS, \ 76 78 dump_portlets=dump_portlets, \ 77 dump_policy=dump_policy, 78 dump_portlets_selection=dump_portlets_selection, 79 dump_custom_views=dump_custom_views )79 dump_policy=dump_policy, \ 80 dump_portlets_selection=dump_portlets_selection, \ 81 dump_custom_views=dump_custom_views ) 80 82 81 83 portal_status_message = u'"%s" Product successfully created.' % fs_product_name qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/validate_qploneskindump_form.vpy
r834 r1109 11 11 12 12 from Products.CMFCore.utils import getToolByName 13 from Products.qPloneSkinDump.qPloneSkinDump import isValidProductName, isValidDirName 13 from Products.qPloneSkinDump.qPloneSkinDump import isValidProductName 14 from Products.qPloneSkinDump.qPloneSkinDump import isValidDirName 15 from Products.qPloneSkinDump.qPloneSkinDump import isValidDestinationDir 14 16 errors = state.getErrors() 15 17 … … 22 24 23 25 # Check REQUIRED fields 24 REQUIRED_FIELDS = ['ZMISkinName', 'ZMIBaseSkinName', 'FSProductName', 'FSSkinDirectory' ]26 REQUIRED_FIELDS = ['ZMISkinName', 'ZMIBaseSkinName', 'FSProductName', 'FSSkinDirectory', 'FSDestinationDirectory'] 25 27 theform = {} 26 28 for f in REQUIRED_FIELDS: … … 30 32 theform[f]=fdata 31 33 32 if not( theform['FSProductName'] and isValidProductName(theform['FSProductName']) ): 33 update_errors(errors, {'FSProductName': u"Not valid Product name - read help attentively."}) 34 if not( theform["FSDestinationDirectory"] and isValidDestinationDir(theform["FSDestinationDirectory"]) ): 35 update_errors(errors, {"FSDestinationDirectory": u"Not valid Destination directory"}) 36 37 if not( theform['FSProductName'] and theform["FSDestinationDirectory"] \ 38 and isValidProductName(theform['FSProductName'], theform["FSDestinationDirectory"]) ): 39 update_errors(errors, {'FSProductName': u"Not valid Product name or problem with destination directory - read help attentively."}) 34 40 35 41 if not( theform['FSSkinDirectory'] and isValidDirName(theform['FSSkinDirectory']) ): qPloneSkinDump/branches/plone_3.0/utils.py
r1106 r1109 224 224 return "\n".join([' <layer name="%s"/>' % l for l in layers]) 225 225 226 def getFSSkinPath(folder, fs_ product_name):226 def getFSSkinPath(folder, fs_dest_directory, fs_product_name): 227 227 """ Return file system skin path for subdir.""" 228 228 229 229 folder_path = '/'.join(folder.getPhysicalPath()[list(folder.getPhysicalPath()).index('portal_skins')+1:]) 230 skinpath = "%s/%s/skins/%s" % ( PRODUCTS_PATH, fs_product_name, folder_path)230 skinpath = "%s/%s/skins/%s" % (fs_dest_directory, fs_product_name, folder_path) 231 231 232 232 # If in skin's subfolder - get its path … … 237 237 return skinpath 238 238 239 def dumpFolder(folder, fs_ product_name):240 skinpath = getFSSkinPath(folder, fs_ product_name)239 def dumpFolder(folder, fs_dest_directory, fs_product_name): 240 skinpath = getFSSkinPath(folder, fs_dest_directory, fs_product_name) 241 241 # Create directory in FS if not yet exist 242 242 if not os.path.exists(skinpath): … … 256 256 writeProps(o, skinpath, extension = '.props') 257 257 else: 258 dumpFolder(o, fs_product_name )258 dumpFolder(o, fs_product_name, fs_product_name) 259 259 elif meta_type in _write_custom_meta_type_list: 260 260 #writeProps( o, skinpath ) # write object's properties … … 267 267 writeObjectsMeta(obj_meta, skinpath) 268 268 269 def dumpSkin(context, skin_names=['custom',], fs_product_name='QSkinTemplate', erase_from_skin=0): 269 def dumpSkin(context, skin_names=['custom',], fs_dest_directory=PRODUCTS_PATH, 270 fs_product_name='QSkinTemplate', erase_from_skin=0): 270 271 """Dump custom information to file.""" 271 272 if type(skin_names) not in (type([]), type(())): … … 273 274 for skin_name in list(skin_names): 274 275 folder = getToolByName(context, 'portal_skins')[skin_name] 275 dumpFolder(folder, fs_ product_name)276 dumpFolder(folder, fs_dest_directory, fs_product_name) 276 277 # delete objects from the skin, if request 277 278 if erase_from_skin: … … 360 361 return xml 361 362 362 def makeNewProduct(context, productName, productSkinName, \363 def makeNewProduct(context, destinationDir, productName, productSkinName, \ 363 364 zmi_skin_names, zmi_base_skin_name, subdir,\ 364 365 doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \ … … 367 368 """Create new skin-product's directory and 368 369 copy skin-product template with little modification""" 369 products_path = PRODUCTS_PATH370 products_path = destinationDir 370 371 productPath = ospJoin(products_path, productName) 371 372 if not (productName in os.listdir(products_path)): … … 430 431 431 432 # Copy skin_template to SKIN_PRODUCT directory 432 templatePath = ospJoin( products_path, PROJECTNAME, TEMPLATE_PATH)433 templatePath = ospJoin(PRODUCTS_PATH, PROJECTNAME, TEMPLATE_PATH) 433 434 copyDir(templatePath, productPath, productName) 434 435 # Form data dictionary and form Skin Product's files
