[Zope3-checkins] CVS: zopeproducts/demo/jobboardi18n - preview.pt:1.4 edit.pt:1.3 configure.zcml:1.12 JobCreateView.py:1.5 Job.py:1.6 I18nJob.py:1.3 ApproveJobsView.py:1.4

Barry Warsaw barry@zope.com
Tue, 15 Apr 2003 17:24:00 -0400


Update of /cvs-repository/zopeproducts/demo/jobboardi18n
In directory cvs.zope.org:/tmp/cvs-serv26919/src/zopeproducts/demo/jobboardi18n

Modified Files:
	preview.pt edit.pt configure.zcml JobCreateView.py Job.py 
	I18nJob.py ApproveJobsView.py 
Log Message:
BasicTypes: Do not proxy zope.i18n.messageid.MessageID objects.

I'm not sure this is the 100% right thing to do, but it makes
TAL/PageTemplates work.  Otherwise we'd have to unwrap them to do
isinstance tests in zope/tales/tales.py, Context.evaluateText() and
that didn't seem like the right thing either.

Also, add ZPL header and re-organize imports.


=== zopeproducts/demo/jobboardi18n/preview.pt 1.3 => 1.4 ===
--- zopeproducts/demo/jobboardi18n/preview.pt:1.3	Tue Mar 25 16:59:55 2003
+++ zopeproducts/demo/jobboardi18n/preview.pt	Tue Apr 15 17:23:29 2003
@@ -24,11 +24,14 @@
 will contact the address you provide in the Contact field.
 </p>
 
+<p tal:condition="view/error"
+   tal:content="view/error">Error messages go here</p>
+
 <hr>
 
   <h3 tal:content="request/summary">Job summary goes here</h3>
 
-  <table border=0>
+  <table border="0">
   <tr>
       <td>
       <pre tal:content="request/description">Full descripion goes here
@@ -68,7 +71,12 @@
 	<input name="startdate" type="hidden" value=""
 	       tal:attributes="value request/startdate" />
 
-	<input type="submit" value="Submit" i18n:attributes="value=Submit" />
+	<input type="submit" name="submit" value="Submit"
+	       i18n:attributes="value Submit"
+	       tal:condition="not:view/error" />
+	
+	<input type="submit" name="edit" value="Edit"
+	       i18n:attributes="value Edit" />
 
     </form>
 


=== zopeproducts/demo/jobboardi18n/edit.pt 1.2 => 1.3 ===
--- zopeproducts/demo/jobboardi18n/edit.pt:1.2	Tue Mar 25 16:59:55 2003
+++ zopeproducts/demo/jobboardi18n/edit.pt	Tue Apr 15 17:23:29 2003
@@ -11,30 +11,36 @@
     <form action="preview.html" method="post">
     <table border=0>
     <tr><td i18n:translate="contributor-email">Contributor email:</td>
-	<td><input name="submitter" type="text" value="" size="60">
+	<td><input name="submitter" value="" size="60"
+	     tal:attributes="value request/submitter|nothing" />
 	</td>
     </tr>
     <tr><td i18n:translate="one-line-summary">One-line summary:</td>
-	<td><input name="summary" type="text" value="" size="60">
+	<td><input name="summary" value="" size="60"
+	     tal:attributes="value request/summary|nothing" />
 	</td>
     </tr>
     <tr><td i18n:translate="full-description">Full description (no HTML):</td>
 	<td><textarea name="description" cols=60 rows=10 wrap="hard"
-	    ></textarea>
+	    ><span tal:replace="request/description|nothing">Description</span>
+	    </textarea>
 	</td>
     </tr>
     <tr><td i18n:translate="contact">Contact (where to apply):</td>
-	<td><input name="contact" type="text" value="" size="60">
+	<td><input name="contact" value="" size="60"
+	     tal:attributes="value request/contact|nothing" />
 	</td>
     </tr>
     <tr><td i18n:translate="salary">Salary Range:</td>
-	<td><input name="salary" type="text" value="" size="60">
+	<td><input name="salary" value="" size="60"
+	     tal:attributes="value request/salary|nothing" />
 	</td>
     </tr>
     <tr>
 	<td><span i18n:translate="startdate">Start Date</span><br>
 	(<span tal:replace="python:request.locale.getDateFormatter('short').getPattern()" />)</td>
-	<td><input name="startdate" type="text" value="" size="60">
+	<td><input name="startdate" value="" size="60"
+	     tal:attributes="value request/startdate|nothing" />
 	</td>
     </tr>
     <tr><td colspan="2">


