Changeset 1109

Show
Ignore:
Timestamp:
04/10/08 07:49:00
Author:
mylan
Message:

#91:Implement possibility to choose destination directory

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneSkinDump/branches/plone_3.0/exportingObjects.py

    r932 r1109  
    3434##                         EXPORTING                         ## 
    3535############################################################### 
    36 def exportObjects(context, doesExportObjects, exporting_objects, product_name): 
     36def exportObjects(context, doesExportObjects, exporting_objects, 
     37                  fs_dest_directory, product_name): 
    3738    # Check whether should perform exporting 
    3839    if not doesExportObjects: 
    3940        return None 
    4041    # 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) 
    4243    # Move same named files from Instance export dir to Temp dir 
    4344    temp_dir_path, product_elist = moveSameFilesToTemp(instance_epath, product_epath, exporting_objects) 
     
    6364    return fail_export 
    6465 
    65 def getImportedPathes(product_name): 
     66def getImportedPathes(fs_dest_directory, product_name): 
    6667    # Based on instance path, construct import pathes  
    6768    cfg = getConfiguration() 
    6869    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") 
    7071    # Check presence of Product import directory 
    7172    if not osp.isdir(product_epath):         
  • qPloneSkinDump/branches/plone_3.0/qPloneSkinDump.py

    r999 r1109  
    88 
    99security = ModuleSecurityInfo( 'Products.qPloneSkinDump.qPloneSkinDump' ) 
     10 
     11security.declarePublic('getProductsPath') 
     12def getProductsPath(): 
     13    return PRODUCTS_PATH 
    1014 
    1115security.declarePublic('getExportingData') 
     
    3539 
    3640security.declarePublic('isValidProductName') 
    37 def isValidProductName(product_name): 
     41def isValidProductName(product_name, fs_dest_directory): 
    3842    """ 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 
     50security.declarePublic('isValidDestinationDir') 
     51def isValidDestinationDir(destination_dir): 
     52    """ Check for existance of destination directory.""" 
     53    return os.path.isdir(destination_dir) 
    4154 
    4255DIR_NAME_PATTERN = re.compile("^[a-zA-Z]+[a-zA-Z0-9_]*[a-zA-Z0-9]$") 
     
    5265                  zmi_base_skin_name='', \ 
    5366                  subdir=None,\ 
     67                  fs_dest_directory=PRODUCTS_PATH, \ 
    5468                  fs_skin_directory='custom',\ 
    5569                  fs_product_name='QSkinTemplate',\ 
     
    7084                  dump_custom_views=False): 
    7185    """ 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, \ 
    7387                   zmi_skin_names, zmi_base_skin_name, subdir, \ 
    7488                   doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \ 
    7589                   doesExportObjects, import_policy, \ 
    7690                   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) 
    7993    return result 
    8094 
  • qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config.cpt

    r1027 r1109  
    4242            <fieldset id="fieldset-product" 
    4343                      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');"> 
    4546                <legend id="fieldsetlegend-product"> 
    4647                  <label style="font-size: 110%" i18n:translate="label_product">Product</label> 
     
    5758                    <div i18n:translate="help_FSProductName" 
    5859                         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. 
    6061                    </div> 
    6162                    <div tal:condition="error_fsProdName" 
     
    9192                           size="50" 
    9293                           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" /> 
    93118                </div> 
    94119            </fieldset> 
  • qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/qploneskindump_config_script.cpy

    r999 r1109  
    2020 
    2121# File system data 
     22fs_dest_directory = REQUEST.get("FSDestinationDirectory") 
    2223fs_skin_directory = REQUEST.get('FSSkinDirectory') 
    2324fs_product_name = REQUEST.get('FSProductName') 
     
    6162result = createProduct(context, zmi_skin_names=zmi_skin_names,\ 
    6263              zmi_base_skin_name=zmi_base_skin_name,\ 
     64              fs_dest_directory=fs_dest_directory, \ 
    6365              fs_skin_directory=fs_skin_directory,\ 
    6466              fs_product_name=fs_product_name,\ 
     
    7577              dump_JS=dump_JS, \ 
    7678              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
    8082 
    8183portal_status_message = u'"%s" Product successfully created.' % fs_product_name 
  • qPloneSkinDump/branches/plone_3.0/skins/qploneskindump/validate_qploneskindump_form.vpy

    r834 r1109  
    1111 
    1212from Products.CMFCore.utils import getToolByName 
    13 from Products.qPloneSkinDump.qPloneSkinDump import isValidProductName, isValidDirName 
     13from Products.qPloneSkinDump.qPloneSkinDump import isValidProductName 
     14from Products.qPloneSkinDump.qPloneSkinDump import isValidDirName 
     15from Products.qPloneSkinDump.qPloneSkinDump import isValidDestinationDir 
    1416errors = state.getErrors() 
    1517 
     
    2224 
    2325# Check REQUIRED fields 
    24 REQUIRED_FIELDS = ['ZMISkinName', 'ZMIBaseSkinName', 'FSProductName', 'FSSkinDirectory'
     26REQUIRED_FIELDS = ['ZMISkinName', 'ZMIBaseSkinName', 'FSProductName', 'FSSkinDirectory', 'FSDestinationDirectory'
    2527theform = {} 
    2628for f in REQUIRED_FIELDS: 
     
    3032    theform[f]=fdata 
    3133 
    32 if not( theform['FSProductName'] and isValidProductName(theform['FSProductName']) ): 
    33     update_errors(errors, {'FSProductName': u"Not valid Product name - read help attentively."}) 
     34if not( theform["FSDestinationDirectory"] and isValidDestinationDir(theform["FSDestinationDirectory"]) ): 
     35    update_errors(errors, {"FSDestinationDirectory": u"Not valid Destination directory"}) 
     36 
     37if 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."}) 
    3440 
    3541if not( theform['FSSkinDirectory'] and isValidDirName(theform['FSSkinDirectory']) ): 
  • qPloneSkinDump/branches/plone_3.0/utils.py

    r1106 r1109  
    224224    return "\n".join(['   <layer name="%s"/>' % l for l in layers]) 
    225225 
    226 def getFSSkinPath(folder, fs_product_name): 
     226def getFSSkinPath(folder, fs_dest_directory, fs_product_name): 
    227227    """ Return file system skin path for subdir.""" 
    228228 
    229229    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) 
    231231 
    232232    # If in skin's subfolder - get its path 
     
    237237    return skinpath 
    238238 
    239 def dumpFolder(folder, fs_product_name): 
    240     skinpath = getFSSkinPath(folder, fs_product_name) 
     239def dumpFolder(folder, fs_dest_directory, fs_product_name): 
     240    skinpath = getFSSkinPath(folder, fs_dest_directory, fs_product_name) 
    241241    # Create directory in FS if not yet exist 
    242242    if not os.path.exists(skinpath): 
     
    256256                writeProps(o, skinpath, extension = '.props') 
    257257            else: 
    258                 dumpFolder(o, fs_product_name
     258                dumpFolder(o, fs_product_name, fs_product_name
    259259        elif meta_type in _write_custom_meta_type_list: 
    260260            #writeProps( o, skinpath )      # write object's properties 
     
    267267        writeObjectsMeta(obj_meta, skinpath) 
    268268 
    269 def dumpSkin(context, skin_names=['custom',], fs_product_name='QSkinTemplate', erase_from_skin=0): 
     269def dumpSkin(context, skin_names=['custom',], fs_dest_directory=PRODUCTS_PATH, 
     270             fs_product_name='QSkinTemplate', erase_from_skin=0): 
    270271    """Dump custom information to file.""" 
    271272    if type(skin_names) not in (type([]), type(())): 
     
    273274    for skin_name in list(skin_names): 
    274275        folder = getToolByName(context, 'portal_skins')[skin_name] 
    275         dumpFolder(folder, fs_product_name) 
     276        dumpFolder(folder, fs_dest_directory, fs_product_name) 
    276277        # delete objects from the skin, if request 
    277278        if erase_from_skin: 
     
    360361    return xml 
    361362 
    362 def makeNewProduct(context, productName, productSkinName, \ 
     363def makeNewProduct(context, destinationDir, productName, productSkinName, \ 
    363364                   zmi_skin_names, zmi_base_skin_name, subdir,\ 
    364365                   doesCustomizeSlots, left_slots, right_slots, slot_forming, main_column, \ 
     
    367368    """Create new skin-product's directory and  
    368369       copy skin-product template with little modification""" 
    369     products_path = PRODUCTS_PATH 
     370    products_path = destinationDir 
    370371    productPath = ospJoin(products_path, productName) 
    371372    if not (productName in os.listdir(products_path)): 
     
    430431 
    431432    # Copy skin_template to SKIN_PRODUCT directory 
    432     templatePath = ospJoin(products_path, PROJECTNAME, TEMPLATE_PATH) 
     433    templatePath = ospJoin(PRODUCTS_PATH, PROJECTNAME, TEMPLATE_PATH) 
    433434    copyDir(templatePath, productPath, productName) 
    434435    # Form data dictionary and form Skin Product's files