From 01bd976a198061945fc4f47a6fb6d584daa42dc3 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 10 Nov 2008 13:57:10 +0000 Subject: [PATCH] add 'container' attribute to TypeInstances classes git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2972 fd906abe-77d9-0310-91a1-e0d9ade77398 --- common.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common.py b/common.py index 4099081..be4bd69 100644 --- a/common.py +++ b/common.py @@ -227,11 +227,15 @@ class TypeInstances(object): langInfo = None - def __init__(self, context, typeName, idAttr='name', prefix=''): + def __init__(self, context, typeName, idAttr='name', prefix='', container=None): self.context = context self.typeName = typeName self.idAttr = idAttr self.prefix = prefix + if container is None: + self.container = context + else: + self.container = context.getLoopsRoot()[container] @Lazy def typeConcept(self): @@ -250,7 +254,7 @@ class TypeInstances(object): from loops.setup import addAndConfigureObject if self.idAttr != 'name' and self.idAttr not in kw: kw[self.idAttr] = id - c = addAndConfigureObject(self.context, Concept, self.prefix + id, + c = addAndConfigureObject(self.container, Concept, self.prefix + id, conceptType=self.typeConcept, **kw) return adapted(c) @@ -338,15 +342,17 @@ class ChildRelationSet(RelationSet): class TypeInstancesProperty(object): - def __init__(self, typeName, idAttr='name', prefix=''): + def __init__(self, typeName, idAttr='name', prefix='', container=None): self.typeName = typeName self.idAttr = idAttr self.prefix = prefix + self.container = container def __get__(self, inst, class_=None): if inst is None: return self - return TypeInstances(inst.context, self.typeName, self.idAttr, self.prefix) + return TypeInstances(inst.context, self.typeName, self.idAttr, + self.prefix, self.container) class RelationSetProperty(object):