Commit dd3fc0f3 authored by Chris McDonough's avatar Chris McDonough

Added new_or_existing method to StringKeyedHomogeneousItemContainer. Removed...

Added new_or_existing method to StringKeyedHomogeneousItemContainer.  Removed set method from StringKeyedHomogeneousItemContainer.
parent c859e075
...@@ -143,17 +143,26 @@ class HomogeneousItemContainer(Interface.Base): ...@@ -143,17 +143,26 @@ class HomogeneousItemContainer(Interface.Base):
""" """
class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer): class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
def set(self, k, v): def new(self, k):
""" """
Sets key k to value v. "k" must be a string, and "v" must support Creates a new subobject of the type supported by this container
the homogenous item container's subobject interface; a TypeError with key "k" and returns it.
is raised if either condition is untrue.
If an object already exists in the container with key "k", a
KeyError is raised.
"k" must be a string, else a TypeError is raised.
""" """
def new(self, k): def new_or_existing(self, k):
""" """
Creates a new subobject of the type supported by this container If an object already exists in the container with key "k", it
with key "k". "k" must be a string else a TypeError is raised. is returned.
Otherwiser, create a new subobject of the type supported by this
container with key "k" and return it.
"k" must be a string, else a TypeError is raised.
""" """
class TransientItemContainer(Interface.Base): class TransientItemContainer(Interface.Base):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment