[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Publisher/Browser - browser-meta.zcml:1.1.2.2 metaConfigure.py:1.1.2.2
Jim Fulton
jim@zope.com
Sun, 2 Jun 2002 10:35:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Publisher/Browser
In directory cvs.zope.org:/tmp/cvs-serv29793/lib/python/Zope/App/Publisher/Browser
Modified Files:
Tag: Zope3InWonderland-branch
browser-meta.zcml metaConfigure.py
Log Message:
- Added template attribute to allow views to be created from a
template source file.
- Added beginnings of a Zope debugger. This required seperating site
and server configuration.
- Added the ability to specify a config file package in the
zopeConfigure directive. Made "config.zcml" a default for the file
attribute in the include directive.
- Fixed mapply to unwrap proxied objects. This was necessary once
views became wrapped in proxies. We need to investigate why they
weren't being wrapped before.
- I updated enough system page templates and zcml directives so that:
- Zope now starts. :)
- The root folder contents listing can be viewed.
Many more templates and zcml files need to be updated to reflect the
way views are now handled.
=== Zope3/lib/python/Zope/App/Publisher/Browser/browser-meta.zcml 1.1.2.1 => 1.1.2.2 ===
<directive
name="view"
- attributes="component, name, for, layer,
- permission_id, allowed_interface, allowed_attributes"
+ attributes="factory name for layer template
+ permission_id allowed_interface allowed_attributes"
handler="Zope.App.Publisher.Browser.metaConfigure.view" >
<subdirective name="page"
attributes="name attribute permission_id layer"
@@ -17,13 +17,14 @@
<directive
name="defaultView"
- attributes="component, name, for, layer"
+ attributes="factory name for layer template
+ permission_id allowed_interface allowed_attributes"
handler="Zope.App.Publisher.Browser.metaConfigure.defaultView" />
<directive
name="resource"
- attributes="component, name, layer,
- permission_id, allowed_interface, allowed_attributes"
+ attributes="factory name layer
+ permission_id allowed_interface allowed_attributes"
handler="Zope.App.Publisher.Browser.metaConfigure.resource">
<subdirective name="page"
attributes="name attribute permission_id layer"
=== Zope3/lib/python/Zope/App/Publisher/Browser/metaConfigure.py 1.1.2.1 => 1.1.2.2 ===
import defaultView as _defaultView, skin as _skin, handler
-def defaultView(_context, **__kw):
- return _defaultView(_context,
- type='Zope.Publisher.Browser.IBrowserPresentation.',
- **__kw)
+from Zope.App.PageTemplate.SimpleViewClass import SimpleViewClass
+
def skin(_context, **__kw):
return _skin(_context,
type='Zope.Publisher.Browser.IBrowserPresentation.',
**__kw)
-class resource:
+class resource(object):
type = IBrowserPresentation
@@ -125,24 +123,20 @@
if permission_id == 'Zope.Public':
permission_id = CheckerPublic
- if (not allowed_attributes) and (allowed_interface is None):
- if not self.pages:
- raise ConfigurationError(
- "Must specify allowed_interface or allowed_names "
- "to be allowed with permission_id.")
-
- else:
-
- require={}
- for name in (allowed_attributes or '').split():
+ if ((not allowed_attributes) and (allowed_interface is None)
+ and (not self.pages)):
+ allowed_attributes = "__call__"
+
+ require={}
+ for name in (allowed_attributes or '').split():
+ require[name] = permission_id
+ if allowed_interface:
+ for name in allowed_interface.names(1):
require[name] = permission_id
- if allowed_interface:
- for name in allowed_interface.names(1):
- require[name] = permission_id
- checker = Checker(require.get)
+ checker = Checker(require.get)
- factory = self._proxyFactory(factory, checker)
+ factory = self._proxyFactory(factory, checker)
return [
@@ -162,33 +156,49 @@
class view(resource):
- def __init__(self, _context, factory, name=None, for_=None,
+ def __init__(self, _context, factory=None, name=None, for_=None,
layer='',
permission_id=None,
- allowed_interface=None, allowed_attributes=None):
-
- resource.__init__(self, _context, factory, name, layer,
- permission_id, allowed_interface, allowed_attributes)
+ allowed_interface=None, allowed_attributes=None,
+ template=None):
+ if template:
+ if not name:
+ raise ConfigurationError(
+ "Must specify name for template view")
+ self.template = template
if for_ is not None:
for_ = _context.resolve(for_)
self.for_ = for_
+
+ resource.__init__(self, _context, factory, name, layer,
+ permission_id, allowed_interface, allowed_attributes)
- def defaultPage(self, _context, name, attribute, permission_id=None):
- actions = self.page(_context, name, attribute, permission_id)
+ def page(self, _context, name, attribute, permission_id=None, layer=None):
+ if self.template:
+ raise ConfigurationError(
+ "Can't use page or defaultPage subdirectives for simple "
+ "template views")
+ return super(view, self).page(
+ _context, name, attribute, permission_id, layer)
- actions += [Action(
- discriminator = ('defaultViewName', self.for_, name, self.type),
- callable = handler,
- args = ('Views','setDefaultViewName', self.for_, self.type, name),
- )]
+ def _factory(self, _context, factory):
- return actions
+ if self.template:
+
+ if factory:
+ raise ConfigurationError(
+ "Can't specify factory and template")
+
+ return [SimpleViewClass(
+ str(_context.path(self.template)),
+ used_for = self.for_
+ )]
- def _factory(self, _context, factory):
- return map(_context.resolve, factory.strip().split())
+ else:
+ return map(_context.resolve, factory.strip().split())
def _discriminator(self, name, layer):
return ('view', self.for_, name, self.type, layer)
@@ -232,3 +242,24 @@
factory[-1] = proxyView
return factory
+
+
+def defaultView(_context, name, for_=None, **__kw):
+
+ if __kw:
+ actions = view(_context, name=name, for_=for_, **__kw)()
+ else:
+ actions = []
+
+ if for_ is not None:
+ for_ = _context.resolve(for_)
+
+ type = IBrowserPresentation
+
+ actions += [Action(
+ discriminator = ('defaultViewName', for_, type, name),
+ callable = handler,
+ args = ('Views','setDefaultViewName', for_, type, name),
+ )]
+
+ return actions