Skip to content

Commit

Permalink
Switch out makeClass for type and makeClassForTemplate for SimpleView…
Browse files Browse the repository at this point in the history
…Class for Zope trunk compatibility, with fallback to makeClassForTemplate for Zope 2.13.
  • Loading branch information
lrowe committed Sep 4, 2012
1 parent 972c59b commit b5fee3a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/five/formlib/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
from zope.browsermenu.metaconfigure import menuItemDirective
from zope.publisher.interfaces.browser import IDefaultBrowserLayer

from Products.Five.metaclass import makeClass
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Products.Five.browser.metaconfigure import makeClassForTemplate

try:
from Products.Five.browser.metaconfigure import SimpleViewClass
except ImportError:
# Zope < 4
from Products.Five.browser.metaconfigure import makeClassForTemplate as SimpleViewClass
from five.formlib import EditView, AddView

_ = MessageFactory('zope')
Expand All @@ -37,7 +39,7 @@
def EditViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_, fields,
fulledit_path=None, fulledit_label=None, menu=u''):
class_ = makeClassForTemplate(template, globals(), used_for=schema,
class_ = SimpleViewClass(template, globals(), used_for=schema,
bases=bases)
class_.schema = schema
class_.label = label
Expand Down Expand Up @@ -67,7 +69,7 @@ class FiveFormDirective(BaseFormDirective):

def _processWidgets(self):
if self._widgets:
customWidgetsObject = makeClass(
customWidgetsObject = type(
'CustomWidgetsMixin', (Base,), self._widgets)
self.bases = self.bases + (customWidgetsObject,)

Expand Down Expand Up @@ -100,7 +102,7 @@ def AddViewFactory(name, schema, label, permission, layer,
fields, content_factory, arguments,
keyword_arguments, set_before_add, set_after_add,
menu=u''):
class_ = makeClassForTemplate(template, globals(), used_for=schema,
class_ = SimpleViewClass(template, globals(), used_for=schema,
bases=bases)

class_.schema = schema
Expand Down

0 comments on commit b5fee3a

Please sign in to comment.