[CMF-checkins] CVS: CMF/CMFDefault/skins/zpt_content -
document_edit_control.py:1.1 newsitem_edit_control.py:1.1
document_edit_form.pt:1.8 newsitem_edit_form.pt:1.8
Yvo Schubbe
y.2004_ at wcm-solutions.de
Tue Jan 20 17:30:53 EST 2004
Update of /cvs-repository/CMF/CMFDefault/skins/zpt_content
In directory cvs.zope.org:/tmp/cvs-serv9999/CMFDefault/skins/zpt_content
Modified Files:
document_edit_form.pt newsitem_edit_form.pt
Added Files:
document_edit_control.py newsitem_edit_control.py
Log Message:
- use scrubHTML also for uploads
- refactored document and newsitem edit
=== Added File CMF/CMFDefault/skins/zpt_content/document_edit_control.py ===
## Script (Python) "document_edit_control"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=text_format='', text='', file='', SafetyBelt='', change='', change_and_view=''
##title=
##
from ZTUtils import make_query
from Products.CMFCore.CMFCoreExceptions import EditingConflict
from Products.CMFCore.CMFCoreExceptions import IllegalHTML
from Products.CMFCore.CMFCoreExceptions import ResourceLockedError
from Products.CMFDefault.utils import scrubHTML
message = ''
if change or change_and_view:
ok = 1
message = 'Nothing to change.'
try:
upload = file.read()
except AttributeError:
pass
else:
if upload:
text = upload
try:
text = scrubHTML(text)
except IllegalHTML, msg:
ok = 0
message = msg
if ok and (text_format != context.text_format or text != context.text):
try:
context.edit(text_format, text, safety_belt=SafetyBelt)
except (ResourceLockedError, EditingConflict), msg:
ok = 0
message = msg
else:
message = 'Document changed.'
if ok and change_and_view:
ti = context.getTypeInfo()
target = ti.getActionInfo('object/view', context)['url']
query = make_query(portal_status_message=message)
context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
return None
if message:
context.REQUEST.set('portal_status_message', message)
control = {}
buttons = []
ti = context.getTypeInfo()
target = ti.getActionInfo('object/edit', context)['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
=== Added File CMF/CMFDefault/skins/zpt_content/newsitem_edit_control.py ===
## Script (Python) "newsitem_edit_control"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=description='', text_format='', text='', change='', change_and_view=''
##title=
##
from ZTUtils import make_query
from Products.CMFCore.CMFCoreExceptions import IllegalHTML
from Products.CMFCore.CMFCoreExceptions import ResourceLockedError
from Products.CMFDefault.utils import scrubHTML
message = ''
if change or change_and_view:
ok = 1
message = 'Nothing to change.'
try:
description = scrubHTML(description)
text = scrubHTML(text)
except IllegalHTML, msg:
ok = 0
message = msg
if ok and (description != context.description
or text_format != context.text_format or text != context.text):
try:
context.edit(text=text, description=description,
text_format=text_format)
except ResourceLockedError, msg:
ok = 0
message = msg
else:
message = 'News Item changed.'
if ok and change_and_view:
ti = context.getTypeInfo()
target = ti.getActionInfo('object/view', context)['url']
query = make_query(portal_status_message=message)
context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
return None
if message:
context.REQUEST.set('portal_status_message', message)
control = {}
buttons = []
ti = context.getTypeInfo()
target = ti.getActionInfo('object/edit', context)['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
=== CMF/CMFDefault/skins/zpt_content/document_edit_form.pt 1.7 => 1.8 ===
--- CMF/CMFDefault/skins/zpt_content/document_edit_form.pt:1.7 Sun Jun 8 15:47:52 2003
+++ CMF/CMFDefault/skins/zpt_content/document_edit_form.pt Tue Jan 20 17:30:52 2004
@@ -1,16 +1,20 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
- xmlns:metal="http://xml.zope.org/namespaces/metal"
- metal:use-macro="here/main_template/macros/master">
+<tal:page
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ tal:define="control python: here.document_edit_control(**request.form)"
+ tal:condition="control"
+><html metal:use-macro="here/main_template/macros/master">
<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-<div class="Desktop">
+
+<metal:block metal:fill-slot="main"
+ tal:define="form control/form">
+<div class="Desktop" i18n:domain="cmf_default">
<h2 i18n:translate="">Edit <span
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
-<form action="document_edit" method="post" enctype="multipart/form-data"
- tal:attributes="action string:${here/absolute_url}/document_edit"
->
+<form action="document_edit_form" method="post" enctype="multipart/form-data"
+ tal:attributes="action control/form/action">
<input type="hidden" name="SafetyBelt" value=""
tal:attributes="value here/SafetyBelt" />
@@ -59,16 +63,14 @@
<tr>
<td> <br /> </td>
<td>
- <input type="submit" name="change" value="Change"
- i18n:attributes="value" />
- <input type="submit" name="change_and_view" value="Change and View"
- i18n:attributes="value" />
+ <metal:block metal:use-macro="here/form_widgets/macros/buttons" />
</td>
</tr>
</table>
</form>
</div>
-</div>
+</metal:block>
+
</body>
-</html>
+</html></tal:page>
=== CMF/CMFDefault/skins/zpt_content/newsitem_edit_form.pt 1.7 => 1.8 ===
--- CMF/CMFDefault/skins/zpt_content/newsitem_edit_form.pt:1.7 Sun Jun 8 15:47:52 2003
+++ CMF/CMFDefault/skins/zpt_content/newsitem_edit_form.pt Tue Jan 20 17:30:52 2004
@@ -1,17 +1,20 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
- xmlns:metal="http://xml.zope.org/namespaces/metal"
- metal:use-macro="here/main_template/macros/master">
+<tal:page
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ tal:define="control python: here.newsitem_edit_control(**request.form)"
+ tal:condition="control"
+><html metal:use-macro="here/main_template/macros/master">
<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-<div class="Desktop">
-<div class="NewsItem">
+
+<metal:block metal:fill-slot="main"
+ tal:define="form control/form">
+<div class="Desktop" i18n:domain="cmf_default">
<h2 i18n:translate="">Edit <span
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
-<form action="newsitem_edit" method="post"
- tal:attributes="action string:${here/absolute_url}/newsitem_edit"
->
+<form action="newsitem_edit_form" method="post"
+ tal:attributes="action control/form/action">
<table class="FormLayout">
<tr>
<th i18n:translate="">Title</th>
@@ -49,17 +52,14 @@
<tr>
<td> <br /> </td>
<td>
- <input type="submit" name="change" value="Change"
- i18n:attributes="value" />
- <input type="submit" name="change_and_view" value="Change and View"
- i18n:attributes="value" />
+ <metal:block metal:use-macro="here/form_widgets/macros/buttons" />
</td>
</tr>
</table>
</form>
</div>
-</div>
-</div>
+</metal:block>
+
</body>
-</html>
+</html></tal:page>
More information about the CMF-checkins
mailing list