[Zope3-checkins] CVS: Zope3/src/zope/app/utilities -
definition.pyc:1.1.2.2 schema.py:1.1.2.14
Sidnei da Silva
sidnei at x3ng.com.br
Wed Aug 13 19:56:56 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/utilities
In directory cvs.zope.org:/tmp/cvs-serv23336/src/zope/app/utilities
Modified Files:
Tag: dreamcatcher-ttwschema-branch
definition.pyc schema.py
Log Message:
Add MutableSchemaContent. Reorganize a bit the imports
=== Zope3/src/zope/app/utilities/definition.pyc 1.1.2.1 => 1.1.2.2 ===
=== Zope3/src/zope/app/utilities/schema.py 1.1.2.13 => 1.1.2.14 ===
--- Zope3/src/zope/app/utilities/schema.py:1.1.2.13 Wed Aug 13 15:53:46 2003
+++ Zope3/src/zope/app/utilities/schema.py Wed Aug 13 18:56:50 2003
@@ -15,10 +15,21 @@
$Id$
"""
+from persistence.dict import PersistentDict
+
+from zope.context import ContextMethod
+from zope.interface import implements
+from zope.interface import directlyProvides, directlyProvidedBy
+from zope.proxy import removeAllProxies
+from zope.publisher.browser import BrowserView
+from zope.schema import getFieldsInOrder, getFieldNamesInOrder
+from zope.security.proxy import trustedRemoveSecurityProxy
+from zope.component.exceptions import ComponentLookupError
+
from zope.app import zapi
+from zope.app.introspector import nameToInterface, interfaceToName
from zope.app.browser.container.adding import Adding
from zope.app.browser.form.editview import EditView
-from zope.app.context import ContextWrapper
from zope.app.form.utility import \
setUpEditWidgets, applyWidgetsChanges, setUpWidget
from zope.app.security.permission import PermissionField
@@ -32,14 +43,7 @@
from zope.app.services.interface import PersistentInterface
from zope.app.services.utility import UtilityRegistration
from zope.app.interfaces.utilities import IMutableSchema, ISchemaUtility
-from zope.component import getAdapter
-from zope.context import ContextMethod
-from zope.interface import implements
-from zope.proxy import removeAllProxies
-from zope.publisher.browser import BrowserView
-from zope.schema import getFieldsInOrder, getFieldNamesInOrder
-from zope.security.proxy import trustedRemoveSecurityProxy
-from persistence.dict import PersistentDict
+from zope.app.utilities.interfaces import IMutableSchemaContent
class SchemaUtility(PersistentInterfaceClass):
@@ -174,10 +178,10 @@
schema = property(_get_schema)
def _setUpWidgets(self):
- adapted = getAdapter(self.context, self.schema)
+ adapted = zapi.getAdapter(self.context, self.schema)
if adapted is not self.context:
- adapted = ContextWrapper(adapted, self.context, name='(adapted)')
- self.adapted = removeAllProxies(adapted)
+ adapted = zapi.ContextWrapper(adapted, self.context,
+ name='(adapted)')
setUpEditWidgets(self, self.schema, names=self.fieldNames,
content=self.adapted)
@@ -206,14 +210,34 @@
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)
activated = ContextMethod(activated)
-
+
def deactivated(self):
schema = self.getComponent()
schema.setName('<schema not activated>')
deactivated = ContextMethod(deactivated)
+class MutableSchemaContent:
+
+ implements(IMutableSchemaContent)
+
+ schema_id = None
+ zapi.ContextAwareDescriptors()
+
+ def _set_schema(self, iface):
+ directlyProvides(self, iface)
+ self.schema_id = interfaceToName(self, iface)
+
+ def _get_schema(self):
+ provided = list(directlyProvidedBy(self))
+ schema = self.schema_id and \
+ nameToInterface(self, self.schema_id) or None
+ if not schema in provided:
+ directlyProvides(self, schema)
+ return schema or provided and provided[0] or None
+
+ mutableschema = property(_get_schema, _set_schema)
More information about the Zope3-Checkins
mailing list