[CMF-checkins] CVS: Products/CMFDefault/skins/zpt_content - document_edit_form.py:1.1 document_edit_template.pt:1.1 newsitem_edit_form.py:1.1 newsitem_edit_template.pt:1.1 document_edit_control.py:1.5 newsitem_edit_control.py:1.5 document_edit.py:NONE document_edit_form.pt:NONE newsitem_edit.py:NONE newsitem_edit_form.pt:NONE

Yvo Schubbe y.2004_ at wcm-solutions.de
Tue Jul 6 12:06:06 EDT 2004


Update of /cvs-repository/Products/CMFDefault/skins/zpt_content
In directory cvs.zope.org:/tmp/cvs-serv3458/CMFDefault/skins/zpt_content

Modified Files:
	document_edit_control.py newsitem_edit_control.py 
Added Files:
	document_edit_form.py document_edit_template.pt 
	newsitem_edit_form.py newsitem_edit_template.pt 
Removed Files:
	document_edit.py document_edit_form.pt newsitem_edit.py 
	newsitem_edit_form.pt 
Log Message:
- renamed *_edit_form.pt to *_edit_template.pt: edit templates are now called by the *_edit_form.py
- renamed *_edit_control.py to *_edit_form.py: form scripts are now called directly
- renamed *_edit.py to *_edit_control.py: they are the real controller scripts


=== Added File Products/CMFDefault/skins/zpt_content/document_edit_form.py ===
##parameters=change='', change_and_view=''
##
form = context.REQUEST.form
if change and \
        context.validateTextFile(**form) and \
        context.validateHTML(**form) and \
        context.document_edit_control(**form) and \
        context.setRedirect(context, 'object/edit'):
    return
elif change_and_view and \
        context.validateTextFile(**form) and \
        context.validateHTML(**form) and \
        context.document_edit_control(**form) and \
        context.setRedirect(context, 'object/view'):
    return


options = {}

buttons = []
target = context.getActionInfo('object/edit')['url']
buttons.append( {'name': 'change', 'value': 'Change'} )
buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
options['form'] = { 'action': target,
                    'listButtonInfos': tuple(buttons) }

return context.document_edit_template(**options)


=== Added File Products/CMFDefault/skins/zpt_content/document_edit_template.pt ===
<html metal:use-macro="context/main_template/macros/master">
<body>

<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
<h1 i18n:translate="">Edit: <tal:span
    tal:content="context/Title" i18n:name="obj_title">Title</tal:span></h1>
</metal:slot>

<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
   tal:define="form options/form">
<div class="Desktop">

<form action="document_edit_form" method="post" enctype="multipart/form-data"
   tal:attributes="action form/action">
 <input type="hidden" name="SafetyBelt" value=""
        tal:attributes="value context/SafetyBelt" />
<table class="FormLayout">
 <tr>
  <th i18n:translate="">Title</th>
  <td tal:content="context/Title">Title</td>
 </tr>
 <tr>
  <th i18n:translate="">Description</th>
  <td tal:content="context/Description">Description</td>
 </tr>
 <tr>
  <th i18n:translate="">Format</th>
  <td>
   <input type="radio" name="text_format" value="structured-text" id="cb_stx"
      tal:attributes="
             checked python:path('context/text_format')=='structured-text'" />
   <label for="cb_stx" i18n:translate="">structured-text</label>
   <input type="radio" name="text_format" value="plain" id="cb_plain"
      tal:attributes="checked python:path('context/text_format')=='plain'" />
   <label for="cb_plain" i18n:translate="">plain text</label>
   <input type="radio" name="text_format" value="html" id="cb_html"
      tal:attributes="checked python:path('context/text_format')=='html'" />
   <label for="cb_html" i18n:translate="">html</label>
  </td>
 </tr>
 <tr>
  <th i18n:translate="">Upload</th>
  <td>
   <input type="file" name="file" size="25" />
  </td>
 </tr>
 <tr>
  <th class="TextField" i18n:translate="">Edit</th>
  <td class="TextField">
   <textarea name="text:text" rows="20" cols="80" wrap="soft"
             tal:content="context/EditableBody"></textarea>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>
   <metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
  </td>
 </tr>
</table>
</form>

</div>
</metal:slot>

</body>
</html>


=== Added File Products/CMFDefault/skins/zpt_content/newsitem_edit_form.py ===
##parameters=change='', change_and_view=''
##
form = context.REQUEST.form
if change and \
        context.validateHTML(**form) and \
        context.newsitem_edit_control(**form) and \
        context.setRedirect(context, 'object/edit'):
    return
elif change_and_view and \
        context.validateHTML(**form) and \
        context.newsitem_edit_control(**form) and \
        context.setRedirect(context, 'object/view'):
    return


options = {}

buttons = []
target = context.getActionInfo('object/edit')['url']
buttons.append( {'name': 'change', 'value': 'Change'} )
buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
options['form'] = { 'action': target,
                    'listButtonInfos': tuple(buttons) }

return context.newsitem_edit_template(**options)


=== Added File Products/CMFDefault/skins/zpt_content/newsitem_edit_template.pt ===
<html metal:use-macro="context/main_template/macros/master">
<body>

<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
<h1 i18n:translate="">Edit: <tal:span
    tal:content="context/Title" i18n:name="obj_title">Title</tal:span></h1>
</metal:slot>

<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
   tal:define="form options/form">
<div class="Desktop">

<form action="newsitem_edit_form" method="post"
   tal:attributes="action form/action">
