Commit 4840eedd authored by Jérome Perrin's avatar Jérome Perrin

make .cvsignore generation optional when generating a product



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10082 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 015d5a78
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
from Products.CMFCore.utils import UniqueObject from Products.CMFCore.utils import UniqueObject
from zExceptions import BadRequest
from Acquisition import Implicit from Acquisition import Implicit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, DTMLFile from Globals import InitializeClass, DTMLFile
...@@ -610,9 +611,18 @@ class ConstraintTemplate(Constraint): ...@@ -610,9 +611,18 @@ class ConstraintTemplate(Constraint):
security.declareProtected( Permissions.ManageExtensions, 'generateProduct' ) security.declareProtected( Permissions.ManageExtensions, 'generateProduct' )
def generateProduct(self, product_id, def generateProduct(self, product_id,
document_id_list=(), property_sheet_id_list=(), constraint_id_list=(), document_id_list=(), property_sheet_id_list=(), constraint_id_list=(),
extension_id_list=(), test_id_list=(), REQUEST=None): extension_id_list=(), test_id_list=(),
generate_cvsignore=0, REQUEST=None):
"""Generate a Product """Generate a Product
""" """
if not product_id:
message = 'Product Name must be specified'
if REQUEST is not None:
return REQUEST.RESPONSE.redirect(
'%s/manage_viewProductGeneration?manage_tabs_message=%s' %
(self.absolute_url(), message.replace(' ', '+')))
raise BadRequest(message)
# Ensure that Products exists. # Ensure that Products exists.
product_path = os.path.join(getConfiguration().instancehome, 'Products') product_path = os.path.join(getConfiguration().instancehome, 'Products')
if not os.path.exists(product_path): if not os.path.exists(product_path):
...@@ -650,13 +660,14 @@ class ConstraintTemplate(Constraint): ...@@ -650,13 +660,14 @@ class ConstraintTemplate(Constraint):
f.close() f.close()
# Make .cvsignore for convenience. # Make .cvsignore for convenience.
cvsignore = os.path.join(base_path, '.cvsignore') if generate_cvsignore:
if not os.path.exists(cvsignore): cvsignore = os.path.join(base_path, '.cvsignore')
f = open(cvsignore, 'w') if not os.path.exists(cvsignore):
try: f = open(cvsignore, 'w')
f.write('*.pyc' + os.linesep) try:
finally: f.write('*.pyc' + os.linesep)
f.close() finally:
f.close()
# Create an init file for this Product. # Create an init file for this Product.
init = os.path.join(base_path, '__init__.py') init = os.path.join(base_path, '__init__.py')
...@@ -746,7 +757,7 @@ def initialize( context ): ...@@ -746,7 +757,7 @@ def initialize( context ):
f.close() f.close()
if REQUEST is not None: if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_viewProductGeneration?message=New+Product+Saved+In+%s' % (self.absolute_url(), base_path)) REQUEST.RESPONSE.redirect('%s/manage_viewProductGeneration?manage_tabs_message=New+Product+Saved+In+%s' % (self.absolute_url(), base_path))
security.declareProtected( Permissions.ManagePortal, security.declareProtected( Permissions.ManagePortal,
'asDocumentationHelper') 'asDocumentationHelper')
......
...@@ -25,7 +25,18 @@ ...@@ -25,7 +25,18 @@
<input type="text" name="product_id" size="40" value="" /> <input type="text" name="product_id" size="40" value="" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Generate .cvsignore files ?
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="generate_cvsignore" />
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment