[Zope3-checkins] CVS: Zope3/src/zope/app/utilities - traversal.py:1.1.2.1 configure.zcml:1.1.2.2 edit.pt:1.1.2.2

Sidnei da Silva sidnei at x3ng.com.br
Tue Aug 12 11:31:36 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/utilities
In directory cvs.zope.org:/tmp/cvs-serv2140/src/zope/app/utilities

Modified Files:
      Tag: dreamcatcher-ttwschema-branch
	configure.zcml edit.pt 
Added Files:
      Tag: dreamcatcher-ttwschema-branch
	traversal.py 
Log Message:
Made fields editable, traversable and introspectable

=== Added File Zope3/src/zope/app/utilities/traversal.py ===
##############################################################################
# Copyright (c) 2003 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.
##############################################################################
"""Specific HTTP

$Id: traversal.py,v 1.1.2.1 2003/08/12 14:31:29 sidnei Exp $
"""
from zope.interface import implements
from zope.component import getDefaultViewName, queryView
from zope.publisher.interfaces import IPublishTraverse
from zope.app.interfaces.utilities import IMutableSchema

from zope.exceptions import NotFoundError
from zope.app.traversing import getParent

from zope.proxy import removeAllProxies
from zope.app.context import ContextWrapper

from zope.app.interfaces.traversing import ITraversable
from zope.app.traversing.namespace import UnexpectedParameters

_marker = object()

class SchemaFieldTraverser:

    implements(IPublishTraverse)
    __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)

        # XXX: Check that subobj has self.context as parent!
        if subob is None:

            view = queryView(self.context, name, request)
            if view is not None:
                return view

            raise NotFoundError(self.context, name, request)

        subob = removeAllProxies(subob)
        return ContextWrapper(subob, self.context, name=name)

    def browserDefault(self, request):
        c = self.context
        view_name = getDefaultViewName(c, request)
        view_uri = "@@%s" % view_name
        return c, (view_uri,)

class SchemaFieldTraversable:
    """Traverses Schema Fields.
    """

    implements(ITraversable)
    __used_for__ = IMutableSchema

    def __init__(self, context):
        self._context = context

    def traverse(self, name, parameters, original_name, furtherPath):
        if parameters:
            raise UnexpectedParameters(parameters)

        subobj = self._context.get(name, _marker)
        if subobj is _marker:
            raise NotFoundError, original_name

        return subobj


=== Zope3/src/zope/app/utilities/configure.zcml 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/utilities/configure.zcml:1.1.2.1	Tue Aug 12 09:19:27 2003
+++ Zope3/src/zope/app/utilities/configure.zcml	Tue Aug 12 10:31:28 2003
@@ -47,7 +47,6 @@
 
   </content>
 
-
   <!-- Menu entry for "add component" menu -->
   <browser:menuItem
       for="zope.app.interfaces.container.IAdding"
@@ -68,6 +67,11 @@
       permission="zope.ManageServices"
       />
 
+
+  <browser:defaultView
+      for="zope.app.interfaces.utilities.IMutableSchema" 
+      name="editschema.html" />
+
   <browser:page
       name="editschema.html"
       menu="zmi_views" title="Edit Schema"
@@ -113,5 +117,18 @@
      title="Set Schema"
      permission="zope.ManageContent"
    />
+
+  <adapter
+      factory=".traversal.SchemaFieldTraversable"
+      provides="zope.app.interfaces.traversing.ITraversable"
+      for="zope.app.interfaces.utilities.IMutableSchema" />
+
+  <!-- Register a browser-specific traverser -->
+
+  <browser:page
+      name="_traverse"
+      for="zope.app.interfaces.utilities.IMutableSchema"
+      class=".traversal.SchemaFieldTraverser"
+      permission="zope.Public" />
 
 </configure>


=== Zope3/src/zope/app/utilities/edit.pt 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/utilities/edit.pt:1.1.2.1	Tue Aug 12 09:19:27 2003
+++ Zope3/src/zope/app/utilities/edit.pt	Tue Aug 12 10:31:29 2003
@@ -43,7 +43,7 @@
                      value=""
                      tal:attributes="value row/name" /></td>
           <td><a href="#"
-                 tal:attributes="href string:${request/URL/-1}/${row/name}"
+                 tal:attributes="href string:${request/URL/-1}/${row/name}/@@edit.html"
                  tal:content="row/name">Name</a></td>
           <td tal:content="row/type">Type</td>
           <tal:block define="field row/field">




More information about the Zope3-Checkins mailing list