[Checkins] SVN: grok/branches/grokcore.xxx/src/grok/ Use formlib stuff from grokcore.formlib. Haven't removed any duplicate tests yet.

Philipp von Weitershausen philikon at philikon.de
Tue Jul 29 18:53:21 EDT 2008


Log message for revision 89009:
  Use formlib stuff from grokcore.formlib. Haven't removed any duplicate tests yet.
  

Changed:
  U   grok/branches/grokcore.xxx/src/grok/__init__.py
  U   grok/branches/grokcore.xxx/src/grok/components.py
  U   grok/branches/grokcore.xxx/src/grok/meta.zcml
  U   grok/branches/grokcore.xxx/src/grok/testing.py

-=-
Modified: grok/branches/grokcore.xxx/src/grok/__init__.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/__init__.py	2008-07-29 22:50:31 UTC (rev 89008)
+++ grok/branches/grokcore.xxx/src/grok/__init__.py	2008-07-29 22:53:21 UTC (rev 89009)
@@ -17,7 +17,7 @@
 from grokcore.component import *
 from grokcore.security import *
 from grokcore.view import *
-from grokcore.view.formlib import action, AutoFields, Fields
+from grokcore.formlib import *
 
 from zope.event import notify
 from zope.app.component.hooks import getSite
@@ -39,7 +39,7 @@
 from grok.components import Traverser
 from grok.components import Container, OrderedContainer
 from grok.components import Site, LocalUtility, Annotation
-from grok.components import Application, Form, AddForm, EditForm, DisplayForm
+from grok.components import Application
 from grok.components import Indexes
 from grok.components import Role
 from grok.components import RESTProtocol, IRESTLayer

Modified: grok/branches/grokcore.xxx/src/grok/components.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/components.py	2008-07-29 22:50:31 UTC (rev 89008)
+++ grok/branches/grokcore.xxx/src/grok/components.py	2008-07-29 22:53:21 UTC (rev 89009)
@@ -52,8 +52,6 @@
 import martian.util
 
 from grok import interfaces, util
-from grokcore.view import formlib
-from grokcore.view import GrokForm
 from grokcore.view import PageTemplateFile
 
 
@@ -263,83 +261,6 @@
         return self.context.get(name)
 
 
-default_form_template = PageTemplateFile(os.path.join(
-    'templates', 'default_edit_form.pt'))
-default_form_template.__grok_name__ = 'default_edit_form'
-default_display_template = PageTemplateFile(os.path.join(
-    'templates', 'default_display_form.pt'))
-default_display_template.__grok_name__ = 'default_display_form'
-
-class Form(GrokForm, form.FormBase, View):
-    # We're only reusing the form implementation from zope.formlib, we
-    # explicitly don't want to inherit the interface semantics (mostly
-    # for the different meanings of update/render).
-    interface.implementsOnly(interfaces.IGrokForm)
-
-    template = default_form_template
-
-    def applyData(self, obj, **data):
-        return formlib.apply_data_event(obj, self.form_fields, data,
-                                        self.adapters)
-
-    # BBB -- to be removed in June 2007
-    def applyChanges(self, obj, **data):
-        warnings.warn("The 'applyChanges' method on forms is deprecated "
-                      "and will disappear by June 2007. Please use "
-                      "'applyData' instead.", DeprecationWarning, 2)
-        return bool(self.applyData(obj, **data))
-
-
-class AddForm(Form):
-    pass
-
-
-class EditForm(GrokForm, form.EditFormBase, View):
-    # We're only reusing the form implementation from zope.formlib, we
-    # explicitly don't want to inherit the interface semantics (mostly
-    # for the different meanings of update/render).
-    interface.implementsOnly(interfaces.IGrokForm)
-
-    template = default_form_template
-
-    def applyData(self, obj, **data):
-        return formlib.apply_data_event(obj, self.form_fields, data,
-                                        self.adapters, update=True)
-
-    # BBB -- to be removed in June 2007
-    def applyChanges(self, obj, **data):
-        warnings.warn("The 'applyChanges' method on forms is deprecated "
-                      "and will disappear by June 2007. Please use "
-                      "'applyData' instead.", DeprecationWarning, 2)
-        return bool(self.applyData(obj, **data))
-
-    @formlib.action("Apply")
-    def handle_edit_action(self, **data):
-        if self.applyData(self.context, **data):
-            formatter = self.request.locale.dates.getFormatter(
-                'dateTime', 'medium')
-
-            try:
-                time_zone = idatetime.ITZInfo(self.request)
-            except TypeError:
-                time_zone = pytz.UTC
-
-            self.status = "Updated on %s" % formatter.format(
-                datetime.datetime.now(time_zone)
-                )
-        else:
-            self.status = 'No changes'
-
-
-class DisplayForm(GrokForm, form.DisplayFormBase, View):
-    # We're only reusing the form implementation from zope.formlib, we
-    # explicitly don't want to inherit the interface semantics (mostly
-    # for the different meanings of update/render).
-    interface.implementsOnly(interfaces.IGrokForm)
-
-    template = default_display_template
-
-
 class IndexesClass(object):
     def __init__(self, name, bases=(), attrs=None):
         if attrs is None:

Modified: grok/branches/grokcore.xxx/src/grok/meta.zcml
===================================================================
--- grok/branches/grokcore.xxx/src/grok/meta.zcml	2008-07-29 22:50:31 UTC (rev 89008)
+++ grok/branches/grokcore.xxx/src/grok/meta.zcml	2008-07-29 22:53:21 UTC (rev 89009)
@@ -9,6 +9,7 @@
   <include package="grokcore.component" file="meta.zcml" />
   <include package="grokcore.security" file="meta.zcml" />
   <include package="grokcore.view" file="meta.zcml" />
+  <include package="grokcore.formlib" file="meta.zcml" />
   <grok:grok package=".meta" />
 
 </configure>

Modified: grok/branches/grokcore.xxx/src/grok/testing.py
===================================================================
--- grok/branches/grokcore.xxx/src/grok/testing.py	2008-07-29 22:50:31 UTC (rev 89008)
+++ grok/branches/grokcore.xxx/src/grok/testing.py	2008-07-29 22:53:21 UTC (rev 89009)
@@ -44,6 +44,7 @@
     zcml.do_grok('grokcore.component.meta', config)
     zcml.do_grok('grokcore.security.meta', config)
     zcml.do_grok('grokcore.view.meta', config)
+    zcml.do_grok('grokcore.formlib.meta', config)
     zcml.do_grok('grok.meta', config)
     zcml.do_grok('grokcore.view.templatereg', config)
     zcml.do_grok(module_name, config)



More information about the Checkins mailing list