Commit 3ad77578 authored by Romain Courteaud's avatar Romain Courteaud

erp5_forge: start to break vcs for erp5js

erp5_force: break by dropping the custom page template

erp5_forge: drop vcs_dialog

erp5_forge: use Base_redirect

erp5_forge: use formulator to propagate the values

erp5_forge drop some fields from changelog form

erp5_forge:

erp5_forge: stop accessing the request to pass arguments

erp5_forge: commit from xhtml_style and from erp5js

erp5_forge: remove comment

erp5_forge: drop useless comment
parent 2d2f2b57
...@@ -321,10 +321,8 @@ class Git(WorkingCopy): ...@@ -321,10 +321,8 @@ class Git(WorkingCopy):
return self.git('rev-parse', '--short', 'HEAD') + '+' return self.git('rev-parse', '--short', 'HEAD') + '+'
return self.git('rev-parse', 'HEAD') return self.git('rev-parse', 'HEAD')
def commit(self, changelog, added=(), modified=(), removed=()): def commit(self, changelog, push, added=(), modified=(), removed=()):
context = self.aq_parent context = self.aq_parent
request = context.REQUEST
push = request.get('push')
reset = 1 reset = 1
if push: if push:
# if we can't push because we are not up-to-date, we'll either 'merge' or # if we can't push because we are not up-to-date, we'll either 'merge' or
...@@ -390,9 +388,9 @@ class Git(WorkingCopy): ...@@ -390,9 +388,9 @@ class Git(WorkingCopy):
portal_status_message = translateString( portal_status_message = translateString(
'Files committed successfully in revision ${revision}', 'Files committed successfully in revision ${revision}',
mapping=dict(revision=head)) mapping=dict(revision=head))
return request.RESPONSE.redirect('%s/view?%s' % ( return context.Base_redirect('view', keep_items={
context.absolute_url_path(), 'portal_status_message': portal_status_message
make_query(portal_status_message=portal_status_message))) })
def log(self, path='.'): def log(self, path='.'):
log = [] log = []
......
from ZTUtils import make_query from Products.ERP5Type.Message import translateString
form_results = context.BusinessTemplate_viewCreateWorkingCopy.validate_all(REQUEST) form_results = context.BusinessTemplate_viewCreateWorkingCopy.validate_all(REQUEST)
working_copy = form_results['your_repository'] working_copy = form_results['your_repository']
context.getVcsTool(path=working_copy).createBusinessTemplateWorkingCopy() context.getVcsTool(path=working_copy).createBusinessTemplateWorkingCopy()
query_string = make_query(portal_status_message='Business Template Working Copy created') return context.Base_redirect('BusinessTemplate_viewVcsStatus', keep_items=dict(
REQUEST.response.redirect('%s/BusinessTemplate_viewVcsStatus?%s' % portal_status_message=translateString('Business Template Working Copy created')
(context.absolute_url_path(), query_string)) ))
kw = {} import json
request = container.REQUEST
for k in 'added', 'modified', 'removed': context.log('BusinessTemplate_viewVcsStatusDialog\nchnagelog %s\npush %s\nadded %s\nmodified %s\nremoved %s\njson %s\nkw %s' % (changelog, push, added, modified, removed, commit_json, str(kw)))
file_list = request.get(k, ())
commit_dict = json.loads(commit_json) if commit_json is not None else {
'added': (),
'modified': (),
'removed': (),
'changelog': '',
'push': False
}
for key, file_list in (('added', added), ('modified', modified), ('removed', removed)):
if file_list is not None:
# XXX: ERP5VCS_doCreateJavaScriptStatus should send lists # XXX: ERP5VCS_doCreateJavaScriptStatus should send lists
if isinstance(file_list, basestring): if isinstance(file_list, basestring):
file_list = file_list != 'none' and filter(None, file_list.split(',')) or () file_list = file_list != 'none' and filter(None, file_list.split(',')) or ()
kw[k] = file_list commit_dict[key] = file_list
if changelog is not None:
commit_dict['changelog'] = changelog
if push is not None:
commit_dict['push'] = push
# Remover keys used when handling commit exception
commit_dict.pop('caller', None)
commit_dict.pop('caller_kw', None)
# Always propage all informations throught formulator hidden field
request = context.REQUEST
request.form['your_commit_json'] = json.dumps(commit_dict)
request.form['your_added'] = commit_dict['added']
request.form['your_modified'] = commit_dict['modified']
request.form['your_removed'] = commit_dict['removed']
changelog = request.get('changelog', '') if commit_dict['changelog'].strip():
if not changelog.strip(): request.form['your_changelog'] = commit_dict['changelog']
else:
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
error_msg = "Please set a ChangeLog message." error_msg = "Please set a ChangeLog message."
request.set('portal_status_message', translateString(error_msg)) return context.Base_renderForm('BusinessTemplate_viewVcsChangelog', keep_items={
request.set('cancel_url', context.absolute_url() + 'portal_status_message': translateString(error_msg),
'cancel_url': context.absolute_url() +
'/BusinessTemplate_viewVcsStatus?do_extract:int=0' '/BusinessTemplate_viewVcsStatus?do_extract:int=0'
'&portal_status_message=Commit%20cancelled.') '&portal_status_message=Commit%20cancelled.'
return context.asContext(**kw).BusinessTemplate_viewVcsChangelog() })
try: try:
return context.getVcsTool().commit(changelog, **kw) return context.getVcsTool().commit(
commit_dict['changelog'],
commit_dict['push'],
added=commit_dict['added'],
modified=commit_dict['modified'],
removed=commit_dict['removed']
)
except Exception, error: except Exception, error:
return context.BusinessTemplate_handleException(error, script.id) return context.BusinessTemplate_handleException(error, script.id, commit_dict=commit_dict)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>push=None, changelog=None, added=None, modified=None, removed=None, commit_json=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
if caller_kw is None:
caller_kw = {}
context.getVcsTool().setLogin(auth, user, password) context.getVcsTool().setLogin(auth, user, password)
return context.restrictedTraverse(caller)(**caller_kw) import json
commit_dict = json.loads(commit_json)
return context.restrictedTraverse(commit_dict['caller'].encode())(commit_json=commit_json)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>user, password, auth, caller, caller_kw=None, added=(), modified=(), removed=(), changelog=None, **kw</string> </value> <value> <string>user, password, auth, commit_json, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from erp5.component.module.Git import GitLoginError from erp5.component.module.Git import GitLoginError
from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError
import json
try: try:
raise exception raise exception
...@@ -16,5 +17,12 @@ except GitLoginError, e: ...@@ -16,5 +17,12 @@ except GitLoginError, e:
kw = dict(remote_url=context.getVcsTool().getRemoteUrl()) kw = dict(remote_url=context.getVcsTool().getRemoteUrl())
method = 'BusinessTemplate_viewGitLogin' method = 'BusinessTemplate_viewGitLogin'
context.REQUEST.set('portal_status_message', message) commit_dict['caller'] = caller
return getattr(context.asContext(**kw), method)(caller=caller, caller_kw=caller_kw) # XXX caller_kw
# Always propage all informations throught formulator hidden field
request = context.REQUEST
request.form['your_commit_json'] = json.dumps(commit_dict)
return context.Base_renderForm(method, keep_items={
'portal_status_message': message
})
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>exception, caller, **caller_kw</string> </value> <value> <string>exception, caller, commit_dict, **caller_kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsLogin</string> </value> <value> <string>BusinessTemplate_doVcsLogin</string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -74,7 +78,9 @@ ...@@ -74,7 +78,9 @@
<item> <item>
<key> <string>bottom</string> </key> <key> <string>bottom</string> </key>
<value> <value>
<list/> <list>
<string>your_commit_json</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -123,7 +129,7 @@ ...@@ -123,7 +129,7 @@
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>here/remote_url</string> </value> <value> <string>python: context.getVcsTool().getRemoteUrl()</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsLogin</string> </value> <value> <string>BusinessTemplate_doVcsLogin</string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -102,7 +106,7 @@ ...@@ -102,7 +106,7 @@
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>BusinessTemplate_doSvnSslTrust</string> </value> <value> <string>BusinessTemplate_doSvnSslTrust</string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -113,7 +117,7 @@ ...@@ -113,7 +117,7 @@
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsCommit</string> </value> <value> <string>BusinessTemplate_doVcsCommit</string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -60,6 +64,7 @@ ...@@ -60,6 +64,7 @@
<value> <value>
<list> <list>
<string>center</string> <string>center</string>
<string>bottom</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -67,6 +72,14 @@ ...@@ -67,6 +72,14 @@
<key> <string>groups</string> </key> <key> <string>groups</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
...@@ -74,9 +87,9 @@ ...@@ -74,9 +87,9 @@
<string>your_push</string> <string>your_push</string>
<string>your_changelog</string> <string>your_changelog</string>
<string>reminder</string> <string>reminder</string>
<string>added_files</string> <string>your_added</string>
<string>modified_files</string> <string>your_modified</string>
<string>removed_files</string> <string>your_removed</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -97,7 +110,7 @@ ...@@ -97,7 +110,7 @@
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>default</string>
<string>editable</string> <string>editable</string>
<string>title</string> <string>title</string>
</list> </list>
...@@ -18,7 +17,7 @@ ...@@ -18,7 +17,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>added_files</string> </value> <value> <string>your_added</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -55,10 +54,8 @@ ...@@ -55,10 +54,8 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>default</string> </key> <key> <string>editable</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
...@@ -72,6 +69,10 @@ ...@@ -72,6 +69,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -79,12 +80,6 @@ ...@@ -79,12 +80,6 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
...@@ -111,17 +106,4 @@ ...@@ -111,17 +106,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.added</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>default</string>
<string>editable</string> <string>editable</string>
<string>title</string> <string>title</string>
</list> </list>
...@@ -18,7 +17,7 @@ ...@@ -18,7 +17,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>modified_files</string> </value> <value> <string>your_modified</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -55,10 +54,8 @@ ...@@ -55,10 +54,8 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>default</string> </key> <key> <string>editable</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
...@@ -72,6 +69,10 @@ ...@@ -72,6 +69,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -79,12 +80,6 @@ ...@@ -79,12 +80,6 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
...@@ -111,17 +106,4 @@ ...@@ -111,17 +106,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.modified</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>default</string>
<string>editable</string> <string>editable</string>
<string>title</string> <string>title</string>
</list> </list>
...@@ -18,7 +17,7 @@ ...@@ -18,7 +17,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>removed_files</string> </value> <value> <string>your_removed</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -55,10 +54,8 @@ ...@@ -55,10 +54,8 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>default</string> </key> <key> <string>editable</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
...@@ -72,6 +69,10 @@ ...@@ -72,6 +69,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -79,12 +80,6 @@ ...@@ -79,12 +80,6 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
...@@ -111,17 +106,4 @@ ...@@ -111,17 +106,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.removed</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsMultiDiff</string> </value> <value> <string>BusinessTemplate_doVcsMultiDiff</string> </value>
</item> </item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -110,7 +114,7 @@ ...@@ -110,7 +114,7 @@
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value> <value> <string>form_dialog</string> </value>
</item> </item>
<item> <item>
<key> <string>row_length</string> </key> <key> <string>row_length</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>vcs_dialog</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<tal:block define="local_parameter_list python: dict((x, request[x])
for x in ('added', 'modified', 'removed', 'changelog', 'push')
if x in request);
dummy python: local_parameter_list.update((x, options.pop(x))
for x in ('caller', 'caller_kw')
if x in options)"
tal:on-error="structure python: here.BusinessTemplate_handleException(error.value, context.id)">
<tal:block metal:use-macro="here/form_dialog/macros/master" />
</tal:block>
</tal:block>
\ No newline at end of file
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