[Zope-CVS] CVS: Products/Ape/lib/apelib/core - interfaces.py:1.14
io.py:1.11 oidgen.py:1.3
Shane Hathaway
shane at zope.com
Fri Mar 26 10:53:18 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/core
In directory cvs.zope.org:/tmp/cvs-serv22823/lib/apelib/core
Modified Files:
interfaces.py io.py oidgen.py
Log Message:
Simplified OID generation.
The complexity existed to support path-based OIDs, but Ape no longer
needs path-based OIDs.
=== Products/Ape/lib/apelib/core/interfaces.py 1.13 => 1.14 ===
--- Products/Ape/lib/apelib/core/interfaces.py:1.13 Sat Mar 20 01:34:22 2004
+++ Products/Ape/lib/apelib/core/interfaces.py Fri Mar 26 10:52:48 2004
@@ -122,9 +122,11 @@
class IGatewayEvent (IMapperEvent):
"""Interface for events used by gateways."""
- connections = Attribute("connections", "A mapping of database connections")
+ connections = Attribute(
+ "connections", "A mapping of database connections")
- classification = Attribute("classification", "The classification of the object.")
+ classification = Attribute(
+ "classification", "The classification of the object.")
class ILoadEvent (IGatewayEvent):
@@ -433,26 +435,14 @@
class IOIDGenerator (Interface):
"""A utility for generating OIDs.
-
- Many serializers encode references to other objects, but it is
- desirable to not hard code the format of OIDs into
- ISerializer implementations. This utility, normally accessed
- through an IMapperEvent, allows OID knowledge to be kept in
- one place.
"""
root_oid = Attribute("root_oid", "The OID to use for the root")
- def new_oid(event, name, stored):
- """Returns a new oid.
-
- event is an ISDEvent or IGatewayEvent.
-
- name is the name of the subobject.
+ def new_oid(event):
+ """Returns a new oid, which should be a string.
- stored is a boolean indicating whether the returned oid will be
- stored. If it will not be stored, the generated oid can not
- be arbitrary.
+ event is an IGatewayEvent.
"""
=== Products/Ape/lib/apelib/core/io.py 1.10 => 1.11 ===
--- Products/Ape/lib/apelib/core/io.py:1.10 Sat Mar 20 01:34:22 2004
+++ Products/Ape/lib/apelib/core/io.py Fri Mar 26 10:52:48 2004
@@ -122,7 +122,7 @@
def new_oid(self):
event = GatewayEvent(self.conf, None, None, self.conn_map, None)
- return self.conf.oid_gen.new_oid(event, None, 1)
+ return self.conf.oid_gen.new_oid(event)
=== Products/Ape/lib/apelib/core/oidgen.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/core/oidgen.py:1.2 Mon Feb 2 10:07:18 2004
+++ Products/Ape/lib/apelib/core/oidgen.py Fri Mar 26 10:52:48 2004
@@ -16,34 +16,13 @@
$Id$
"""
-from apelib.core.interfaces import IOIDGenerator, MappingError
-
-
-class PathOIDGenerator:
- """Path-based OID generator
- """
- __implements__ = IOIDGenerator
-
- root_oid = "/_root"
-
- def __init__(self, root_oid="/_root"):
- self.root_oid = root_oid
-
- def new_oid(self, event, name, stored):
- if name is None:
- raise MappingError('Path OIDs require a name')
- if '/' in name:
- raise MappingError('%s is not a legal name in a path' % repr(name))
- p = str(event.oid) # parent OID
- if p.endswith('/'):
- p += name
- else:
- p = '%s/%s' % (p, name)
- return p
+from apelib.core.interfaces import IOIDGenerator, IGatewayEvent
class SerialOIDGenerator:
- """Generates OIDs in series.
+ """Minimal OID generator that generates OIDs in series.
+
+ Does not store the counter in non-volatile storage.
"""
__implements__ = IOIDGenerator
@@ -53,10 +32,8 @@
def __init__(self, root_oid="0"):
self.root_oid = root_oid
- def new_oid(self, event, name, stored):
- if not stored:
- raise MappingError('Serial OIDs must be stored')
+ def new_oid(self, event):
+ assert IGatewayEvent.isImplementedBy(event)
oid = str(self.counter)
self.counter += 1
return oid
-
More information about the Zope-CVS
mailing list