<table class="FormLayout">
 <tr>
  <th i18n:translate="">Title</th>
  <td tal:content="context/Title">Title</td>
 </tr>
 <tr>
  <th i18n:translate="">Format</th>
  <td>
   <input type="radio" name="text_format" value="structured-text" id="cb_stx"
      tal:attributes="
             checked python:path('context/text_format')=='structured-text'" />
   <label for="cb_stx" i18n:translate="">structured-text</label>
   <input type="radio" name="text_format" value="plain" id="cb_plain"
      tal:attributes="checked python:path('context/text_format')=='plain'" />
   <label for="cb_plain" i18n:translate="">plain text</label>
   <input type="radio" name="text_format" value="html" id="cb_html"
      tal:attributes="checked python:path('context/text_format')=='html'" />
   <label for="cb_html" i18n:translate="">html</label>
  </td>
 </tr>
 <tr>
  <th class="TextField" i18n:translate="">Lead-in</th>
  <td class="TextField">
   <textarea name="description:text" rows="10" wrap="soft"
             cols="65" tal:content="context/Description"></textarea>
  </td>
 </tr>
 <tr>
  <th class="TextField" i18n:translate="">Body</th>
  <td class="TextField">
   <textarea name="text:text" rows="20" cols="65" wrap="soft"
             tal:content="context/EditableBody"></textarea>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>
   <metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
  </td>
 </tr>
</table>
</form>

</div>
</metal:slot>

</body>
</html>


=== Products/CMFDefault/skins/zpt_content/document_edit_control.py 1.4 => 1.5 ===
--- Products/CMFDefault/skins/zpt_content/document_edit_control.py:1.4	Tue Jun  1 13:40:57 2004
+++ Products/CMFDefault/skins/zpt_content/document_edit_control.py	Tue Jul  6 12:06:06 2004
@@ -1,29 +1,13 @@
-## Script (Python) "document_edit_control"
-##parameters=text_format='', text='', file='', SafetyBelt='', change='', change_and_view='', **kw
-##title=
+##parameters=text_format, text, SafetyBelt='', **kw
 ##
-form = context.REQUEST.form
-if change and \
-        context.validateTextFile(**form) and \
-        context.validateHTML(**form) and \
-        context.document_edit(**form) and \
-        context.setRedirect(context, 'object/edit'):
-    return
-elif change_and_view and \
-        context.validateTextFile(**form) and \
-        context.validateHTML(**form) and \
-        context.document_edit(**form) and \
-        context.setRedirect(context, 'object/view'):
-    return
+from Products.CMFDefault.exceptions import EditingConflict
+from Products.CMFDefault.exceptions import ResourceLockedError
 
-
-control = {}
-
-buttons = []
-target = context.getActionInfo('object/edit')['url']
-buttons.append( {'name': 'change', 'value': 'Change'} )
-buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
-control['form'] = { 'action': target,
-                    'listButtonInfos': tuple(buttons) }
-
-return control
+if text_format != context.text_format or text != context.text:
+    try:
+        context.edit(text_format, text, safety_belt=SafetyBelt)
+        return context.setStatus(True, 'Document changed.')
+    except (ResourceLockedError, EditingConflict), errmsg:
+        return context.setStatus(False, errmsg)
+else:
+    return context.setStatus(False, 'Nothing to change.')


=== Products/CMFDefault/skins/zpt_content/newsitem_edit_control.py 1.4 => 1.5 ===
--- Products/CMFDefault/skins/zpt_content/newsitem_edit_control.py:1.4	Tue Jun  1 13:40:57 2004
+++ Products/CMFDefault/skins/zpt_content/newsitem_edit_control.py	Tue Jul  6 12:06:06 2004
@@ -1,27 +1,14 @@
-## Script (Python) "newsitem_edit_control"
-##parameters=description='', text_format='', text='', change='', change_and_view='', **kw
-##title=
+##parameters=text_format, text, description='', **kw
 ##
-form = context.REQUEST.form
-if change and \
-        context.validateHTML(**form) and \
-        context.newsitem_edit(**form) and \
-        context.setRedirect(context, 'object/edit'):
-    return
-elif change_and_view and \
-        context.validateHTML(**form) and \
-        context.newsitem_edit(**form) and \
-        context.setRedirect(context, 'object/view'):
-    return
+from Products.CMFDefault.exceptions import ResourceLockedError
 
-
-control = {}
-
-buttons = []
-target = context.getActionInfo('object/edit')['url']
-buttons.append( {'name': 'change', 'value': 'Change'} )
-buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
-control['form'] = { 'action': target,
-                    'listButtonInfos': tuple(buttons) }
-
-return control
+if description != context.description or \
+        text_format != context.text_format or text != context.text:
+    try:
+        context.edit(text=text, description=description,
+                     text_format=text_format)
+        return context.setStatus(True, 'News Item changed.')
+    except ResourceLockedError, errmsg:
+        return context.setStatus(False, errmsg)
+else:
+    return context.setStatus(False, 'Nothing to change.')

=== Removed File Products/CMFDefault/skins/zpt_content/document_edit.py ===

=== Removed File Products/CMFDefault/skins/zpt_content/document_edit_form.pt ===

=== Removed File Products/CMFDefault/skins/zpt_content/newsitem_edit.py ===

=== Removed File Products/CMFDefault/skins/zpt_content/newsitem_edit_form.pt ===



More information about the CMF-checkins mailing list