[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/ Ripped out Persistent code support

Jim Fulton jim at zope.com
Thu Jun 3 15:47:08 EDT 2004


Log message for revision 25241:
Ripped out Persistent code support

It's not ready for production.  This includes
persistent modules, interfaces, and schema.



-=-
Deleted: Zope3/branches/ZopeX3-3.0/package-includes/zope.app.module.fssync-configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/package-includes/zope.app.module.fssync-configure.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/package-includes/zope.app.module.fssync-configure.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1 +0,0 @@
-<include package="zope.app.module.fssync" />

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/DEPENDENCIES.cfg
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/DEPENDENCIES.cfg	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/DEPENDENCIES.cfg	2004-06-03 19:47:08 UTC (rev 25241)
@@ -3,7 +3,6 @@
 persistent
 transaction
 zdaemon
-zodbcode
 zope.cachedescriptors
 zope.component
 zope.configuration

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/PACKAGE.cfg
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/PACKAGE.cfg	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/PACKAGE.cfg	2004-06-03 19:47:08 UTC (rev 25241)
@@ -66,7 +66,6 @@
 # XXX used by zope.app.utility.browser
 introspector
 location
-module
 observable
 pagetemplate
 pluggableauth

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -55,12 +55,6 @@
   <include package="zope.app.utility" />  
   <include package="zope.app.principalannotation" />  
 
-  <!-- Utilities -->
-  <include package="zope.app.schema" />
-
-  <!-- Misc. Service Manager objects -->
-  <include package="zope.app.module" />
-
   <!-- Broken-object support -->
   <include package="zope.app.broken" />
 

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -17,47 +17,8 @@
 
 $Id$
 """
-from persistent import Persistent
-from persistent.dict import PersistentDict
-from zodbcode.patch import registerWrapper, Wrapper
-from zope.interface.interface import InterfaceClass
-from zope.interface import Interface
 from zope.proxy import removeAllProxies
 
-class PersistentInterfaceClass(Persistent, InterfaceClass):
-
-    def __init__(self, *args, **kw):
-        Persistent.__init__(self)
-        InterfaceClass.__init__(self, *args, **kw)
-
-        self.dependents = PersistentDict()
-
-# PersistentInterface is equivalent to the zope.interface.Interface object
-# except that it is also persistent.  It is used in conjunction with
-# zodb.code to support interfaces in persistent modules.
-PersistentInterface = PersistentInterfaceClass("PersistentInterface",
-                                               (Interface, ))
-
-class PersistentInterfaceWrapper(Wrapper):
-
-    def unwrap(self):
-        return PersistentInterfaceClass(self._obj.__name__)
-
-
-def getInterfaceStateForPersistentInterfaceCreation(iface):
-    # Need to convert the dependents weakref dict to a persistent dict
-    dict = iface.__dict__.copy()
-    dependents = PersistentDict()
-    for k, v in dict['dependents'].iteritems():
-        dependents[k] = v
-    dict['dependents'] = dependents
-    return dict
-
-registerWrapper(InterfaceClass, PersistentInterfaceWrapper,
-                lambda iface: (),
-                getInterfaceStateForPersistentInterfaceCreation,
-                )
-
 from zope.interface.declarations import providedBy
 
 def queryType(object, interface):

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/interface/tests/test_interface.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/interface/tests/test_interface.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/interface/tests/test_interface.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,77 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Interface Service Tests
-
-$Id$
-"""
-import unittest
-
-from transaction import get_transaction
-
-from ZODB.tests.util import DB
-from zodbcode.module import ManagedRegistry
-
-from zope.interface import Interface, implements
-from zope.app.interface import PersistentInterface
-
-# XXX for some reason changing this code to use implements() does not work
-code = """\
-from zope.interface import Interface
-
-class IFoo(Interface):
-    pass
-
-class Foo:
-    __implemented__ = IFoo
-
-aFoo = Foo()
-"""
-
-class PersistentInterfaceTest(unittest.TestCase):
-
-    def setUp(self):
-        self.db = DB()
-        self.root = self.db.open().root()
-        self.registry = ManagedRegistry()
-        self.root["registry"] = self.registry
-        get_transaction().commit()
-
-    def tearDown(self):
-        get_transaction().abort() # just in case
-
-    def test_creation(self):
-        class IFoo(PersistentInterface):
-            pass
-
-        class Foo:
-            implements(IFoo)
-
-        self.assert_(IFoo.providedBy(Foo()))
-        self.assertEqual(IFoo._p_oid, None)
-
-    def test_patch(self):
-        self.registry.newModule("imodule", code)
-        get_transaction().commit()
-        imodule = self.registry.findModule("imodule")
-
-        # test for a pickling bug
-        self.assertEqual(imodule.Foo.__implemented__, imodule.IFoo)
-
-        self.assert_(imodule.IFoo.providedBy(imodule.aFoo))
-        # the conversion should not affect Interface
-        self.assert_(imodule.Interface is Interface)
-
-
-def test_suite():
-    return unittest.makeSuite(PersistentInterfaceTest)

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -17,7 +17,6 @@
 """
 from zope.interface import Interface
 from zope.app.introspector.interfaces import IIntrospector
-from zope.app.module.interfaces import IModuleService
 from zope.component import getService, getServiceDefinitions, getServices
 from zope.proxy import removeAllProxies
 from zope.interface import implements, implementedBy
@@ -53,8 +52,7 @@
             if (self.context == Interface and
                 name != 'Interface._Interface.Interface'):
                 servicemanager = getServices()
-                adapter = IModuleService(servicemanager)
-                self.currentclass = adapter.resolve(name)
+                self.currentclass = servicemanager.resolve(name)
                 self.context = self.currentclass
             else:
                 self.currentclass = self.context

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/registration/registration.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/registration/registration.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/registration/registration.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -32,7 +32,6 @@
 from zope.app.dependable.interfaces import IDependable, DependencyError
 from zope.app.component.localservice import getLocalServices
 from zope.app.location import inside
-from zope.app.module.interfaces import IModuleManager
 from zope.app.registration import interfaces
 
 class RegistrationStatusProperty(object):
@@ -847,21 +846,6 @@
     def findModule(self, name):
         # Used by the persistent modules import hook
 
-        # Look for a .py file first:
-        manager = self.get(name+'.py')
-        if manager is not None:
-            # found an item with that name, make sure it's a module(manager):
-            if IModuleManager.providedBy(manager):
-                return manager.getModule()
-
-        # Look for the module in this folder:
-        manager = self.get(name)
-        if manager is not None:
-            # found an item with that name, make sure it's a module(manager):
-            if IModuleManager.providedBy(manager):
-                return manager.getModule()
-
-
         # See if out container is a RegisterableContainer:
         c = self.__parent__
         if interfaces.IRegisterableContainer.providedBy(c):

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/configure.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/configure.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,37 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-  <content class=".schema.SchemaUtility">
-
-    <factory
-        title="Mutable Schema"
-        description="A Persistent Schema that can be edited through the web"/>
-
-    <implements
-        interface="zope.app.utility.interfaces.ILocalUtility" />
-
-    <implements
-        interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
-
-    <require
-        permission="zope.ManageServices"
-        interface=".interfaces.IMutableSchema" />
-
-    <require
-        permission="zope.ManageServices"
-        interface=".interfaces.ISchemaUtility"
-        set_schema=".interfaces.ISchemaUtility" />
-
-  </content>
-
-  <content class=".schema.SchemaRegistration">
-    <require
-      permission="zope.ManageServices"
-      interface="zope.app.utility.interfaces.IUtilityRegistration"
-      set_schema="zope.app.utility.interfaces.IUtilityRegistration" />
-  </content>
-
-  <include file="fields.zcml" />
-  <include package=".browser" />
-  <include file="fieldforms.zcml" />
-
-</configure>

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fieldforms.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fieldforms.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fieldforms.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,163 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
-           xmlns:browser="http://namespaces.zope.org/browser">
-
-  <!-- Define add and edit forms for fields as part of a (persistent)
-       schema -->
-
-  <browser:addform
-      label="Add Text Field"
-      name="Text Field"
-      menu="add_schema_field"
-      title="Text Field"
-      description="A Text Field"
-      content_factory="zope.schema.Text"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.IText"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default min_length max_length"
-    />
-
-  <browser:editform
-      label="Edit Text Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.IText"
-      schema="zope.schema.interfaces.IText"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default min_length max_length"
-    />
-
-  <browser:addform
-      label="Add TextLine Field"
-      name="TextLine Field"
-      menu="add_schema_field"
-      title="TextLine Field"
-      description="A TextLine Field"
-      content_factory="zope.schema.TextLine"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.ITextLine"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default min_length max_length"
-    />
-
-  <browser:editform
-      label="Edit TextLine Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.ITextLine"
-      schema="zope.schema.interfaces.ITextLine"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default min_length max_length"
-    />
-
-  <browser:addform
-      label="Add Boolean Field"
-      name="Boolean Field"
-      menu="add_schema_field"
-      title="Boolean Field"
-      description="A Boolean Field"
-      content_factory="zope.schema.Bool"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.IBool"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default"
-    />
-
-  <browser:editform
-      label="Edit Boolean Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.IBool"
-      schema="zope.schema.interfaces.IBool"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default"
-    />
-
-  <browser:addform
-      label="Add Integer Field"
-      name="Integer Field"
-      menu="add_schema_field"
-      title="Integer Field"
-      description="An Integer Field"
-      content_factory="zope.schema.Int"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.IInt"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-  <browser:editform
-      label="Edit Integer Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.IInt"
-      schema="zope.schema.interfaces.IInt"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-  <browser:addform
-      label="Add Float Field"
-      name="Float Field"
-      menu="add_schema_field"
-      title="Float Field"
-      description="A Float Field"
-      content_factory="zope.schema.Float"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.IFloat"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-  <browser:editform
-      label="Edit Float Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.IFloat"
-      schema="zope.schema.interfaces.IFloat"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-  <browser:addform
-      label="Add Datetime Field"
-      name="Datetime Field"
-      menu="add_schema_field"
-      title="Datetime Field"
-      description="A Datetime Field"
-      content_factory="zope.schema.Datetime"
-      for=".interfaces.ISchemaAdding"
-      schema="zope.schema.interfaces.IDatetime"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-  <browser:editform
-      label="Edit Datetime Field"
-      name="edit.html"
-      menu="zmi_views"
-      title="Edit"
-      for="zope.schema.interfaces.IDatetime"
-      schema="zope.schema.interfaces.IDatetime"
-      permission="zope.ManageContent"
-      fields="title description required readonly
-              default max min"
-    />
-
-</configure>
\ No newline at end of file

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fields.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fields.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/fields.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,311 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-  <content class="zope.schema.Field">
-
-    <factory
-        id="zope.schema.Field"
-	title="Basic Field"
-	description="Basic Field" />
-
-    <implements interface="zope.interface.interfaces.IAttribute" />
-
-    <!--
-    <require
-	permission="zope.View"
-	interface="zope.schema.interfaces.IField"
-	/>
-
-    <require
-	permission="zope.ManageContent"
-	attributes="bind set"
-	/>
-    -->
-
-    <allow attributes="__name__" />
-
-    <!-- XXX put the whole interface under one permission for now -->
-
-    <require
-	permission="zope.ManageContent"
-	interface="zope.schema.interfaces.IField"
-	set_schema="zope.schema.interfaces.IField"
-	/>
-
-  </content>
-
-  <content class="zope.schema.Container">
-
-    <factory
-        id="zope.schema.Container"
-	title="Container Field"
-	description="Container Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Iterable">
-
-    <factory
-        id="zope.schema.Iterable"
-	title="Iterable Field"
-	description="Iterable Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Orderable">
-
-    <factory
-        id="zope.schema.Orderable"
-	title="Orderable Field"
-	description="Orderable Field" />
-
-    <require
-	permission="zope.ManageContent"
-	interface="zope.schema.interfaces.IMinMax"
-	set_schema="zope.schema.interfaces.IMinMax"
-	/>
-
-  </content>
-
-  <content class="zope.schema.MinMaxLen">
-
-    <factory
-        id="zope.schema.MinMaxLen"
-	title="MinMaxLen Field"
-	description="MinMaxLen Field" />
-
-    <require
-	permission="zope.ManageContent"
-	interface="zope.schema.interfaces.IMinMaxLen"
-	set_schema="zope.schema.interfaces.IMinMaxLen"
-	/>
-
-  </content>
-
-  <content class="zope.schema.Bytes">
-
-    <factory
-	id="zope.schema.Bytes"
-	title="Bytes Field"
-	description="Bytes Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.BytesLine">
-
-    <factory
-	id="zope.schema.BytesLine"
-	title="BytesLine Field"
-	description="BytesLine Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Text">
-
-    <factory
-	id="zope.schema.Text"
-	title="Text Field"
-	description="Text Field" />
-
-    <implements interface="zope.schema.interfaces.IFromUnicode" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.TextLine">
-
-    <factory
-	id="zope.schema.TextLine"
-	title="Text Line Field"
-	description="Text Line Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Bool">
-
-    <factory
-	id="zope.schema.Bool"
-	title="Boolean Field"
-	description="Boolean Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Int">
-
-    <factory
-	id="zope.schema.Int"
-	title="Integer Field"
-	description="Integer Field" />
-
-    <require like_class="zope.schema.Orderable" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Float">
-
-    <factory
-	id="zope.schema.Float"
-	title="Float Field"
-	description="Float Field" />
-
-    <require like_class="zope.schema.Orderable" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Tuple">
-
-    <factory
-	id="zope.schema.Tuple"
-	title="Tuple Field"
-	description="Tuple Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.List">
-
-    <factory
-	id="zope.schema.List"
-	title="List Field"
-	description="List Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Set">
-
-    <factory
-	id="zope.schema.Set"
-	title="Set Field"
-	description="Set Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Password">
-
-    <factory
-	id="zope.schema.Password"
-	title="Password Field"
-	description="Password Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Dict">
-
-    <factory
-	id="zope.schema.Dict"
-	title="Dict Field"
-	description="Dict Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Datetime">
-
-    <factory
-	id="zope.schema.Datetime"
-	title="Datetime Field"
-	description="Datetime Field" />
-
-    <require like_class="zope.schema.Orderable" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.SourceText">
-
-    <factory
-	id="zope.schema.SourceText"
-	title="SourceText Field"
-	description="SourceText Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Object">
-
-    <factory
-	id="zope.schema.Object"
-	title="Object Field"
-	description="Object Field" />
-
-    <require
-       permission="zope.ManageContent"
-       interface="zope.schema.interfaces.IObject" />
-
-  </content>
-
-  <content class="zope.schema.URI">
-
-    <factory
-	id="zope.schema.URI"
-	title="URI Field"
-	description="URI Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.Id">
-
-    <factory
-	id="zope.schema.Id"
-	title="Id Field"
-	description="Id Field" />
-
-    <require like_class="zope.schema.MinMaxLen" />
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.InterfaceField">
-
-    <factory
-	id="zope.schema.InterfaceField"
-	title="Interface Field"
-	description="Interface Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.vocabulary.SimpleTerm">
-    <allow interface="zope.schema.interfaces.ITitledTokenizedTerm" />
-  </content>
-
-  <content class="zope.schema.vocabulary.SimpleVocabulary">
-    <allow interface="zope.schema.interfaces.IVocabulary" />
-    <allow interface="zope.schema.interfaces.IVocabularyTokenized" />
-  </content>
-
-</configure>

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/interfaces.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/interfaces.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/interfaces.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,90 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""TTW Schema Interfaces
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.interface.interfaces import IInterface
-from zope.app.container.interfaces import IAdding
-
-class ISchemaUtility(Interface):
-    pass
-
-class ISchemaAdding(IAdding):
-    pass
-
-class IReadMutableSchema(IInterface):
-    """This object represents an interface/schema that can be edited by
-    managing the fields it contains."""
-
-    def getName(name):
-        """Get the name of the schema."""
-
-class IWriteMutableSchema(Interface):
-    """This object represents an interface/schema that can be edited by
-    managing the fields it contains."""
-
-    def setName(name):
-        """Set the name of the schema."""
-
-    def addField(name, field):
-        """Add a field to schema."""
-
-    def removeField(name):
-        """Remove field by name from the schema.
-
-        If the field does not exist, raise an error.
-        """
-
-    def renameField(orig_name, target_name):
-        """Rename a field.
-
-        If the target_name is already taken, raise an error.
-        """
-
-    def insertField(name, field, position):
-        """Insert a field with a given name at the specified position.
-
-        If the position does not make sense, i.e. a negative number of a
-        number larger than len(self), then an error is raised.
-        """
-
-    def moveField(name, position):
-        """Move a field (given by its name) to a particular position.
-
-        If the position does not make sense, i.e. a negative number of a
-        number larger than len(self), then an error is raised.
-        """
-
-    def moveField(name, position):
-        """Move a field (given by its name) to a particular position.
-
-        If the position does not make sense, i.e. a negative number of a
-        number larger than len(self), then an error is raised.
-        """
-
-    def __setitem__(name, object):
-        """Add the given object to the container under the given name.
-        """
-
-    def __delitem__(name):
-        """Delete the nameed object from the container.
-
-        Raises a KeyError if the object is not found.
-        """
-
-class IMutableSchema(IReadMutableSchema, IWriteMutableSchema):
-    """This object represents an interface/schema that can be edited by
-    managing the fields it contains."""

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/schema.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/schema.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/schema.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,286 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""TTW Schema (as Utility)
-
-$Id$
-"""
-from types import FunctionType
-
-from persistent import Persistent
-from persistent.dict import PersistentDict
-from zope.interface import Interface, implements
-
-from zope.security.proxy import trustedRemoveSecurityProxy
-from zope.proxy import removeAllProxies
-from zope.app import zapi
-from zope.app.container.browser.adding import Adding
-from zope.app.interface import PersistentInterfaceClass
-from zope.app.utility import UtilityRegistration
-from zope.app.container.contained import Contained, setitem, uncontained
-
-from zope.interface.interface import Attribute, Method, fromFunction
-from zope.interface.interface import InterfaceClass
-from zope.interface.exceptions import InvalidInterface
-from zope.schema import getFieldsInOrder, getFieldNamesInOrder
-
-from wrapper import Struct
-from interfaces import ISchemaAdding, IMutableSchema, ISchemaUtility
-
-class BaseSchemaUtility(InterfaceClass):
-
-    implements(IMutableSchema, ISchemaUtility)
-
-    def __init__(self, name='', bases=(), attrs=None,
-                 __doc__=None, __module__=None):
-        if not bases:
-            bases = (Interface,)
-        super(BaseSchemaUtility, self).__init__(name, bases,
-                                            attrs, __doc__, __module__)
-        self._clear()
-
-    def _clear(self):
-        self.schemaPermissions = {}
-        self._attrs = {}
-
-    def setName(self, name):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        self.__name__ = name
-
-    def addField(self, name, field):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        fields = getFieldsInOrder(self)
-        field_names = [n for n, f in fields]
-        fields = [f for n, f in fields]
-        if name in field_names:
-            raise KeyError, "Field %s already exists." % name
-        if fields:
-            field.order = fields[-1].order + 1
-        self[name] = field
-
-    def removeField(self, name):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        fields = getFieldNamesInOrder(self)
-        if name not in fields:
-            raise KeyError, "Field %s does not exists." % name
-        del self[name]
-
-    def renameField(self, orig_name, target_name):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        fields = getFieldNamesInOrder(self)
-        if orig_name not in fields:
-            raise KeyError, "Field %s does not exists." % orig_name
-        if target_name in fields:
-            raise KeyError, "Field %s already exists." % target_name
-        field = self[orig_name]
-        del self[orig_name]
-        field.__name__ = None
-        self[target_name] = field
-
-    def insertField(self, name, field, position):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        fields = getFieldsInOrder(self)
-        field_names = [n for n, f in fields]
-        fields = [f for n, f in fields]
-        if name in field_names:
-            raise KeyError, "Field %s already exists." % name
-        if not 0 <= position <= len(field_names):
-            raise IndexError, "Position %s out of range." % position
-        fields.insert(position, field)
-        for p, f in enumerate(fields):
-            if not f.order == p:
-                f.order = p
-        self[name] = field
-
-    def moveField(self, name, position):
-        """See zope.app.interfaces.utilities.IMutableSchema"""
-        fields = getFieldsInOrder(self)
-        field_names = [n for n, f in fields]
-        fields = [f for n, f in fields]
-        if name not in field_names:
-            raise KeyError, "Field %s does not exist." % name
-        if not 0 <= position <= len(field_names):
-            raise IndexError, "Position %s out of range." % position
-        index = field_names.index(name)
-        if index == position: return
-        field = fields[index]
-        del fields[index]
-        fields.insert(position, field)
-        for p, f in enumerate(fields):
-            if not f.order == p:
-                f.order = p
-
-    def __delitem__(self, name):
-        uncontained(self._attrs[name], self, name)
-        del self._attrs[name]
-
-    def __setitem__(self, name, value):
-        value = removeAllProxies(value)
-        if isinstance(value, Attribute):
-            value.interface = name
-            if not value.__name__:
-                value.__name__ = name
-            elif isinstance(value, FunctionType):
-                attrs[name] = fromFunction(value, name, name=name)
-            else:
-                raise InvalidInterface("Concrete attribute, %s" % name)
-
-        setitem(self, self._attrs.__setitem__, name, value)
-
-    # Methods copied from zope.interface.interface.InterfaceClass,
-    # to avoid having to work around name mangling, which happens to be
-    # ugly and undesirable.
-    # Copied some methods, but not all. Only the ones that used __attrs
-    # and __bases__. Changed __attrs to _attrs, which is a PersistentDict,
-    # and __bases__ to getBases(), whic filters instances of InterfaceClass
-    def getBases(self):
-        return [b for b in self.__bases__ if isinstance(b, self.__class__)]
-
-    def extends(self, interface, strict=True):
-        """Does an interface extend another?"""
-        return ((interface in self._implied)
-                and
-                ((not strict) or (self != interface))
-                )
-
-    def names(self, all=False):
-        """Return the attribute names defined by the interface."""
-        if not all:
-            return self._attrs.keys()
-
-        r = {}
-        for name in self._attrs.keys():
-            r[name] = 1
-        for base in self.getBases():
-            for name in base.names(all):
-                r[name] = 1
-        return r.keys()
-
-    def namesAndDescriptions(self, all=False):
-        """Return attribute names and descriptions defined by interface."""
-        if not all:
-            return self._attrs.items()
-
-        r = {}
-        for name, d in self._attrs.items():
-            r[name] = d
-
-        for base in self.getBases():
-            for name, d in base.namesAndDescriptions(all):
-                if name not in r:
-                    r[name] = d
-
-        return r.items()
-
-    def getDescriptionFor(self, name):
-        """Return the attribute description for the given name."""
-        r = self.queryDescriptionFor(name)
-        if r is not None:
-            return r
-
-        raise KeyError, name
-
-    __getitem__ = getDescriptionFor
-
-    def queryDescriptionFor(self, name, default=None):
-        """Return the attribute description for the given name."""
-        r = self._attrs.get(name, self)
-        if r is not self:
-            return r
-        for base in self.getBases():
-            r = base.queryDescriptionFor(name, self)
-            if r is not self:
-                return r
-
-        return default
-
-    get = queryDescriptionFor
-
-    def deferred(self):
-        """Return a defered class corresponding to the interface."""
-        if hasattr(self, "_deferred"): return self._deferred
-
-        klass={}
-        exec "class %s: pass" % self.__name__ in klass
-        klass=klass[self.__name__]
-
-        self.__d(klass.__dict__)
-
-        self._deferred=klass
-
-        return klass
-
-    def __d(self, dict):
-
-        for k, v in self._attrs.items():
-            if isinstance(v, Method) and not (k in dict):
-                dict[k]=v
-
-        for b in self.getBases(): b.__d(dict)
-
-
-class StructPersistentDict(PersistentDict):
-
-    def __setitem__(self, name, value):
-        if not isinstance(value, Persistent):
-            value = Struct(value)
-        return super(StructPersistentDict, self).__setitem__(name, value)
-
-
-class SchemaUtility(BaseSchemaUtility, PersistentInterfaceClass, Contained):
-
-    def __init__(self, name='', bases=(), attrs=None,
-                 __doc__=None, __module__=None):
-        if not bases:
-            bases = (Interface,)
-        PersistentInterfaceClass.__init__(self, name, bases,
-                                          attrs, __doc__, __module__)
-        self._clear()
-
-    def _clear(self):
-        self.schemaPermissions = PersistentDict()
-        self._attrs = StructPersistentDict()
-
-
-class SchemaAdding(Adding):
-
-    implements(ISchemaAdding)
-
-    menu_id = "add_schema_field"
-
-    def add(self, content):
-        name = self.contentName
-        container = IMutableSchema(self.context)
-        container.addField(name, content)
-        return content
-
-    def nextURL(self):
-        """See zope.app.container.interfaces.IAdding"""
-        return (str(zapi.getView(self.context, "absolute_url", self.request))
-                + '/@@editschema.html')
-
-
-class SchemaRegistration(UtilityRegistration):
-    """Schema Registration
-
-    We have a custom registration here, since we want active registrations to
-    set the name of the schema.
-    """
-
-    def activated(self):
-        schema = self.getComponent()
-        schema.setName(self.name)
-
-    def deactivated(self):
-        schema = self.getComponent()
-        schema.setName('<schema not activated>')

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_field.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_field.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_field.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,79 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 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.
-#
-##############################################################################
-"""Field Tests
-
-$Id$
-"""
-import unittest
-
-from persistent.tests.persistenttestbase import DM
-
-from zope.configuration import xmlconfig
-from zope.schema import Text, getFieldsInOrder
-from zope.security.checker import ProxyFactory
-from zope.security.management import system_user, newInteraction
-from zope.app.tests import setup
-from zope.app.schema.wrapper import Struct
-from zope.security.checker import getChecker, _defaultChecker
-import zope.app.schema.tests
-
-
-class ParticipationStub:
-
-    def __init__(self, principal):
-        self.principal = principal
-        self.interaction = None
-
-
-class FieldPersistence(unittest.TestCase):
-
-    def test_field_change(self):
-        f = Text(title=u'alpha')
-        f = Struct(f)
-        f._p_oid = '\0\0\0\0\0\0hi'
-        dm = DM()
-        f._p_jar = dm
-        self.assertEqual(f._p_changed, 0)
-        f.title = u'bar'
-        self.assertEqual(f._p_changed, 1)
-        self.assertEqual(dm.called, 1)
-
-class FieldPermissions(unittest.TestCase):
-
-    def setUp(self):
-        setup.placefulSetUp()
-        self.context = xmlconfig.file("fields.zcml", zope.app.schema.tests)
-        newInteraction(ParticipationStub(system_user))
-
-    def test_wrapped_field_checker(self):
-        f1 = Text(title=u'alpha')
-        f1 = ProxyFactory(f1)
-        f2 = Text(title=u'alpha')
-        f2 = Struct(f2)
-        f2 = ProxyFactory(f2)
-        self.assertEquals(getChecker(f1), getChecker(f2))
-        self.failIf(getChecker(f1) is _defaultChecker)
-        self.failIf(getChecker(f2) is _defaultChecker)
-
-    def tearDown(self):
-        setup.placefulTearDown()
-
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(FieldPersistence),
-        unittest.makeSuite(FieldPermissions),
-        ))
-
-if __name__ == '__main__':
-    unittest.main()

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,75 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 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.
-#
-##############################################################################
-"""Field Factory Tests
-
-$Id$
-"""
-import unittest
-
-import zope.app.schema
-
-from zope.app import zapi
-from zope.component.exceptions import ComponentLookupError
-from zope.component.interfaces import IFactory
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.security.management import newInteraction, system_user
-from zope.schema.interfaces import IField, IText
-from zope.interface import Interface
-from zope.configuration import xmlconfig
-
-
-class ParticipationStub:
-
-    def __init__(self, principal):
-        self.principal = principal
-        self.interaction = None
-
-class IFoo(Interface): pass
-
-class TestFieldFactory(PlacelessSetup, unittest.TestCase):
-
-    def setUp(self):
-        super(TestFieldFactory, self).setUp()
-        newInteraction(ParticipationStub(system_user))
-        context = xmlconfig.file('tests/test_fieldfactory.zcml',
-                                 zope.app.schema)
-
-    def testRegisterFields(self):
-        factory = zapi.getUtility(IFactory,
-                                  'zope.schema._bootstrapfields.Text')
-        self.assertEquals(factory.title, "Text Field")
-        self.assertEquals(factory.description, "Text Field")
-
-    def testGetFactoriesForIField(self):
-        factories = list(zapi.getFactoriesFor(IField))
-        self.assertEqual(len(factories), 3)
-
-    def testGetFactoriesForIText(self):
-        factories = list(zapi.getFactoriesFor(IText))
-        self.assertEqual(len(factories), 2)
-
-    def testGetFactoriesUnregistered(self):
-        factories = list(zapi.getFactoriesFor(IFoo))
-        self.assertEqual(len(factories), 0)
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite.addTest(loader.loadTestsFromTestCase(TestFieldFactory))
-    return suite
-
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.zcml	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_fieldfactory.zcml	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,56 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
-           i18n_domain="zope">
-
-  <include package="zope.app.schema" file="meta.zcml" />
-  <include package="zope.app.component" file="meta.zcml" />
-  <include package="zope.app.publisher" file="meta.zcml" />
-  <include package="zope.app.security" file="meta.zcml" />
-  <include package="zope.app.security" file="configure.zcml" />
-
-  <content class="zope.schema.Field">
-
-    <factory
-	title="Basic Field"
-	description="Basic Field" />
-
-    <!--
-    <require
-	permission="zope.View"
-	interface="zope.schema.interfaces.IField"
-	/>
-
-    <require
-	permission="zope.ManageContent"
-	attributes="bind set"
-	/>
-    -->
-
-    <!-- XXX put the whole interface under one permission for now -->
-    <require
-	permission="zope.ManageContent"
-	interface="zope.schema.interfaces.IField"
-	/>
-
-  </content>
-
-  <content class="zope.schema.Text">
-
-    <factory
-	title="Text Field"
-	description="Text Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-  <content class="zope.schema.TextLine">
-
-    <factory
-	title="Text Line Field"
-	description="Text Line Field" />
-
-    <require like_class="zope.schema.Field" />
-
-  </content>
-
-</configure>
\ No newline at end of file

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_interfaceutility.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_interfaceutility.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_interfaceutility.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,276 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Utility service tests
-
-$Id$
-"""
-import unittest
-from zope.app.tests import setup
-from zope.app.site.tests import placefulsetup
-from zope.app import utility
-from zope.app import zapi
-from zope.app.servicenames import Utilities
-from zope.app.component.interface import getInterface, searchInterface
-from zope.interface import Interface, implements
-from zope.app.container.contained import Contained
-from zope.component import getService
-from zope.component.exceptions import ComponentLookupError
-from zope.app.traversing.api import traverse
-from zope.app.registration.interfaces import IRegistrationStack
-from zope.app.registration.interfaces import UnregisteredStatus
-from zope.app.registration.interfaces import RegisteredStatus
-from zope.app.registration.interfaces import ActiveStatus
-from zope.app.registration.interfaces import IRegistered
-from zope.app.utility.interfaces import ILocalUtility
-from zope.app.dependable.interfaces import IDependable
-from zope.app.tests import setup
-from zope.interface.interface import InterfaceClass
-from zope.interface.interfaces import IInterface
-from zope.interface import Interface
-
-class IBaz(Interface): pass
-
-class Baz:
-    # We implement IRegistered and IDependable directly to
-    # depend as little  as possible on other infrastructure.
-    implements(IBaz, ILocalUtility, IRegistered, IDependable)
-
-    def __init__(self, name):
-        self.name = name
-        self._usages = []
-        self._dependents = []
-
-    def foo(self):
-        return 'foo ' + self.name
-
-    def addUsage(self, location):
-        "See zope.app.registration.interfaces.IRegistered"
-        if location not in self._usages:
-            self._usages.append(location)
-
-    def removeUsage(self, location):
-        "See zope.app.registration.interfaces.IRegistered"
-        self._usages.remove(location)
-
-    def usages(self):
-        "See zope.app.registration.interfaces.IRegistered"
-        return self._usages
-
-    def addDependent(self, location):
-        "See zope.app.dependable.interfaces.IDependable"
-        if location not in self._dependents:
-            self._dependents.append(location)
-
-    def removeDependent(self, location):
-        "See zope.app.dependable.interfaces.IDependable"
-        self._dependents.remove(location)
-
-    def dependents(self):
-        "See zope.app.dependable.interfaces.IDependable"
-        return self._dependents
-
-class Foo(InterfaceClass, Baz, Contained):
-
-    def __init__(self, name):
-        InterfaceClass.__init__(self, name, (Interface,))
-        Baz.__init__(self, name)
-
-class Bar(Foo): pass
-
-class TestInterfaceUtility(placefulsetup.PlacefulSetup, unittest.TestCase):
-
-    def setUp(self):
-        sm = placefulsetup.PlacefulSetup.setUp(self, site=True)
-        setup.addService(sm, Utilities,
-                         utility.LocalUtilityService())
-
-    def test_getLocalInterface_delegates_to_globalUtility(self):
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, Bar("blob"),
-                                            name="blob")
-        utilityService.provideUtility(IBaz, Baz("global baz"))
-        utilityService.provideUtility(IInterface, Foo("global bob"),
-                                            name="bob")
-
-        self.assertEqual(getInterface(None, "bob").__class__, Foo)
-        self.assertEqual(getInterface(None, "blob").__class__, Bar)
-
-    def test_localInterfaceitems_filters_accordingly(self):
-        bar = Bar("global")
-        baz = Baz("global baz")
-        foo = Foo("global bob")
-
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, foo,
-                                            name="bob")
-        utilityService.provideUtility(IInterface, bar)
-        utilityService.provideUtility(IBaz, baz)
-
-        ifaces = searchInterface(None)
-        self.assert_(len(ifaces), 2)
-        for pair in [(foo), (bar)]:
-            self.assert_(pair in ifaces)
-
-        iface_utilities = utilityService.getUtilitiesFor(IInterface)
-        ifaces = [iface for (name, iface) in iface_utilities]
-
-        self.assert_(len(ifaces), 2)
-        for pair in [(foo), (bar)]:
-            self.assert_(pair in ifaces)
-
-        for pair in [(foo), (bar)]:
-            self.assert_(pair in ifaces)
-
-    def test_localInterfaceitems_filters_only_interfaces(self):
-        bar = Bar("global")
-        baz = Baz("global baz")
-        foo = Foo("global bob")
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, foo,
-                                            name="bob")
-        utilityService.provideUtility(ILocalUtility, bar)
-        utilityService.provideUtility(IBaz, baz)
-
-        iface_utilities = utilityService.getUtilitiesFor(IInterface)
-        ifaces = [iface for (name, iface) in iface_utilities]
-        self.assertEqual(ifaces, [(foo)])
-
-        iface_utilities = utilityService.getUtilitiesFor(ILocalUtility)
-        ifaces = [iface for (name, iface) in iface_utilities]
-        self.assertEqual(ifaces, [(bar)])
-
-        iface_utilities = utilityService.getUtilitiesFor(IBaz)
-        ifaces = [iface for (name, iface) in iface_utilities]
-        self.assertEqual(ifaces, [(baz)])
-
-    def test_getLocalInterface_raisesComponentLookupError(self):
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, Foo("global"))
-        utilityService.provideUtility(IBaz, Baz("global baz"))
-        utilityService.provideUtility(IInterface, Foo("global bob"),
-                                            name="bob")
-
-        self.assertRaises(ComponentLookupError,
-                          getInterface, None, "bobesponja")
-
-    def test_globalsearchInterface_delegates_to_globalUtility(self):
-        foo = Foo("global bob")
-        bar = Bar("global")
-        baz = Baz("global baz")
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, bar)
-        utilityService.provideUtility(IBaz, baz)
-        utilityService.provideUtility(IInterface, foo,
-                                            name="bob")
-
-        self.assertEqual(searchInterface(None, search_string="bob"),
-                         [foo])
-
-    def test_localsearchInterface_delegates_to_globalUtility(self):
-        foo = Foo("global bob")
-        bar = Bar("global")
-        baz = Baz("global baz")
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, bar)
-        utilityService.provideUtility(IBaz, baz)
-        utilityService.provideUtility(IInterface, foo,
-                                            name="bob")
-
-        self.assertEqual(searchInterface(None, search_string="bob"),
-                         [foo])
-
-    def test_queryUtility_delegates_to_global(self):
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, Foo("global"))
-        utilityService.provideUtility(IInterface, Foo("global bob"),
-                                            name="bob")
-
-        utility_service = getService(Utilities, self.rootFolder)
-        self.assert_(utility_service != utilityService)
-
-        self.assertEqual(utility_service.queryUtility(IInterface).foo(),
-                         "foo global")
-        self.assertEqual(
-            utility_service.queryUtility(IInterface, "bob").foo(),
-            "foo global bob")
-
-    def test_getUtility_delegates_to_global(self):
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, Foo("global"))
-        utilityService.provideUtility(IInterface, Foo("global bob"),
-                                            name="bob")
-
-        utility_service = getService(Utilities, self.rootFolder)
-        self.assert_(utility_service != utilityService)
-
-        self.assertEqual(utility_service.getUtility(IInterface).foo(),
-                         "foo global")
-        self.assertEqual(
-            utility_service.getUtility(IInterface, "bob").foo(),
-            "foo global bob")
-
-
-    def test_registrationsFor_methods(self):
-        utilities = getService(Utilities, self.rootFolder)
-        default = traverse(self.rootFolder, "++etc++site/default")
-        default['foo'] = Foo("local")
-        path = "/++etc++site/default/foo"
-
-        for name in ('', 'bob'):
-            registration = utility.UtilityRegistration(name, IInterface, path)
-            self.assertEqual(utilities.queryRegistrationsFor(registration),
-                             None)
-            registery = utilities.createRegistrationsFor(registration)
-            self.assert_(IRegistrationStack.providedBy(registery))
-            self.assertEqual(utilities.queryRegistrationsFor(registration),
-                             registery)
-
-
-    def test_local_utilities(self):
-        utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-        utilityService.provideUtility(IInterface, Foo("global"))
-        utilityService.provideUtility(IInterface, Foo("global bob"),
-                                            name="bob")
-
-        utilities = getService(Utilities, self.rootFolder)
-        default = traverse(self.rootFolder, "++etc++site/default")
-        default['foo'] = Foo("local")
-        path = "/++etc++site/default/foo"
-        cm = default.getRegistrationManager()
-
-        for name in ('', 'bob'):
-            registration = utility.UtilityRegistration(name, IInterface, path)
-            cname = cm.addRegistration(registration)
-            registration = traverse(cm, cname)
-
-            gout = name and "foo global "+name or "foo global"
-
-            self.assertEqual(utilities.getUtility(IInterface, name).foo(),
-                             gout)
-
-            registration.status = ActiveStatus
-
-            self.assertEqual(utilities.getUtility(IInterface, name).foo(),
-                             "foo local")
-
-            registration.status = RegisteredStatus
-
-            self.assertEqual(utilities.getUtility(IInterface, name).foo(), gout)
-
-
-def test_suite():
-    return unittest.makeSuite(TestInterfaceUtility)
-
-if __name__ == '__main__':
-    unittest.main()

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautility.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautility.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautility.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,210 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 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.
-#
-##############################################################################
-"""
-$Id$
-"""
-from unittest import TestCase, makeSuite, TestSuite
-
-from zope.configuration import xmlconfig
-from zope.schema import Text, getFieldNamesInOrder, getFieldsInOrder
-from zope.security.management import system_user, newInteraction
-from zope.security.checker import getChecker, _defaultChecker, ProxyFactory
-from zope.app.schema.schema import SchemaUtility
-from zope.app.tests import setup
-from zope.app import zapi
-import zope.app.schema.tests
-
-class ParticipationStub:
-
-    def __init__(self, principal):
-        self.principal = principal
-        self.interaction = None
-
-
-class SchemaUtilityTests(TestCase):
-
-    def _createSchemaUtility(self):
-        return SchemaUtility()
-
-    def _additionalSetup(self):
-        self.s = self._createSchemaUtility()
-        self.s.setName('IFoo')
-        self.alpha = Text(title=u"alpha")
-
-    def setUp(self):
-        setup.placefulSetUp()
-        self._additionalSetup()
-
-    def test_addField(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        self.assertEquals(
-            [u'alpha',],
-            getFieldNamesInOrder(s))
-
-    def test_addFieldInsertsAtEnd(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        s.addField(u'beta', beta)
-        self.assertEquals(
-            [u'alpha', u'beta'],
-            getFieldNamesInOrder(s))
-
-    def test_removeField(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        s.removeField(u'alpha')
-        self.assertEquals(
-            [],
-            getFieldNamesInOrder(s))
-
-    def test_addFieldCollision(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        self.assertRaises(KeyError, s.addField, 'alpha', self.alpha)
-
-    def test_removeFieldNotPresent(self):
-        self.assertRaises(KeyError, self.s.removeField, 'alpha')
-
-    def test_renameField(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        s.renameField(u'alpha', 'beta')
-        self.assertEquals(
-            [u'beta'],
-            getFieldNamesInOrder(s))
-
-    def test_renameFieldCollision(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        s.addField(u'beta', Text(title=u"Beta"))
-        self.assertRaises(KeyError, s.renameField, 'alpha', 'beta')
-
-    def test_renameFieldNotPresent(self):
-        self.assertRaises(KeyError, self.s.renameField, 'alpha', 'beta')
-
-    def test_insertField(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        s.insertField(u'beta', beta, 0)
-        self.assertEquals(
-            [u'beta', u'alpha'],
-            getFieldNamesInOrder(s))
-
-    def test_insertFieldCollision(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        self.assertRaises(KeyError, s.insertField, 'alpha', beta, 0)
-
-    def test_insertFieldCornerCases(self):
-        s = self.s
-        gamma = Text(title=u"Gamma")
-        # it's still possible to insert at beginning
-        s.insertField(u'gamma', gamma, 0)
-        self.assertEquals(
-            [u'gamma'],
-            getFieldNamesInOrder(s))
-        # should be allowed to insert field at the end
-        s.insertField(u'alpha', self.alpha, 1)
-        self.assertEquals(
-            [u'gamma', u'alpha'],
-            getFieldNamesInOrder(s))
-        # should be allowed to insert field at the beginning still
-        delta = Text(title=u"Delta")
-        s.insertField(u'delta', delta, 0)
-        self.assertEquals(
-            [u'delta', u'gamma', u'alpha'],
-            getFieldNamesInOrder(s))
-
-    def test_insertFieldBeyondEnd(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        self.assertRaises(IndexError, s.insertField,
-                          'beta', beta, 100)
-
-    def test_insertFieldBeforeBeginning(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        self.assertRaises(IndexError, s.insertField,
-                          'beta', beta, -1)
-
-    def test_moveField(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u'Beta')
-        s.addField(u'beta', beta)
-        gamma = Text(title=u'Gamma')
-        s.addField(u'gamma', gamma)
-        s.moveField(u'beta', 3)
-        self.assertEquals(
-            [u'alpha', u'gamma', u'beta'],
-            getFieldNamesInOrder(s))
-        s.moveField(u'beta', 2)
-        self.assertEquals(
-            [u'alpha', u'gamma', u'beta'],
-            getFieldNamesInOrder(s))
-        s.moveField(u'beta', 1)
-        self.assertEquals(
-            [u'alpha', u'beta', u'gamma'],
-            getFieldNamesInOrder(s))
-        s.moveField(u'beta', 0)
-        self.assertEquals(
-            [u'beta', u'alpha', u'gamma'],
-            getFieldNamesInOrder(s))
-
-    def test_moveFieldBeyondEnd(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        s.addField(u'beta', beta)
-        self.assertRaises(IndexError, s.moveField,
-                          'beta', 100)
-
-    def test_moveFieldBeforeBeginning(self):
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        beta = Text(title=u"Beta")
-        s.addField(u'beta', beta)
-        self.assertRaises(IndexError, s.moveField,
-                          'beta', -1)
-
-    def test_traverseToField(self):
-        context = xmlconfig.file("fields.zcml", zope.app.schema.tests)
-        s = self.s
-        s.addField(u'alpha', self.alpha)
-        s = ProxyFactory(s)
-        newInteraction(ParticipationStub(system_user))
-        f1 = ProxyFactory(s[u'alpha'])
-        order = f1.order
-        f1 = zapi.traverse(s, 'alpha')
-        self.assertEquals(f1.order, self.alpha.order)
-        title = zapi.traverse(f1, 'title')
-        self.assertEquals(title, self.alpha.title)
-        fields = getFieldsInOrder(s)
-        for k, v in fields:
-            self.failUnless(v.title is not None)
-
-    def tearDown(self):
-        setup.placefulTearDown()
-
-
-def test_suite():
-    return TestSuite((
-        makeSuite(SchemaUtilityTests),
-         ))

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautilitypersistence.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautilitypersistence.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_schemautilitypersistence.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,107 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Tests for Schema Utility Persistence
-
-$Id$
-"""
-import unittest
-
-from persistent.tests.persistenttestbase import PersistentTest, DM
-from zope.app.schema.wrapper import Struct
-from zope.app.schema.schema import SchemaUtility
-from zope.schema import Text, getFieldsInOrder
-from zope.app.tests import setup
-
-class PSchema(SchemaUtility):
-
-    def __init__(self):
-        super(PSchema, self).__init__()
-        self.x = 0
-        self.setName('PSchema')
-
-    def inc(self):
-        self.x += 1
-
-class PersistentSchemaUtilityTest(PersistentTest):
-
-    klass = PSchema
-
-    def setUp(self):
-        PersistentTest.setUp(self)
-        setup.placefulSetUp(self)
-
-    def testState(self):
-        pass
-
-#     def testChangeField(self):
-#         f = Text(title=u'alpha')
-#         p = self.klass()
-#         p._p_oid = '\0\0\0\0\0\0hi'
-#         dm = DM()
-#         p._p_jar = dm
-#         self.assertEqual(p._p_changed, 0)
-#         self.assertEqual(dm.called, 0)
-#         p.addField('alpha', f)
-#         self.assertEqual(p._p_changed, 1)
-#         self.assertEqual(dm.called, 1)
-#         p._p_changed = 0
-#         self.assertEqual(p._p_changed, 0)
-#         self.assertEqual(dm.called, 1)
-#         field = p['alpha']
-#         field.title = u'Beta'
-#         self.assertEqual(f._p_changed, 1)
-#         self.assertEqual(p._p_changed, 1)
-#         self.assertEqual(dm.called, 2)
-
-#     def testAddField(self):
-#         f = Text(title=u'alpha')
-#         p = self.klass()
-#         p._p_oid = '\0\0\0\0\0\0hi'
-#         dm = DM()
-#         p._p_jar = dm
-#         self.assertEqual(p._p_changed, 0)
-#         self.assertEqual(dm.called, 0)
-#         p.addField('alpha', f)
-#         self.assertEqual(p._p_changed, 1)
-#         self.assertEqual(dm.called, 1)
-
-#     def testRemoveField(self):
-#         f = Text(title=u'alpha')
-#         p = self.klass()
-#         p._p_oid = '\0\0\0\0\0\0hi'
-#         dm = DM()
-#         p._p_jar = dm
-#         self.assertEqual(p._p_changed, 0)
-#         self.assertEqual(dm.called, 0)
-#         p.addField('alpha', f)
-#         self.assertEqual(p._p_changed, 1)
-#         self.assertEqual(dm.called, 1)
-#         p._p_changed = 0
-#         self.assertEqual(p._p_changed, 0)
-#         self.assertEqual(dm.called, 1)
-#         p.removeField('alpha')
-#         self.assertEqual(p._p_changed, 1)
-#         self.assertEqual(dm.called, 2)
-
-    def tearDown(self):
-        PersistentTest.tearDown(self)
-        setup.placefulTearDown()
-
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(PersistentSchemaUtilityTest))
-    return suite
-
-if __name__ == '__main__':
-    unittest.main()

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_wrapper.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_wrapper.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/tests/test_wrapper.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,349 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 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.
-#
-##############################################################################
-import unittest
-
-from persistent import Persistent, GHOST, UPTODATE
-from persistent.tests.persistenttestbase import DM as BaseDM, BrokenDM
-
-from zope.interface import Interface, directlyProvides, directlyProvidedBy
-
-from zope.app.schema.wrapper import Struct
-from zope.app.container.contained import ContainedProxy, getProxiedObject
-
-
-class IDummy(Interface): pass
-
-class Dummy(object):
-
-    def __init__(self, x=0):
-        self.x = x
-
-DUMMY = Dummy(42)
-
-class DM(BaseDM):
-    def setstate(self, ob):
-        ob.__setstate__({'__proxied__': DUMMY})
-
-def makeInstance(self):
-    d = Dummy()
-    p = Struct(d)
-    return p
-
-class Test(unittest.TestCase):
-
-    klass = None # override in subclass
-
-    def testSaved(self):
-        p = self.klass()
-        p._p_oid = '\0\0\0\0\0\0hi'
-        dm = DM()
-        p._p_jar = dm
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(dm.called, 0)
-        p.x += 1
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 1)
-        p.x += 1
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 1)
-        p._p_deactivate()
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 1)
-        p._p_deactivate()
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 1)
-        p._p_invalidate()
-        self.assertEqual(p._p_changed, None)
-        self.assertEqual(dm.called, 1)
-        p.x += 1
-        self.assertEqual(p.x, 43)
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 2)
-        p._p_changed = 0
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(dm.called, 2)
-        self.assertEqual(p.x, 43)
-        p.x += 1
-        self.assertEqual(p._p_changed, 1)
-        self.assertEqual(dm.called, 3)
-
-    def testUnsaved(self):
-        p = self.klass()
-
-        self.assertEqual(p.x, 0)
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(p._p_jar, None)
-        self.assertEqual(p._p_oid, None)
-        p.x += 1
-        p.x += 1
-        self.assertEqual(p.x, 2)
-        self.assertEqual(p._p_changed, 0)
-
-        p._p_deactivate()
-        self.assertEqual(p._p_changed, 0)
-        p._p_changed = 1
-        self.assertEqual(p._p_changed, 0)
-        p._p_deactivate()
-        self.assertEqual(p._p_changed, 0)
-        p._p_invalidate()
-        self.assertEqual(p._p_changed, None)
-        if self.has_dict:
-            self.failUnless(p.__dict__)
-        self.assertEqual(p.x, 2)
-
-    def testState(self):
-        p = self.klass()
-        d = Dummy()
-        self.failUnless(p.__getstate__().has_key('__proxied__'))
-        self.assertEqual(p._p_changed, 0)
-        p.__setstate__({'__proxied__':d})
-        self.assertEqual(p._p_changed, 0)
-        if self.has_dict:
-            p._v_foo = 2
-        self.failUnless(p.__getstate__(), {'__proxied__': d})
-        self.assertEqual(p._p_changed, 0)
-
-    def testSetStateSerial(self):
-        p = self.klass()
-        p._p_serial = 'abcdefgh'
-        p.__setstate__(p.__getstate__())
-        self.assertEqual(p._p_serial, 'abcdefgh')
-
-    def testDirectChanged(self):
-        p = self.klass()
-        p._p_oid = 1
-        dm = DM()
-        p._p_jar = dm
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(dm.called, 0)
-        p._p_changed = 1
-        self.assertEqual(dm.called, 1)
-
-    def testGhostChanged(self):
-        # An object is a ghost, and it's _p_changed it set to True.
-        # This assignment should have no effect.
-        p = self.klass()
-        p._p_oid = 1
-        dm = DM()
-        p._p_jar = dm
-        p._p_deactivate()
-        self.assertEqual(p._p_state, GHOST)
-        p._p_changed = True
-        self.assertEqual(p._p_state, GHOST)
-
-    def testRegistrationFailure(self):
-        p = self.klass()
-        p._p_oid = 1
-        dm = BrokenDM()
-        p._p_jar = dm
-        self.assertEqual(p._p_changed, 0)
-        self.assertEqual(dm.called, 0)
-        try:
-            p._p_changed = 1
-        except NotImplementedError:
-            pass
-        else:
-            raise AssertionError("Exception not propagated")
-        self.assertEqual(dm.called, 1)
-        self.assertEqual(p._p_changed, 0)
-
-    def testLoadFailure(self):
-        p = self.klass()
-        p._p_oid = 1
-        dm = BrokenDM()
-        p._p_jar = dm
-        p._p_deactivate()  # make it a ghost
-
-        try:
-            p._p_activate()
-        except NotImplementedError:
-            pass
-        else:
-            raise AssertionError("Exception not propagated")
-        self.assertEqual(p._p_changed, None)
-
-    def testActivate(self):
-        p = self.klass()
-        dm = DM()
-        p._p_oid = 1
-        p._p_jar = dm
-        p._p_changed = 0
-        p._p_deactivate()
-        # XXX does this really test the activate method?
-        p._p_activate()
-        self.assertEqual(p._p_state, UPTODATE)
-        self.assertEqual(p.x, 42)
-
-    def testDeactivate(self):
-        p = self.klass()
-        dm = DM()
-        p._p_oid = 1
-        p._p_deactivate() # this deactive has no effect
-        self.assertEqual(p._p_state, UPTODATE)
-        p._p_jar = dm
-        p._p_changed = 0
-        p._p_deactivate()
-        self.assertEqual(p._p_state, GHOST)
-        p._p_activate()
-        self.assertEqual(p._p_state, UPTODATE)
-        self.assertEqual(p.x, 42)
-
-# XXX to do this right and expose both IPersistent and the
-# underlying object's interfaces, we'd need to use a specialized
-# descriptor.  This would create to great a dependency on
-# zope.interface.
-
-#     def testInterface(self):
-#         from persistent.interfaces import IPersistent
-#         self.assert_(IPersistent.implementedBy(Persistent),
-#                      "%s does not implement IPersistent" % Persistent)
-#         p = Persistent()
-#         self.assert_(IPersistent.providedBy(p),
-#                      "%s does not implement IPersistent" % p)
-
-#         self.assert_(IPersistent.implementedBy(Struct),
-#                      "%s does not implement IPersistent" % Struct)
-#         p = self.klass()
-#         self.assert_(IPersistent.providedBy(p),
-#                      "%s does not implement IPersistent" % p)
-
-    def testDataManagerAndAttributes(self):
-        # Test to cover an odd bug where the instance __dict__ was
-        # set at the same location as the data manager in the C type.
-        p = self.klass()
-        p.x += 1
-        p.x += 1
-        self.assert_('__proxied__' in p.__dict__)
-        self.assert_(p._p_jar is None)
-
-    def testMultipleInheritance(self):
-        # make sure it is possible to inherit from two different
-        # subclasses of persistent.
-        class A(Persistent):
-            pass
-        class B(Persistent):
-            pass
-        class C(A, B):
-            pass
-        class D(object):
-            pass
-        class E(D, B):
-            pass
-
-    def testMultipleMeta(self):
-        # make sure it's possible to define persistent classes
-        # with a base whose metaclass is different
-        class alternateMeta(type):
-            pass
-        class alternate(object):
-            __metaclass__ = alternateMeta
-        class mixedMeta(alternateMeta, type):
-            pass
-        class mixed(alternate, Persistent):
-            __metaclass__ = mixedMeta
-
-    def testSlots(self):
-        # Verify that Persistent classes behave the same way
-        # as pure Python objects where '__slots__' and '__dict__'
-        # are concerned.
-
-        class noDict(object):
-            __slots__ = ['foo']
-
-        class shouldHaveDict(noDict):
-            pass
-
-        class p_noDict(Persistent):
-            __slots__ = ['foo']
-
-        class p_shouldHaveDict(p_noDict):
-            pass
-
-        self.assertEqual(noDict.__dictoffset__, 0)
-        self.assertEqual(p_noDict.__dictoffset__, 0)
-
-        self.assert_(shouldHaveDict.__dictoffset__ <> 0)
-        self.assert_(p_shouldHaveDict.__dictoffset__ <> 0)
-
-    def testBasicTypeStructure(self):
-        # test that a persistent class has a sane C type structure
-        # use P (defined below) as simplest example
-        self.assertEqual(Persistent.__dictoffset__, 0)
-        self.assertEqual(Persistent.__weakrefoffset__, 0)
-        self.assert_(Persistent.__basicsize__ > object.__basicsize__)
-        self.assert_(Struct.__dictoffset__)
-        self.assert_(Struct.__weakrefoffset__)
-        self.assert_(Struct.__dictoffset__ < Struct.__weakrefoffset__)
-        self.assert_(Struct.__basicsize__ > Persistent.__basicsize__)
-
-    def testDeactivateErrors(self):
-        p = self.klass()
-        p._p_oid = '\0\0\0\0\0\0hi'
-        dm = DM()
-        p._p_jar = dm
-
-        def typeerr(*args, **kwargs):
-            self.assertRaises(TypeError, p, *args, **kwargs)
-
-        typeerr(1)
-        typeerr(1, 2)
-        typeerr(spam=1)
-        typeerr(spam=1, force=1)
-
-        p._p_changed = True
-        class Err(object):
-            def __nonzero__(self):
-                raise RuntimeError
-
-        typeerr(force=Err())
-
-class PersistentTest(Test):
-
-    klass = makeInstance
-    has_dict = 1
-
-    def testPicklable(self):
-        import pickle
-
-        p = self.klass()
-        p.x += 1
-        p2 = pickle.loads(pickle.dumps(p))
-        self.assertEqual(p2.__class__, p.__class__);
-        self.failUnless(p2.__dict__.has_key('__proxied__'))
-        self.assertEqual(p2.__dict__['__proxied__'].__dict__,
-                         p.__dict__['__proxied__'].__dict__)
-
-    def testContainedPicklable(self):
-        import pickle
-
-        p = self.klass()
-        p = ContainedProxy(p)
-        p.x += 1
-        p2 = pickle.loads(pickle.dumps(p))
-        pa = getProxiedObject(p)
-        pb = getProxiedObject(p2)
-        self.assertEqual(pb.__class__, pa.__class__);
-        self.failUnless(pb.__dict__.has_key('__proxied__'))
-        self.assertEqual(pb.__dict__['__proxied__'].__dict__,
-                         pa.__dict__['__proxied__'].__dict__)
-
-    def testDirectlyProvides(self):
-        p = self.klass()
-        self.failIf(IDummy.providedBy(p))
-        directlyProvides(p, directlyProvidedBy(p), IDummy)
-        self.failUnless(IDummy.providedBy(p))
-
-
-def test_suite():
-    return unittest.makeSuite(PersistentTest)

