renamed Position to RequirementProfile

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1228 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-05-26 07:48:08 +00:00
parent cc1b0e4585
commit 5f5a200ce1
4 changed files with 18 additions and 23 deletions

View file

@ -39,17 +39,17 @@ Now we create a person that knows about basic Python programming:
>>> john = Knowing() >>> john = Knowing()
>>> john.knows(pyBasics) >>> john.knows(pyBasics)
Next we have a position that requires knowledge in object-oriented Next we have a requirement profile for knowledge in object-oriented
programming with Python: programming with Python:
>>> from cybertools.knowledge.position import Position >>> from cybertools.knowledge.requirement import RequirementProfile
>>> pos01 = Position() >>> req01 = RequirementProfile()
>>> pos01.requires(pyOo) >>> req01.requires(pyOo)
Now we can ask what knowledge john is lacking if he would like to take Now we can ask what knowledge john is lacking if he would like to take
the position offered: a position with the requirement profile:
>>> missing = john.getMissingKnowledge(pos01) >>> missing = john.getMissingKnowledge(req01)
>>> missing >>> missing
(<...KnowledgeElement...>, <...KnowledgeElement...>) (<...KnowledgeElement...>, <...KnowledgeElement...>)
@ -69,10 +69,9 @@ provide some of the knowledge needed:
So that we are now able to find out what john has to study in order to So that we are now able to find out what john has to study in order to
fulfill the position offered: fulfill the position offered:
>>> prov = list(john.getProvidersNeeded(pos01)) >>> prov = list(john.getProvidersNeeded(req01))
>>> len(prov) >>> len(prov)
2 2
>>> [d[0] for k, d in prov] == [doc01, doc02] >>> [d[0] for k, d in prov] == [doc01, doc02]
True True

View file

@ -37,7 +37,6 @@ class KnowledgeElement(object):
self._children = set() self._children = set()
self._dependents = set() self._dependents = set()
self._knowers = set() self._knowers = set()
self._requiringPositions = set()
self._providers = set() self._providers = set()
def setParent(self, obj): def setParent(self, obj):

View file

@ -84,21 +84,22 @@ class IKnowing(Interface):
that constitute the knowledge of this object. that constitute the knowledge of this object.
""" """
def getMissingKnowledge(position): def getMissingKnowledge(profile):
""" Return a tuple of knowledge elements that this object """ Return a tuple of knowledge elements that this object
is missing for fulfilling the position given. is missing for fulfilling the requirement profile given.
""" """
def getProvidersNeeded(position): def getProvidersNeeded(profile):
""" Return a tuple of tuples: Each tuple has as its first element """ Return a tuple of tuples: Each tuple has as its first element
a requirement of the position, the second element is a tuple a requirement of the profile, the second element is a tuple
of the knowledge providers providing this knowledge of the knowledge providers providing this knowledge
((requirement, (provider, ...,)), ...). ((requirement, (provider, ...,)), ...).
""" """
class IPosition(Interface): class IRequirementProfile(Interface):
""" A position requires a certain knowledge. """ A collection of certain knowledge e.g. needed to work on certain
position or for a certain task.
""" """
def getRequirements(): def getRequirements():
@ -110,7 +111,7 @@ class IPosition(Interface):
object requires. object requires.
""" """
def removeKnowledge(element): def removeRequirement(element):
""" Remove the element given from the collection of elements """ Remove the element given from the collection of elements
this object requires. this object requires.
""" """
@ -135,5 +136,3 @@ class IKnowledgeProvider(Interface):
this object provides. this object provides.
""" """

View file

@ -23,12 +23,12 @@ $Id$
""" """
from zope.interface import implements from zope.interface import implements
from cybertools.knowledge.interfaces import IPosition from cybertools.knowledge.interfaces import IRequirementProfile
class Position(object): class RequirementProfile(object):
implements(IPosition) implements(IRequirementProfile)
def __init__(self): def __init__(self):
self._requirements = {} self._requirements = {}
@ -38,9 +38,7 @@ class Position(object):
def requires(self, obj): def requires(self, obj):
self._requirements[obj] = True self._requirements[obj] = True
obj._requiringPositions.add(self)
def removeRequirement(self, obj): def removeRequirement(self, obj):
del self._requirements[obj] del self._requirements[obj]
del obj._requiringPositions[self]