=== zopeproducts/demo/jobboardi18n/configure.zcml 1.11 => 1.12 ===
--- zopeproducts/demo/jobboardi18n/configure.zcml:1.11	Wed Apr  9 16:31:07 2003
+++ zopeproducts/demo/jobboardi18n/configure.zcml	Tue Apr 15 17:23:29 2003
@@ -2,7 +2,7 @@
     xmlns="http://namespaces.zope.org/zope"
     xmlns:browser="http://namespaces.zope.org/browser"
     xmlns:gts="http://namespaces.zope.org/gts"
->
+    >
 
 <content class="zopeproducts.demo.jobboard.JobList.JobList">
   <factory


=== zopeproducts/demo/jobboardi18n/JobCreateView.py 1.4 => 1.5 ===
--- zopeproducts/demo/jobboardi18n/JobCreateView.py:1.4	Tue Mar 25 16:59:55 2003
+++ zopeproducts/demo/jobboardi18n/JobCreateView.py	Tue Apr 15 17:23:29 2003
@@ -1,3 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+from zope.i18n.messageid import MessageIDFactory
+from zope.i18n.format import DateTimeParseError
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.publisher.browser import BrowserView
 
@@ -11,14 +27,25 @@
 
     thanks = ViewPageTemplateFile('thanks.pt')
 
+    error = ''
+
     def create(self, submitter='', summary='', description='',
                contact='', salary='', startdate=''):
-        
-        # Validation code should go here
-        print "startdate: ##%s##" % startdate
-        print self.request.locale.getDateFormatter('short').getPattern()
-        job = Job(submitter, summary, description, contact, salary,
-                  self.request.locale.getDateFormatter('short').parse(startdate.strip()))
-        self.context.add(job)
-        
-        return self.thanks()
+        # If they clicked the edit button, redirect back to the edit form
+        if self.request.has_key('edit'):
+            return self.edit()
+        # Otherwise they clicked the submit button
+        _ = MessageIDFactory('jobboard')
+        # XXX Really, validation code should happen before the job is
+        # previewed, so that it can be re-edited if it's bad.
+        fmt = self.request.locale.getDateFormatter('short')
+        try:
+            date = fmt.parse(startdate.strip())
+        except DateTimeParseError:
+            self.error = _('Bad date string: $date')
+            self.error.mapping['date'] = startdate
+            return self.preview()
+        else:
+            job = Job(submitter, summary, description, contact, salary, date)
+            self.context.add(job)
+            return self.thanks()


=== zopeproducts/demo/jobboardi18n/Job.py 1.5 => 1.6 ===
--- zopeproducts/demo/jobboardi18n/Job.py:1.5	Wed Apr  9 14:41:10 2003
+++ zopeproducts/demo/jobboardi18n/Job.py	Tue Apr 15 17:23:29 2003
@@ -1,6 +1,20 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
 from persistence import Persistent
 
-from I18nJob import I18nJob
+from zopeproducts.demo.jobboardi18n.I18nJob import I18nJob
 from zopeproducts.demo.jobboard.IJob import JobState
 
 class Job(Persistent):


=== zopeproducts/demo/jobboardi18n/I18nJob.py 1.2 => 1.3 ===
--- zopeproducts/demo/jobboardi18n/I18nJob.py:1.2	Wed Apr  9 14:43:08 2003
+++ zopeproducts/demo/jobboardi18n/I18nJob.py	Tue Apr 15 17:23:29 2003
@@ -1,6 +1,18 @@
-"""
-IJob.py
-"""
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+"""IJob.py"""
 
 from zope.interface import Attribute
 from zopeproducts.demo.jobboard.IJob import IJob
@@ -10,5 +22,6 @@
 
     salary = Attribute("salary",
                        "Salary range offered for the job.")
+
     startdate = Attribute("start date",
-                           "Job start date")
+                          "Job start date")


=== zopeproducts/demo/jobboardi18n/ApproveJobsView.py 1.3 => 1.4 ===
--- zopeproducts/demo/jobboardi18n/ApproveJobsView.py:1.3	Thu Mar 20 16:03:05 2003
+++ zopeproducts/demo/jobboardi18n/ApproveJobsView.py	Tue Apr 15 17:23:29 2003
@@ -1,3 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.publisher.browser import BrowserView
 
@@ -9,12 +23,7 @@
         form = self.request.form
 
         for jobid in form:
-            try:
-                job = self.context[jobid]
-            except KeyError:
-                raise
-            except:
-                continue
+            job = self.context[jobid]
 
             action = form[jobid]
             if action == 'approve':