Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adopt plumber 1.2

  • Loading branch information...
commit 183922705311a8b24800d615fbd8a887c663a262 1 parent 6e84163
@rnixx rnixx authored
View
10 buildout.cfg
@@ -4,6 +4,16 @@ parts =
test
coverage
+extensions =
+ mr.developer
+
+sources = sources
+sources-dir = ${buildout:directory}/devsrc
+auto-checkout = *
+
+[sources]
+plumber = git git@github.com:bluedynamics/plumber.git
+
[test]
recipe = zc.recipe.testrunner
eggs =
View
2  setup.py
@@ -32,7 +32,7 @@
'odict',
'plumber',
'zope.lifecycleevent',
- 'zope.deprecation', # can be removed soon
+ 'zope.deprecation',
],
extras_require={
'py24': [
View
3  src/node/base.py
@@ -1,8 +1,5 @@
from odict import odict
from plumber import plumber
-from plumber import Part
-from plumber import default
-from plumber import extend
from node.interfaces import INode
from node.behaviors import Adopt
from node.behaviors import Nodespaces
View
4 src/node/behaviors/alias.py
@@ -2,7 +2,7 @@
from plumber import plumber
from plumber import default
from plumber import plumb
-from plumber import Part
+from plumber import Behavior
from zope.interface import implementer
from zope.interface.common.mapping import IEnumerableMapping
from zope.interface.common.mapping import IFullMapping
@@ -119,7 +119,7 @@ def __init__(self, prefix=None, suffix=None):
@implementer(IAlias)
-class Alias(Part):
+class Alias(Behavior):
aliaser = default(None)
@plumb
View
4 src/node/behaviors/attributes.py
@@ -2,7 +2,7 @@
from plumber import plumb
from plumber import finalize
from plumber import default
-from plumber import Part
+from plumber import Behavior
from node.interfaces import IAttributes
from node.behaviors.common import Adopt
from node.behaviors.common import NodeChildValidate
@@ -36,7 +36,7 @@ def __repr__(self):
@implementer(IAttributes)
-class Attributes(Part):
+class Attributes(Behavior):
attribute_access_for_attrs = default(False)
attributes_factory = default(NodeAttributes)
View
6 src/node/behaviors/cache.py
@@ -1,4 +1,4 @@
-from plumber import Part
+from plumber import Behavior
from plumber import default
from plumber import plumb
from node.interfaces import IInvalidate
@@ -8,7 +8,7 @@
@implementer(IInvalidate)
-class Invalidate(Part):
+class Invalidate(Behavior):
"""Plumbing behavior for invalidation.
This basic implementation assumes that nodes using this behavior are NOT
@@ -28,7 +28,7 @@ def invalidate(self, key=None):
@implementer(ICache)
-class Cache(Part):
+class Cache(Behavior):
@default
@instance_property
View
26 src/node/behaviors/common.py
@@ -1,9 +1,9 @@
import uuid
import inspect
from odict import odict
-from plumber import Part
+from plumber import Behavior
from plumber import default
-from plumber import extend
+from plumber import override
from plumber import finalize
from plumber import plumb
from zope.interface import implementer
@@ -23,7 +23,7 @@
@implementer(IAdopt)
-class Adopt(Part):
+class Adopt(Behavior):
@plumb
def __setitem__(_next, self, key, val):
@@ -56,7 +56,7 @@ def setdefault(_next, self, key, default=None):
@implementer(IAsAttrAccess)
-class AsAttrAccess(Part):
+class AsAttrAccess(Behavior):
@default
def as_attribute_access(self):
@@ -64,14 +64,14 @@ def as_attribute_access(self):
@implementer(IChildFactory)
-class ChildFactory(Part):
+class ChildFactory(Behavior):
factories = default(odict())
- @extend
+ @override
def __iter__(self):
return self.factories.__iter__()
- iterkeys = extend(__iter__)
+ iterkeys = override(__iter__)
@plumb
def __getitem__(_next, self, key):
@@ -84,8 +84,8 @@ def __getitem__(_next, self, key):
@implementer(IFixedChildren)
-class FixedChildren(Part):
- """Part that initializes a fixed dictionary as children
+class FixedChildren(Behavior):
+ """Behavior that initializes a fixed dictionary as children
The children are instantiated during __init__ and adopted by the
class using this behavior. They cannot receive init argumentes, but
@@ -124,7 +124,7 @@ def __setitem__(self, key, val):
@implementer(IGetattrChildren)
-class GetattrChildren(Part):
+class GetattrChildren(Behavior):
"""Access children via ``__getattr__``, given the attribute name is unused.
XXX: Similar behavior as AsAttrAccess. harmonize.
@@ -139,7 +139,7 @@ def __getattr__(self, name):
@implementer(INodeChildValidate)
-class NodeChildValidate(Part):
+class NodeChildValidate(Behavior):
allow_non_node_childs = default(False)
@plumb
@@ -152,7 +152,7 @@ def __setitem__(_next, self, key, val):
@implementer(IUnicodeAware)
-class UnicodeAware(Part):
+class UnicodeAware(Behavior):
# XXX: It feels here it would be nice to be able to get an instance of a
# plumbing to configure the codec.
@@ -178,7 +178,7 @@ def __setitem__(_next, self, key, val):
@implementer(IUUIDAware)
-class UUIDAware(Part):
+class UUIDAware(Behavior):
uuid = default(None)
overwrite_recursiv_on_copy = default(True)
View
2  src/node/behaviors/common.rst
@@ -326,7 +326,7 @@ Only children not shadowed by real attributes can be accessed via getattr::
2
XXX: The base class' getattr does not work anymore. plumber directive
- plumborextend could solve this together with support for multiple
+ plumbor override could solve this together with support for multiple
behaviors hooking into __getattr__. -cfl
Thats why i prefer AttributeAccess explicit for attribute access on node
View
6 src/node/behaviors/lifecycle.py
@@ -1,6 +1,6 @@
from plumber import default
from plumber import plumb
-from plumber import Part
+from plumber import Behavior
from zope.interface import implementer
from node.interfaces import ILifecycle
from node.interfaces import IAttributesLifecycle
@@ -18,7 +18,7 @@
@implementer(ILifecycle)
-class Lifecycle(Part):
+class Lifecycle(Behavior):
events = default({
'created': NodeCreatedEvent,
@@ -63,7 +63,7 @@ def detach(_next, self, key):
@implementer(IAttributesLifecycle)
-class AttributesLifecycle(Part):
+class AttributesLifecycle(Behavior):
@plumb
def __setitem__(_next, self, key, val):
View
12 src/node/behaviors/mapping.py
@@ -1,7 +1,7 @@
import copy
-from plumber import Part
+from plumber import Behavior
from plumber import default
-from plumber import extend
+from plumber import override
from node.utils import Unset
from zope.interface import implementer
from zope.interface.common.mapping import IItemMapping
@@ -17,7 +17,7 @@
@implementer(IItemMapping)
-class ItemMapping(Part):
+class ItemMapping(Behavior):
"""Simplest readable mapping object
"""
@@ -44,7 +44,7 @@ def get(self, key, default=None):
def __contains__(self, key):
"""Uses ``__getitem__``.
- This should be overriden by storages (using extend), where
+ This should be overriden by storages (using override), where
``__getitem__`` is expensive.
XXX: also catching the exception is expensive, so this should be
@@ -58,7 +58,7 @@ def __contains__(self, key):
@implementer(IWriteMapping)
-class WriteMapping(Part):
+class WriteMapping(Behavior):
"""Mapping methods for changing data
"""
@@ -144,7 +144,7 @@ def iteritems(self):
@implementer(IClonableMapping)
-class ClonableMapping(Part):
+class ClonableMapping(Behavior):
@default
def copy(self):
View
4 src/node/behaviors/nodespace.py
@@ -2,14 +2,14 @@
from plumber import plumb
from plumber import finalize
from plumber import default
-from plumber import Part
+from plumber import Behavior
from zope.interface import implementer
from node.interfaces import INode
from node.interfaces import INodespaces
@implementer(INodespaces)
-class Nodespaces(Part):
+class Nodespaces(Behavior):
_nodespaces = default(None)
@finalize
View
34 src/node/behaviors/nodify.py
@@ -1,7 +1,7 @@
from plumber import default
-from plumber import extend
+from plumber import override
from plumber import plumb
-from plumber import Part
+from plumber import Behavior
from zope.interface import implementer
from zope.interface.interfaces import IInterface
from node.interfaces import IDefaultInit
@@ -13,9 +13,9 @@
@implementer(IDefaultInit)
-class DefaultInit(Part):
+class DefaultInit(Behavior):
- @extend
+ @override
def __init__(self, name=None, parent=None):
self.__name__ = name
self.__parent__ = parent
@@ -33,24 +33,24 @@ def copy(_next, self):
new.__parent__ = self.__parent__
return new
- @extend
+ @override
@property
def name(self):
return self.__name__
- @extend
+ @override
@property
def parent(self):
return self.__parent__
- @extend
+ @override
@property
def path(self):
path = [parent.name for parent in LocationIterator(self)]
path.reverse()
return path
- @extend
+ @override
@property
def root(self):
root = None
@@ -58,13 +58,13 @@ def root(self):
root = parent
return root
- @extend
+ @override
def detach(self, key):
node = self[key]
del self[key]
return node
- @extend
+ @override
def acquire(self, interface):
node = self.parent
while node:
@@ -74,7 +74,7 @@ def acquire(self, interface):
return node
node = node.parent
- @extend
+ @override
def filtereditervalues(self, interface):
"""Uses ``itervalues``.
"""
@@ -82,16 +82,16 @@ def filtereditervalues(self, interface):
if interface.providedBy(val):
yield val
- @extend
+ @override
def filteredvalues(self, interface):
"""Uses ``values``.
"""
return [val for val in self.filtereditervalues(interface)]
# BBB 2010-12-23
- filtereditems = extend(filtereditervalues)
+ filtereditems = override(filtereditervalues)
- @extend
+ @override
@property
def noderepr(self):
"""``noderepr`` is used in ``printtree``.
@@ -113,7 +113,7 @@ def noderepr(self):
name = unicode(self.__name__).encode('ascii', 'replace')
return str(class_) + ': ' + name[name.find(':') + 1:]
- @extend
+ @override
def printtree(self, indent=0):
"""Uses ``values``.
"""
@@ -135,7 +135,7 @@ def printtree(self, indent=0):
def __nonzero__(self):
return True
- @extend
+ @override
def __repr__(self):
# XXX: is this a relict from plumber prototyping? -rn
#if hasattr(self.__class__, '_wrapped'):
@@ -151,4 +151,4 @@ def __repr__(self):
name,
hex(id(self))[:-1])
- __str__ = extend(__repr__)
+ __str__ = override(__repr__)
View
22 src/node/behaviors/order.py
@@ -1,6 +1,6 @@
from odict.pyodict import _nil
-from plumber import extend
-from plumber import Part
+from plumber import override
+from plumber import Behavior
from zope.interface import implementer
from zope.interface.common.mapping import IReadMapping
from node.interfaces import INode
@@ -9,9 +9,9 @@
@implementer(IOrder)
-class Order(Part):
+class Order(Behavior):
- @extend
+ @override
def swap(self, node_a, node_b):
dict_impl = self.storage._dict_impl()
orgin_a = dict_impl.__getitem__(self.storage, node_a.name)
@@ -43,7 +43,7 @@ def swap(self, node_a, node_b):
if new_b[2] == _nil:
self.storage.lt = new_b[1].name
- @extend
+ @override
def insertfirst(self, newnode):
keys = self.keys()
if not keys:
@@ -52,7 +52,7 @@ def insertfirst(self, newnode):
refnode = self[keys[0]]
self.insertbefore(newnode, refnode)
- @extend
+ @override
def insertlast(self, newnode):
keys = self.keys()
if not keys:
@@ -61,7 +61,7 @@ def insertlast(self, newnode):
refnode = self[keys[-1]]
self.insertafter(newnode, refnode)
- @extend
+ @override
def insertbefore(self, newnode, refnode):
self._validateinsertion(newnode, refnode)
nodekey = newnode.__name__
@@ -84,7 +84,7 @@ def insertbefore(self, newnode, refnode):
dict_impl.__setitem__(storage, nodekey, newnode)
self[nodekey] = newnode[1]
- @extend
+ @override
def insertafter(self, newnode, refnode):
self._validateinsertion(newnode, refnode)
nodekey = newnode.__name__
@@ -108,12 +108,12 @@ def insertafter(self, newnode, refnode):
dict_impl.__setitem__(storage, nodekey, newnode)
self[nodekey] = newnode[1]
- @extend
+ @override
def _validateinsertion(self, newnode, refnode):
nodekey = newnode.__name__
if nodekey is None:
raise ValueError, u"Given node has no __name__ set."
- # case if Reference Part is mixed in
+ # case if Reference behavior is mixed in
# XXX: move out of here
if hasattr(self, 'node'):
if self.node(newnode.uuid) is not None:
@@ -122,7 +122,7 @@ def _validateinsertion(self, newnode, refnode):
if index is None:
raise ValueError, u"Given reference node not child of self."
- @extend
+ @override
def _nodeindex(self, node):
index = 0
for key in self.keys():
View
12 src/node/behaviors/reference.py
@@ -1,8 +1,8 @@
import uuid
from plumber import plumb
-from plumber import extend
+from plumber import override
from plumber import default
-from plumber import Part
+from plumber import Behavior
from zope.interface import implementer
from zope.interface.common.mapping import IReadMapping
from node.interfaces import INode
@@ -26,7 +26,7 @@ def __contains__(self, key):
@implementer(IReference)
-class Reference(Part):
+class Reference(Behavior):
_uuid = default(None)
@plumb
@@ -80,14 +80,14 @@ def _set_uuid(self, uuid):
self._index[iuuid] = self
self._uuid = uuid
- uuid = extend(property(_get_uuid, _set_uuid))
+ uuid = override(property(_get_uuid, _set_uuid))
- @extend
+ @override
@property
def index(self):
return NodeIndex(self._index)
- @extend
+ @override
def node(self, uuid):
return self._index.get(int(uuid))
View
14 src/node/behaviors/storage.py
@@ -1,7 +1,7 @@
from odict import odict
from plumber import default
-from plumber import extend
-from plumber import Part
+from plumber import override
+from plumber import Behavior
from node.interfaces import IStorage
from node.interfaces import IOrdered
from node.utils import instance_property
@@ -9,7 +9,7 @@
@implementer(IStorage)
-class Storage(Part):
+class Storage(Behavior):
@default
@property
@@ -17,19 +17,19 @@ def storage(self):
raise NotImplementedError(u"Abstract storage does not implement "
u"``storage``")
- @extend
+ @override
def __getitem__(self, key):
return self.storage[key]
- @extend
+ @override
def __delitem__(self, key):
del self.storage[key]
- @extend
+ @override
def __setitem__(self, key, val):
self.storage[key] = val
- @extend
+ @override
def __iter__(self):
return self.storage.__iter__()
Please sign in to comment.
Something went wrong with that request. Please try again.