add 'container' attribute to TypeInstances classes
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2972 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
429b6ececb
commit
01bd976a19
1 changed files with 10 additions and 4 deletions
14
common.py
14
common.py
|
@ -227,11 +227,15 @@ class TypeInstances(object):
|
||||||
|
|
||||||
langInfo = None
|
langInfo = None
|
||||||
|
|
||||||
def __init__(self, context, typeName, idAttr='name', prefix=''):
|
def __init__(self, context, typeName, idAttr='name', prefix='', container=None):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.typeName = typeName
|
self.typeName = typeName
|
||||||
self.idAttr = idAttr
|
self.idAttr = idAttr
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
if container is None:
|
||||||
|
self.container = context
|
||||||
|
else:
|
||||||
|
self.container = context.getLoopsRoot()[container]
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def typeConcept(self):
|
def typeConcept(self):
|
||||||
|
@ -250,7 +254,7 @@ class TypeInstances(object):
|
||||||
from loops.setup import addAndConfigureObject
|
from loops.setup import addAndConfigureObject
|
||||||
if self.idAttr != 'name' and self.idAttr not in kw:
|
if self.idAttr != 'name' and self.idAttr not in kw:
|
||||||
kw[self.idAttr] = id
|
kw[self.idAttr] = id
|
||||||
c = addAndConfigureObject(self.context, Concept, self.prefix + id,
|
c = addAndConfigureObject(self.container, Concept, self.prefix + id,
|
||||||
conceptType=self.typeConcept, **kw)
|
conceptType=self.typeConcept, **kw)
|
||||||
return adapted(c)
|
return adapted(c)
|
||||||
|
|
||||||
|
@ -338,15 +342,17 @@ class ChildRelationSet(RelationSet):
|
||||||
|
|
||||||
class TypeInstancesProperty(object):
|
class TypeInstancesProperty(object):
|
||||||
|
|
||||||
def __init__(self, typeName, idAttr='name', prefix=''):
|
def __init__(self, typeName, idAttr='name', prefix='', container=None):
|
||||||
self.typeName = typeName
|
self.typeName = typeName
|
||||||
self.idAttr = idAttr
|
self.idAttr = idAttr
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
self.container = container
|
||||||
|
|
||||||
def __get__(self, inst, class_=None):
|
def __get__(self, inst, class_=None):
|
||||||
if inst is None:
|
if inst is None:
|
||||||
return self
|
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):
|
class RelationSetProperty(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue