working: link to parents from other loops sites: query and assign type instances from foreign site
This commit is contained in:
parent
349dc89bb8
commit
ccb4673268
3 changed files with 16 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,14 +19,12 @@
|
||||||
"""
|
"""
|
||||||
Definition of basic view classes and other browser related stuff for the
|
Definition of basic view classes and other browser related stuff for the
|
||||||
loops.expert package.
|
loops.expert package.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import interface, component
|
from zope import interface, component
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.traversing.api import getName, getParent
|
from zope.traversing.api import getName, getParent, traverse
|
||||||
|
|
||||||
from cybertools.browser.form import FormController
|
from cybertools.browser.form import FormController
|
||||||
from cybertools.stateful.interfaces import IStateful, IStatesDefinition
|
from cybertools.stateful.interfaces import IStateful, IStatesDefinition
|
||||||
|
@ -150,12 +148,16 @@ class Search(ConceptView):
|
||||||
if not isinstance(types, (list, tuple)):
|
if not isinstance(types, (list, tuple)):
|
||||||
types = [types]
|
types = [types]
|
||||||
for type in types:
|
for type in types:
|
||||||
|
site = self.loopsRoot
|
||||||
|
if type.startswith('/'):
|
||||||
|
parts = type.split(':')
|
||||||
|
site = traverse(self.loopsRoot, parts[0], site)
|
||||||
result = self.executeQuery(title=title or None, type=type,
|
result = self.executeQuery(title=title or None, type=type,
|
||||||
exclude=('hidden',))
|
exclude=('hidden',))
|
||||||
fv = FilterView(self.context, self.request)
|
fv = FilterView(self.context, self.request)
|
||||||
result = fv.apply(result)
|
result = fv.apply(result)
|
||||||
for o in result:
|
for o in result:
|
||||||
if o.getLoopsRoot() == self.loopsRoot:
|
if o.getLoopsRoot() == site:
|
||||||
adObj = adapted(o, self.languageInfo)
|
adObj = adapted(o, self.languageInfo)
|
||||||
if filterMethod is not None and not filterMethod(adObj):
|
if filterMethod is not None and not filterMethod(adObj):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Query concepts management stuff.
|
Query concepts management stuff.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from BTrees.IOBTree import IOBTree
|
from BTrees.IOBTree import IOBTree
|
||||||
|
@ -29,6 +27,7 @@ from zope.interface import Interface, Attribute, implements
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
from zope.app.intid.interfaces import IIntIds
|
from zope.app.intid.interfaces import IIntIds
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
from zope.traversing.api import traverse
|
||||||
|
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from loops.common import AdapterBase
|
from loops.common import AdapterBase
|
||||||
|
@ -66,6 +65,11 @@ class BaseQuery(object):
|
||||||
return self.context.context.getLoopsRoot()
|
return self.context.context.getLoopsRoot()
|
||||||
|
|
||||||
def queryConcepts(self, title=None, type=None, **kw):
|
def queryConcepts(self, title=None, type=None, **kw):
|
||||||
|
site = self.loopsRoot
|
||||||
|
if type.startswith('/'):
|
||||||
|
parts = type.split(':')
|
||||||
|
site = traverse(self.loopsRoot, parts[0], site)
|
||||||
|
type = 'loops:' + ':'.join(parts[1:])
|
||||||
if type.endswith('*'):
|
if type.endswith('*'):
|
||||||
start = type[:-1]
|
start = type[:-1]
|
||||||
end = start + '\x7f'
|
end = start + '\x7f'
|
||||||
|
@ -76,7 +80,7 @@ class BaseQuery(object):
|
||||||
result = cat.searchResults(loops_type=(start, end), loops_title=title)
|
result = cat.searchResults(loops_type=(start, end), loops_title=title)
|
||||||
else:
|
else:
|
||||||
result = cat.searchResults(loops_type=(start, end))
|
result = cat.searchResults(loops_type=(start, end))
|
||||||
result = set(r for r in result if r.getLoopsRoot() == self.loopsRoot
|
result = set(r for r in result if r.getLoopsRoot() == site
|
||||||
and canListObject(r))
|
and canListObject(r))
|
||||||
if 'exclude' in kw:
|
if 'exclude' in kw:
|
||||||
r1 = set()
|
r1 = set()
|
||||||
|
|
2
type.py
2
type.py
|
@ -68,7 +68,7 @@ class LoopsType(BaseType):
|
||||||
tp = self.typeProvider
|
tp = self.typeProvider
|
||||||
typeName = tp is None and 'unknown' or str(getName(tp))
|
typeName = tp is None and 'unknown' or str(getName(tp))
|
||||||
if self.isForeignReference:
|
if self.isForeignReference:
|
||||||
root = '/'.join(getPath(self.root))
|
root = getPath(self.root)
|
||||||
else:
|
else:
|
||||||
root = 'loops'
|
root = 'loops'
|
||||||
return ':'.join((root, self.qualifiers[0], typeName,))
|
return ':'.join((root, self.qualifiers[0], typeName,))
|
||||||
|
|
Loading…
Add table
Reference in a new issue