Merge branch 'master' into bbmaster
This commit is contained in:
commit
335c52e3cb
8 changed files with 78 additions and 21 deletions
|
@ -28,7 +28,6 @@
|
|||
<div metal:use-macro="views/node_macros/object_actions" />
|
||||
</tal:actions>
|
||||
<h1 tal:attributes="ondblclick item/openEditWindow">
|
||||
<a name="top" />
|
||||
<a tal:omit-tag="python: level > 1"
|
||||
tal:attributes="href request/URL"
|
||||
tal:content="item/title">Title</a>
|
||||
|
|
25
concept.py
25
concept.py
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Definition of the Concept and related classes.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import component, schema
|
||||
|
@ -209,9 +207,26 @@ class Concept(Contained, Persistent):
|
|||
return [r.first for r in self.getParentRelations(predicates, sort=sort,
|
||||
noSecurityCheck=noSecurityCheck)]
|
||||
|
||||
def assignChild(self, concept, predicate=None, order=0, relevance=1.0):
|
||||
def checkPredicate(self, child, predicate=None):
|
||||
cm = self.getConceptManager()
|
||||
defaultPredicate = cm.getDefaultPredicate()
|
||||
if predicate is None:
|
||||
predicate = self.getConceptManager().getDefaultPredicate()
|
||||
predicate = defaultPredicate
|
||||
if predicate == defaultPredicate:
|
||||
subtypePred = cm.get('issubtype')
|
||||
if subtypePred is not None:
|
||||
subtypeRels = list(self.conceptType.getChildRelations(
|
||||
[subtypePred], child.conceptType))
|
||||
if subtypeRels:
|
||||
from loops.predicate import adaptedRelation
|
||||
rel = adaptedRelation(subtypeRels[0])
|
||||
predName = rel.usePredicate
|
||||
if predName and predName != u'standard':
|
||||
predicate = cm[predName]
|
||||
return predicate
|
||||
|
||||
def assignChild(self, concept, predicate=None, order=0, relevance=1.0):
|
||||
predicate = self.checkPredicate(concept, predicate)
|
||||
registry = component.getUtility(IRelationRegistry)
|
||||
rel = ConceptRelation(self, concept, predicate)
|
||||
if order != 0:
|
||||
|
|
|
@ -263,6 +263,15 @@
|
|||
set_schema="loops.interfaces.IPredicate" />
|
||||
</class>
|
||||
|
||||
<adapter factory="loops.predicate.IsSubtype"
|
||||
provides="loops.interfaces.IIsSubtype" trusted="True" />
|
||||
<class class="loops.predicate.IsSubtype">
|
||||
<require permission="zope.View"
|
||||
interface="loops.interfaces.IIsSubtype" />
|
||||
<require permission="zope.ManageContent"
|
||||
set_schema="loops.interfaces.IIsSubtype" />
|
||||
</class>
|
||||
|
||||
<!--<adapter factory="loops.predicate.MappingAttributeRelation" trusted="True" />
|
||||
<class class="loops.predicate.MappingAttributeRelation">
|
||||
<require permission="zope.View"
|
||||
|
|
19
external/element.py
vendored
19
external/element.py
vendored
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
|
@ -19,8 +19,6 @@
|
|||
"""
|
||||
Basic implementation of the elements used for the intermediate format for export
|
||||
and import of loops objects.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
import os
|
||||
|
@ -38,6 +36,7 @@ from loops.interfaces import IConceptSchema
|
|||
from loops.external.interfaces import IElement
|
||||
from loops.i18n.common import I18NValue
|
||||
from loops.layout.base import LayoutNode
|
||||
from loops.predicate import adaptedRelation
|
||||
from loops.view import Node
|
||||
|
||||
|
||||
|
@ -138,14 +137,26 @@ class ChildElement(Element):
|
|||
elementType = 'child'
|
||||
posArgs = ('first', 'second', 'predicate', 'order', 'relevance')
|
||||
|
||||
def __init__(self, *args):
|
||||
def __init__(self, *args, **kw):
|
||||
for idx, arg in enumerate(args):
|
||||
self[self.posArgs[idx]] = arg
|
||||
for k, v in kw.items():
|
||||
self[k] = v
|
||||
|
||||
def execute(self, loader):
|
||||
loader.assignChild(self['first'], self['second'], self['predicate'],
|
||||
order = self.get('order') or 0,
|
||||
relevance = self.get('relevance') or 1.0)
|
||||
additionalParams = [(k, v) for k, v in self.items()
|
||||
if k not in self.posArgs]
|
||||
if additionalParams:
|
||||
pred = loader.getPredicate(self['predicate'])
|
||||
first = loader.concepts[self['first']]
|
||||
second = loader.concepts[self['second']]
|
||||
relation = first.getChildRelations([pred], child=second)[0]
|
||||
adaptedRel = adaptedRelation(relation)
|
||||
for attr, value in additionalParams:
|
||||
setattr(adaptedRel, attr, value)
|
||||
|
||||
|
||||
class ResourceElement(Element):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
loops interface definitions.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import Interface, Attribute
|
||||
|
@ -761,6 +759,16 @@ class IRelationAdapter(Interface):
|
|||
"""
|
||||
|
||||
|
||||
class IIsSubtype(IRelationAdapter):
|
||||
|
||||
usePredicate = schema.TextLine(
|
||||
title=_(u'Use Predicate'),
|
||||
description=_(u'The name of the predicate that should be used'
|
||||
u'for relations between concepts of these types.'),
|
||||
default=u'standard',
|
||||
required=False)
|
||||
|
||||
|
||||
# probably not useful
|
||||
class xxIMappingAttributeRelation(IConceptSchema):
|
||||
""" A relation based on a predicate ('mappingAttribute') that provides
|
||||
|
|
21
predicate.py
21
predicate.py
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Definition and management of special predicates and corresponding relations.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import component, schema
|
||||
|
@ -31,7 +29,8 @@ from zope.security.proxy import removeSecurityProxy
|
|||
from zope.traversing.api import getName
|
||||
|
||||
from loops.interfaces import ILoopsObject, IConcept, IResource, IConceptRelation
|
||||
from loops.interfaces import IPredicate, IRelationAdapter #, IMappingAttributeRelation
|
||||
from loops.interfaces import IPredicate, IRelationAdapter
|
||||
from loops.interfaces import IIsSubtype #, IMappingAttributeRelation
|
||||
from loops.concept import Concept
|
||||
from loops.common import adapted, AdapterBase
|
||||
from loops.type import TypeInterfaceSourceList
|
||||
|
@ -89,8 +88,20 @@ def adaptedRelation(relation):
|
|||
|
||||
# standard relation adapters
|
||||
|
||||
#PredicateInterfaceSourceList.predicateInterfaces += (IMappingAttributeRelation,)
|
||||
PredicateInterfaceSourceList.predicateInterfaces += (
|
||||
IIsSubtype,)
|
||||
|
||||
class IsSubtype(RelationAdapter):
|
||||
""" Allows specification of a predicate for relations between concepts
|
||||
of certain types.
|
||||
"""
|
||||
|
||||
implements(IIsSubtype)
|
||||
|
||||
_contextAttributes = list(IIsSubtype)
|
||||
|
||||
|
||||
#PredicateInterfaceSourceList.predicateInterfaces += (IMappingAttributeRelation,)
|
||||
|
||||
#class MappingAttributeRelation(AdapterBase):
|
||||
|
||||
|
|
5
table.py
5
table.py
|
@ -110,8 +110,9 @@ class DataTableSourceBinder(object):
|
|||
def __init__(self, tableName):
|
||||
self.tableName = tableName
|
||||
|
||||
def __call__(self, context):
|
||||
context = baseObject(context)
|
||||
def __call__(self, instance):
|
||||
#context = baseObject(instance.context)
|
||||
context = instance.view.nodeView.context
|
||||
dt = context.getLoopsRoot().getConceptManager()[self.tableName]
|
||||
return DataTableSourceList(adapted(dt))
|
||||
|
||||
|
|
|
@ -64,10 +64,12 @@ from loops.config.base import GlobalOptions, LoopsOptions
|
|||
from loops.config.base import QueryOptions, PredicateOptions, TypeOptions
|
||||
from loops.interfaces import ILoopsObject, IIndexAttributes
|
||||
from loops.interfaces import IDocument, IFile, ITextDocument
|
||||
from loops.interfaces import IIsSubtype
|
||||
from loops.layout.base import LayoutNode
|
||||
from loops.organize.memberinfo import MemberInfoProvider
|
||||
from loops.organize.stateful.base import StatefulResourceIndexInfo, handleTransition
|
||||
from loops.predicate import Predicate #, MappingAttributeRelation
|
||||
from loops.predicate import Predicate
|
||||
from loops.predicate import IsSubtype#, MappingAttributeRelation
|
||||
from loops.expert.concept import QueryConcept
|
||||
from loops.resource import Resource, FileAdapter, TextDocumentAdapter
|
||||
from loops.resource import Document, MediaAsset
|
||||
|
@ -135,6 +137,7 @@ class TestSite(object):
|
|||
component.provideAdapter(LoopsType)
|
||||
component.provideAdapter(ConceptType)
|
||||
component.provideAdapter(Predicate)
|
||||
component.provideAdapter(IsSubtype, provides=IIsSubtype)
|
||||
#component.provideAdapter(MappingAttributeRelation)
|
||||
component.provideAdapter(ResourceType, (IDocument,))
|
||||
component.provideAdapter(TypeConcept)
|
||||
|
|
Loading…
Add table
Reference in a new issue