add assign/ deassignParent wrapper for resources; add adapterIndexAttributes + keywords index adapter lookup for resources
This commit is contained in:
parent
9ec755ecd3
commit
fbf4efc40c
1 changed files with 23 additions and 1 deletions
24
resource.py
24
resource.py
|
@ -227,8 +227,14 @@ class Resource(Image, Contained):
|
||||||
obj = getMaster(self)
|
obj = getMaster(self)
|
||||||
concept.deassignResource(obj, predicates)
|
concept.deassignResource(obj, predicates)
|
||||||
|
|
||||||
# ISized interface
|
def assignParent(self, concept, predicate=None, order=0, relevance=1.0):
|
||||||
|
self.assignConcept(concept, predicate=predicate, order=order,
|
||||||
|
relevance=relevance)
|
||||||
|
|
||||||
|
def deassignParent(self, parent, predicates=None, noSecurityCheck=False):
|
||||||
|
self.deassignConcept(parent, predicates=predicates)
|
||||||
|
|
||||||
|
# ISized interface
|
||||||
def getSize(self):
|
def getSize(self):
|
||||||
if self._size:
|
if self._size:
|
||||||
return self._size
|
return self._size
|
||||||
|
@ -538,6 +544,17 @@ class IndexAttributes(object):
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def adapted(self):
|
||||||
|
return adapted(self.context)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def adaptedIndexAttributes(self):
|
||||||
|
#if self.adapted != self.context:
|
||||||
|
if isinstance(self.adapted, ResourceAdapterBase):
|
||||||
|
#return component.queryAdapter(self.adapted, IIndexAttributes)
|
||||||
|
return IIndexAttributes(self.adapted, None)
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
actx = adapted(self.context)
|
actx = adapted(self.context)
|
||||||
txt = transformToText(actx)
|
txt = transformToText(actx)
|
||||||
|
@ -590,6 +607,11 @@ class IndexAttributes(object):
|
||||||
def identifier(self):
|
def identifier(self):
|
||||||
return getName(self.context)
|
return getName(self.context)
|
||||||
|
|
||||||
|
def keywords(self):
|
||||||
|
if self.adaptedIndexAttributes is not None:
|
||||||
|
return self.adaptedIndexAttributes.keywords()
|
||||||
|
|
||||||
|
|
||||||
def transformToText(obj, data=None, contentType=None):
|
def transformToText(obj, data=None, contentType=None):
|
||||||
if data is None:
|
if data is None:
|
||||||
data = obj.data
|
data = obj.data
|
||||||
|
|
Loading…
Add table
Reference in a new issue