-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up zope.app for new location of zope.traversing.
(also sneaked in some minor cosmetics regarding zapi/ztapi)
- Loading branch information
Showing
3 changed files
with
149 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<zope:configure | ||
xmlns:zope="http://namespaces.zope.org/zope" | ||
xmlns="http://namespaces.zope.org/browser"> | ||
|
||
<tool | ||
interface="zope.app.schema.interfaces.ISchemaUtility" | ||
title="Persistent, Local Schemas" | ||
description="These are schemas that live in the ZODB and are modifiable." | ||
/> | ||
|
||
<menu | ||
id="add_schema_field" | ||
title="Menu of Fields to be added to a schema." /> | ||
|
||
<view | ||
name="+" | ||
for="zope.app.schema.interfaces.IMutableSchema" | ||
class="zope.app.schema.schema.SchemaAdding" | ||
permission="zope.ManageContent" | ||
allowed_attributes="addingInfo" | ||
menu="zmi_actions" title="Add"> | ||
|
||
<page name="index.html" template="schema_add.pt" /> | ||
<page name="action.html" attribute="action" /> | ||
|
||
</view> | ||
|
||
<addMenuItem | ||
title="Mutable Schema" | ||
description="A Persistent Schema that can be edited through the web" | ||
class="zope.app.schema.schema.SchemaUtility" | ||
permission="zope.ManageServices" | ||
/> | ||
|
||
<defaultView | ||
for="zope.app.schema.interfaces.IMutableSchema" | ||
name="editschema.html" /> | ||
|
||
<page | ||
name="editschema.html" | ||
menu="zmi_views" title="Edit Schema" | ||
for="zope.app.schema.interfaces.IMutableSchema" | ||
permission="zope.ManageServices" | ||
class=".EditSchema" | ||
attribute="edit" | ||
/> | ||
|
||
<!-- Register a browser-specific traverser --> | ||
|
||
<zope:view | ||
for="zope.app.schema.interfaces.IMutableSchema" | ||
type="zope.publisher.interfaces.browser.IBrowserRequest" | ||
provides="zope.publisher.interfaces.browser.IBrowserPublisher" | ||
factory=".traversal.SchemaFieldTraverser" | ||
permission="zope.Public" | ||
/> | ||
|
||
<zope:adapter | ||
factory=".traversal.SchemaFieldTraversable" | ||
provides="zope.traversing.interfaces.ITraversable" | ||
for="zope.app.schema.interfaces.IMutableSchema" /> | ||
|
||
</zope:configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
############################################################################## | ||
# Copyright (c) 2003 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (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. | ||
############################################################################## | ||
"""Specific HTTP Traverser | ||
$Id$ | ||
""" | ||
from zope.interface import implements | ||
from zope.publisher.interfaces.browser import IBrowserPublisher | ||
from zope.publisher.interfaces import NotFound | ||
from zope.traversing.interfaces import TraversalError, ITraversable | ||
from zope.traversing.namespace import UnexpectedParameters | ||
|
||
from zope.app import zapi | ||
from zope.app.location.interfaces import ILocation | ||
from zope.app.schema.interfaces import IMutableSchema | ||
|
||
_marker = object() | ||
|
||
class SchemaFieldTraverser(object): | ||
implements(IBrowserPublisher) | ||
__used_for__ = IMutableSchema | ||
|
||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
|
||
def publishTraverse(self, request, name): | ||
subob = self.context.get(name, None) | ||
|
||
if subob is None: | ||
|
||
view = zapi.queryMultiAdapter((self.context, request), name=name) | ||
if view is not None: | ||
if ILocation.providedBy(view): | ||
view.__parent__ = self.context | ||
view.__name__ = name | ||
|
||
return view | ||
|
||
raise NotFound(self.context, name, request) | ||
|
||
return subob | ||
|
||
def browserDefault(self, request): | ||
c = self.context | ||
view_name = zapi.getDefaultViewName(c, request) | ||
view_uri = "@@%s" % view_name | ||
return c, (view_uri,) | ||
|
||
class SchemaFieldTraversable(object): | ||
"""Traverses Schema Fields. | ||
""" | ||
|
||
implements(ITraversable) | ||
__used_for__ = IMutableSchema | ||
|
||
def __init__(self, context): | ||
self._context = context | ||
|
||
def traverse(self, name, furtherPath): | ||
subobj = self._context.get(name, _marker) | ||
if subobj is _marker: | ||
raise TraversalError(name) | ||
|
||
return subobj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters