[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - add.pt:1.8
add.py:1.29 addwizard.pt:1.3 addwizard.py:1.9
configure.zcml:1.20 edit.pt:1.10 editview.py:1.34
editwizard.py:1.12 schemadisplay.py:1.10
vocabularywidget.py:1.50 widget.py:1.46
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Aug 7 14:42:11 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv26029/form
Modified Files:
add.pt add.py addwizard.pt addwizard.py configure.zcml edit.pt
editview.py editwizard.py schemadisplay.py vocabularywidget.py
widget.py
Log Message:
Internationalized the rest of zope/app/browser.
I also took the chance to clean up some old code and remove a lot of cruft.
(This is the reason I decided to do it instead of letting a less
experienced developer do it.)
I now consider I18n of the Zope core done. What does this mean to you?
1. All code you check into the CVS must be internationalized. That means:
(a) Python and PT code must be properly tagged.
(b) zope.pot must be updated. This can be done with::
[zope/app/translation_files]$ python extract.py
Note: You do not need to merge the new POT file with the catalogs.
2. Any code snippet that has no I18n is considered a bug! Therefore, please
take care and do the I18n and make code so when you see missing spots.
Finally I would like to mention that some forms might experience some
hickups, as I changed and moved around a lot of templates and was not able
to verify them all by hand. Please let me know, if something that used to
work is not working anymore.
=== Zope3/src/zope/app/browser/form/add.pt 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/add.pt:1.7 Mon Jul 14 11:28:23 2003
+++ Zope3/src/zope/app/browser/form/add.pt Thu Aug 7 13:40:28 2003
@@ -5,8 +5,7 @@
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="post"
- enctype="multipart/form-data"
- >
+ enctype="multipart/form-data">
<div metal:define-macro="formbody">
@@ -19,10 +18,9 @@
tal:condition="status"
tal:content="status" />
- <p tal:condition="view/errors">
- <span i18n:translate="">There are</span>
- <strong tal:content="python:len(view.errors)">6</strong>
- <span i18n:translate="">input errors.</span>
+ <p tal:condition="view/errors" i18n:translate="">
+ There are <strong tal:content="python:len(view.errors)"
+ i18n:name="num_errors">6</strong> input errors.
</p>
<div metal:define-slot="extra_info" tal:replace="nothing">
=== Zope3/src/zope/app/browser/form/add.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/browser/form/add.py:1.28 Mon Aug 4 10:52:45 2003
+++ Zope3/src/zope/app/browser/form/add.py Thu Aug 7 13:40:28 2003
@@ -11,26 +11,26 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Add Form View class
+
$Id$
"""
-
import sys
-from zope.schema.interfaces import ValidationError
-
+from zope.app.browser.form.editview import EditView
+from zope.app.browser.form.submit import Update
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.interfaces.form import WidgetsError
from zope.app.form.utility import setUpWidgets, getWidgetsData
+from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.interfaces.form import WidgetsError
+from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.security.checker import defineChecker, NamesChecker
from zope.component import getAdapter
from zope.component.view import provideView
from zope.publisher.interfaces.browser import IBrowserPresentation
-from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
-from zope.app.browser.form.submit import Update
-from zope.app.browser.form.editview import EditView
+from zope.schema.interfaces import ValidationError
+from zope.security.checker import defineChecker, NamesChecker
class AddView(EditView):
"""Simple edit-view base class.
@@ -59,7 +59,7 @@
content = self.createAndAdd(data)
except WidgetsError, errors:
self.errors = errors
- self.update_status = u"An error occured."
+ self.update_status = _("An error occured.")
return self.update_status
self.request.response.redirect(self.nextURL())
@@ -67,8 +67,7 @@
return self.update_status
def create(self, *args, **kw):
- """Do the actual instantiation.
- """
+ """Do the actual instantiation."""
return self._factory(*args, **kw)
def createAndAdd(self, data):
=== Zope3/src/zope/app/browser/form/addwizard.pt 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/addwizard.pt:1.2 Mon Jul 14 11:28:23 2003
+++ Zope3/src/zope/app/browser/form/addwizard.pt Thu Aug 7 13:40:28 2003
@@ -1,81 +1,83 @@
-<tal:b condition="view/update"/><html metal:use-macro="context/@@standard_macros/dialog">
- <body>
- <div metal:fill-slot="body">
-
- <div metal:define-macro="body">
-
- <form action="." tal:attributes="action request/URL" method="post"
- enctype="multipart/form-data">
-
- <div metal:define-macro="formbody">
-
- <h3 tal:condition="view/label"
- tal:content="view/label"
- metal:define-slot="heading"
- >Edit something</h3>
-
- <p tal:condition="view/feedback" tal:content="view/feedback">
- A feedback message to the user
- </p>
-
- <div tal:condition="view/errors">
- <ul>
- <li tal:repeat="error view/errors">
- <strong tal:content="error/__class__" i18n:translate="">
- Error Type</strong>:
- <span tal:content="error">Error text</span>
- </li>
- </ul>
- </div>
-
- <div metal:define-slot="extra_info" tal:replace="nothing">
- </div>
-
- <div class="row" metal:define-slot="extra_top" tal:replace="nothing">
- <div class="label">Extra top</div>
- <div class="label"><input type="text" style="width:100%" /></div>
- </div>
- <div class="row"
- metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
- tal:content="structure widget/row">
- <div class="label">Name</div>
- <div class="field"><input type="text" style="width:100%" /></div>
- <div class="error">Error message</div>
- </div>
- <div class="row"
- metal:define-slot="extra_bottom" tal:replace="nothing">
- <div class="label">Extra bottom</div>
- <div class="field"><input type="text" style="width:100%" /></div>
- </div>
-
- </div>
-
- <div class="row">
- <div class="controls">
- <!-- <input type="submit" value="Refresh"
- i18n:attributes="value refresh-button" /> -->
- <input tal:condition="view/show_previous"
- type="submit" name="PREVIOUS_SUBMIT" value="Previous"
- i18n:attributes="value previous-button" />
- <input tal:condition="view/show_submit"
- type="submit" name="UPDATE_SUBMIT" value="Submit"
- i18n:attributes="value submit-button"/>
- <input tal:condition="view/show_next"
- type="submit" name="NEXT_SUBMIT" value="Next"
- i18n:attributes="value next-button" />
- </div>
- </div>
-
- <div tal:replace="structure view/renderHidden">
- <!-- type=hidden input controls for passing state without session -->
- <input type="hidden" name="example" value="foo" />
+<tal:block condition="view/update"/><html
+ metal:use-macro="context/@@standard_macros/dialog">
+
+<body>
+<div metal:fill-slot="body">
+
+<div metal:define-macro="body">
+
+ <form action="." tal:attributes="action request/URL" method="post"
+ enctype="multipart/form-data">
+
+ <div metal:define-macro="formbody">
+
+ <h3 tal:condition="view/label"
+ tal:content="view/label"
+ metal:define-slot="heading"
+ >Edit something</h3>
+
+ <p tal:condition="view/feedback" tal:content="view/feedback">
+ A feedback message to the user
+ </p>
+
+ <div tal:condition="view/errors">
+ <ul>
+ <li tal:repeat="error view/errors">
+ <strong tal:content="error/__class__">
+ Error Type</strong>:
+ <span tal:content="error">Error text</span>
+ </li>
+ </ul>
+ </div>
+
+ <div metal:define-slot="extra_info" tal:replace="nothing">
+ </div>
+
+ <div class="row" metal:define-slot="extra_top" tal:replace="nothing">
+ <div class="label">Extra top</div>
+ <div class="label"><input type="text" style="width:100%" /></div>
</div>
+ <div class="row"
+ metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
+ tal:content="structure widget/row">
+ <div class="label">Name</div>
+ <div class="field"><input type="text" style="width:100%" /></div>
+ <div class="error">Error message</div>
+ </div>
+ <div class="row"
+ metal:define-slot="extra_bottom" tal:replace="nothing">
+ <div class="label">Extra bottom</div>
+ <div class="field"><input type="text" style="width:100%" /></div>
+ </div>
+
+ </div>
+
+ <div class="row">
+ <div class="controls">
+ <!-- <input type="submit" value="Refresh"
+ i18n:attributes="value refresh-button" /> -->
+ <input tal:condition="view/show_previous"
+ type="submit" name="PREVIOUS_SUBMIT" value="Previous"
+ i18n:attributes="value previous-button" />
+ <input tal:condition="view/show_submit"
+ type="submit" name="UPDATE_SUBMIT" value="Submit"
+ i18n:attributes="value submit-button"/>
+ <input tal:condition="view/show_next"
+ type="submit" name="NEXT_SUBMIT" value="Next"
+ i18n:attributes="value next-button" />
+ </div>
+ </div>
+
+ <div tal:replace="structure view/renderHidden">
+ <!-- type=hidden input controls for passing state without session -->
+ <input type="hidden" name="example" value="foo" />
+ </div>
- </form>
+ </form>
- </div>
+</div>
- </div>
- </body>
+</div>
+</body>
</html>
=== Zope3/src/zope/app/browser/form/addwizard.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/addwizard.py:1.8 Mon Aug 4 10:52:45 2003
+++ Zope3/src/zope/app/browser/form/addwizard.py Thu Aug 7 13:40:28 2003
@@ -11,23 +11,23 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Add Wizard View Classes
+
$Id$
"""
-
import sys
-from zope.schema.interfaces import ValidationError
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.interfaces.form import WidgetsError
from zope.app.form.utility import setUpWidgets
+from zope.app.interfaces.form import WidgetsError
+from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.security.checker import defineChecker, NamesChecker
from zope.component import getAdapter
from zope.component.view import provideView
from zope.publisher.interfaces.browser import IBrowserPresentation
-from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
+from zope.schema.interfaces import ValidationError
+from zope.security.checker import defineChecker, NamesChecker
from editwizard import EditWizardView, WizardStorage
class AddWizardView(EditWizardView):
@@ -47,8 +47,7 @@
setUpWidgets(self, self.schema, names=self.fieldNames)
def create(self, *args, **kw):
- """Do the actual instantiation.
- """
+ """Do the actual instantiation."""
return self._factory(*args, **kw)
def apply_update(self, data):
=== Zope3/src/zope/app/browser/form/configure.zcml 1.19 => 1.20 ===
--- Zope3/src/zope/app/browser/form/configure.zcml:1.19 Sun Aug 3 13:49:03 2003
+++ Zope3/src/zope/app/browser/form/configure.zcml Thu Aug 7 13:40:28 2003
@@ -1,8 +1,6 @@
<configure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'
- i18n_domain='zope'
- >
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
<!-- Form Widget View Directives -->
<browser:defaultView for="zope.schema.interfaces.IField" name="edit" />
=== Zope3/src/zope/app/browser/form/edit.pt 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/form/edit.pt:1.9 Mon Jul 14 11:28:23 2003
+++ Zope3/src/zope/app/browser/form/edit.pt Thu Aug 7 13:40:28 2003
@@ -6,8 +6,7 @@
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="POST"
- enctype="multipart/form-data"
- >
+ enctype="multipart/form-data">
<div metal:define-macro="formbody">
@@ -20,10 +19,9 @@
tal:condition="status"
tal:content="status" />
- <p tal:condition="view/errors">
- <span i18n:translate="">There are</span>
- <strong tal:content="python:len(view.errors)">6</strong>
- <span i18n:translate="">input errors.</span>
+ <p tal:condition="view/errors" i18n:translate="">
+ There are <strong tal:content="python:len(view.errors)"
+ i18n:name="num_errors">6</strong> input errors.
</p>
<div metal:define-slot="extra_info" tal:replace="nothing">
=== Zope3/src/zope/app/browser/form/editview.py 1.33 => 1.34 ===
--- Zope3/src/zope/app/browser/form/editview.py:1.33 Mon Aug 4 10:52:45 2003
+++ Zope3/src/zope/app/browser/form/editview.py Thu Aug 7 13:40:28 2003
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Edit View Classes
+
$Id$
"""
-
from datetime import datetime
from zope.schema import getFieldNamesInOrder
@@ -25,6 +25,7 @@
from zope.component import getAdapter
from zope.app.context import ContextWrapper
+from zope.app.i18n import ZopeMessageIDFactory as _
from zope.app.interfaces.form import WidgetsError
from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
from zope.app.browser.form.submit import Update
@@ -93,15 +94,20 @@
publish(content, ObjectModifiedEvent(content))
except WidgetsError, errors:
self.errors = errors
- status = u"An error occured."
+ status = _("An error occured.")
else:
setUpEditWidgets(self, self.schema, force=1,
names=self.fieldNames)
if changed:
- status = "Updated %s" % datetime.utcnow()
+ formatter = self.request.locale.getDateTimeFormatter(
+ 'medium')
+ status = _("Updated on ${date_time}")
+ status.mapping = {'date_time': formatter.format(
+ datetime.utcnow())}
self.update_status = status
return status
+
def EditViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_, fields,
=== Zope3/src/zope/app/browser/form/editwizard.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/browser/form/editwizard.py:1.11 Mon Aug 4 10:52:45 2003
+++ Zope3/src/zope/app/browser/form/editwizard.py Thu Aug 7 13:40:28 2003
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Edit Wizard View Classes
+
$Id$
"""
-
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.component import getAdapter
from zope.app.publisher.browser.globalbrowsermenuservice import \
@@ -90,8 +90,7 @@
feedback = u''
def update(self):
- '''
- Called before rendering each pane. It is responsible
+ '''Called before rendering each pane. It is responsible
for extracting data into temporary storage, and selecting
which pane should be rendered.
'''
=== Zope3/src/zope/app/browser/form/schemadisplay.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/form/schemadisplay.py:1.9 Mon Aug 4 10:52:45 2003
+++ Zope3/src/zope/app/browser/form/schemadisplay.py Thu Aug 7 13:40:28 2003
@@ -11,12 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""\
-Support for display-only pages based on schema.
+"""Support for display-only pages based on schema.
$Id$
"""
-
from zope.schema import getFieldNamesInOrder
from zope.app.context import ContextWrapper
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.49 => 1.50 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.49 Mon Aug 4 10:54:19 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Thu Aug 7 13:40:28 2003
@@ -11,15 +11,14 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-
"""Vocabulary widget support.
This includes support for vocabulary fields' use of the vocabulary to
determine the actual widget to display, and support for supplemental
query objects and helper views.
+$Id$
"""
-
from xml.sax.saxutils import quoteattr
from zope.interface import implements, implementedBy
=== Zope3/src/zope/app/browser/form/widget.py 1.45 => 1.46 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.45 Tue Aug 5 16:25:03 2003
+++ Zope3/src/zope/app/browser/form/widget.py Thu Aug 7 13:40:28 2003
@@ -11,7 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Browser Widget Definitions
+
$Id$
"""
@@ -216,6 +217,8 @@
def label(self):
ts = getService(self.context, "Translation")
+ # Note that the domain is not that important here, since the title
+ # is most likely a message id carrying the domain anyways.
title = ts.translate(self.title, "zope", context=self.request)
if title is None:
title = self.title
More information about the Zope3-Checkins
mailing list