Deleted: Zope3/branches/ZopeX3-3.0/src/zope/app/schema/wrapper.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/schema/wrapper.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/schema/wrapper.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -1,126 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 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.
-#
-##############################################################################
-"""Provide persistent wrappers for objects that cannot derive from
-persistence for some reason."""
-
-from persistent import Persistent, GHOST
-from zope.interface import implementedBy
-from zope.security.checker import selectChecker
-
-class SecurityDescriptor:
-    """ SecurityDescriptor is used by Struct to return the
-    checker for the proxied object when its an instance,
-    and return the checker for the Struct class, when its a class
-    """
-
-    def __get__(self, inst, cls=None):
-        if inst is None:
-            return selectChecker(cls)
-        else:
-            # XXX This is *VERY* tricky. There is a possibility that
-            # the object was loaded, but not active by the time
-            # __proxied__ needs to be accessed, which results
-            # in an AttributeError here, which is swallowed
-            # somewere inside the security machinery,
-            # and then the object ends up using _defaultChecker
-            #
-            # Added the same code below, in ClassDescriptor,
-            # though I'm not sure it is really needed there.
-            if inst._p_state == GHOST:
-                inst._p_activate()
-            return selectChecker(inst.__proxied__)
-
-class ClassDescriptor:
-    """ ClassDescriptor is used by Struct to return the
-    real class for Struct when a class is being used, and return
-    the proxied object's class when its an instance.
-    """
-
-    def __get__(self, inst, cls=None):
-        if inst is None:
-            return cls
-        else:
-            if inst._p_state == GHOST:
-                inst._p_activate()
-            return inst.__proxied__.__class__
-
-
-# Put those attributes in a list so its easier to add/remove
-# when needed.
-struct_attrs = ['__proxied__',
-                '__dict__',
-                '__reduce_ex__',
-                '__reduce__',
-                '__getstate__',
-                '__setstate__',
-                '__Security_checker__']
-
-class Struct(Persistent):
-  """Wraps a non-persistent object, assuming that *all* changes are
-  made through external attribute assignments.
-  """
-
-  # XXX to do this right and expose both IPersistent and the
-  # underlying object's interfaces, we'd need to use a specialized
-  # descriptor.  This would create to great a dependency on
-  # zope.interface.
-
-  __class__ = ClassDescriptor()
-  __Security_checker__ = SecurityDescriptor()
-
-
-  def __init__(self, o):
-      self.__proxied__ = o
-
-  def __getattribute__(self, name):
-      if name.startswith('_p_') or name in struct_attrs:
-          v = Persistent.__getattribute__(self, name)
-          # Handle descriptors here, eg: __Security_checker__
-          # is a descriptor for Struct objects.
-          if hasattr(v, '__get__'):
-              return v.__get__(self, type(self))
-          return v
-      # XXX This is butt ugly. See the comment on SecurityDescriptor.
-      if self._p_state == GHOST:
-          self._p_activate()
-      proxied = self.__proxied__
-      v = getattr(proxied, name)
-      # And also handle descriptors for the proxied object,
-      # but using the proxied object on __get__ calls.
-      if hasattr(v, '__get__'):
-          # We should call it only if it came from the class,
-          # otherwise its a descriptor being used as an instance
-          # attribute, so just return it.
-          if (hasattr(proxied, '__class__') and
-              getattr(proxied.__class__, name) is v):
-              return v.__get__(proxied, type(proxied))
-      return v
-
-  def __setattr__(self, name, v):
-      if name.startswith('_p_') or name in struct_attrs:
-          return Persistent.__setattr__(self, name, v)
-      # Set _p_changed before calling the mutator on the
-      # proxied object, so we have the object marked
-      # as dirty even if an exception takes place later.
-      self._p_changed = 1
-      setattr(self.__proxied__, name, v)
-
-  def __delattr__(self, name):
-      if name.startswith('_p_') or name in struct_attrs:
-          return Persistent.__delattr__(self, name)
-      # Set _p_changed before deleting the attribute. See
-      # comment above, on __setattr__
-      self._p_changed = 1
-      delattr(self.__proxied__, name, v)
-

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/site/service.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/site/service.py	2004-06-03 19:23:57 UTC (rev 25240)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/site/service.py	2004-06-03 19:47:08 UTC (rev 25241)
@@ -27,7 +27,6 @@
 """
 import sys
 from transaction import get_transaction
-from zodbcode.module import PersistentModuleRegistry
 
 import zope.interface
 from zope.component.exceptions import ComponentLookupError
@@ -64,7 +63,6 @@
 
 class SiteManager(
     BTreeContainer,
-    PersistentModuleRegistry,
     ):
 
     zope.interface.implements(
@@ -78,7 +76,6 @@
         self.__parent__ = site
         self.__name__ = '++etc++site'
         BTreeContainer.__init__(self)
-        PersistentModuleRegistry.__init__(self)
         self.subSites = ()
         self._setNext(site)
         self['default'] = SiteManagementFolder()




More information about the Zope3-Checkins mailing list