setup improvements to facilitate setting up entire loops sites

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2304 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-01-08 19:54:20 +00:00
parent 31a6e91114
commit 0cf020c289
3 changed files with 11 additions and 8 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de # Copyright (c) 2008 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

View file

@ -33,7 +33,7 @@ from loops.interfaces import ILoops, ITypeConcept
from loops.interfaces import IFile, IImage, ITextDocument, INote from loops.interfaces import IFile, IImage, ITextDocument, INote
from loops.concept import ConceptManager, Concept from loops.concept import ConceptManager, Concept
from loops.query import IQueryConcept from loops.query import IQueryConcept
from loops.resource import ResourceManager from loops.resource import ResourceManager, Resource
from loops.view import ViewManager, Node from loops.view import ViewManager, Node
@ -114,14 +114,15 @@ def addObject(container, class_, name, **kw):
return obj return obj
def addAndConfigureObject(container, class_, name, **kw): def addAndConfigureObject(container, class_, name, **kw):
basicAttributes = ('title', 'description', 'conceptType', 'resourceType') basicAttributes = ('title', 'description', 'conceptType', 'resourceType',
'nodeType', 'body')
basicKw = dict([(k, kw[k]) for k in kw if k in basicAttributes]) basicKw = dict([(k, kw[k]) for k in kw if k in basicAttributes])
obj = addObject(container, class_, name, **basicKw) obj = addObject(container, class_, name, **basicKw)
adapted = obj
if class_ in (Concept, Resource):
ti = IType(obj).typeInterface ti = IType(obj).typeInterface
if ti is not None: if ti is not None:
adapted = ti(obj) adapted = ti(obj)
else:
adapted = obj
adapterAttributes = [k for k in kw if k not in basicAttributes] adapterAttributes = [k for k in kw if k not in basicAttributes]
for attr in adapterAttributes: for attr in adapterAttributes:
setattr(adapted, attr, kw[attr]) setattr(adapted, attr, kw[attr])

View file

@ -37,6 +37,7 @@ from loops.interfaces import ILoopsObject, IIndexAttributes
from loops.interfaces import IDocument, IFile, ITextDocument from loops.interfaces import IDocument, IFile, ITextDocument
from loops.concept import Concept from loops.concept import Concept
from loops.concept import IndexAttributes as ConceptIndexAttributes from loops.concept import IndexAttributes as ConceptIndexAttributes
from loops.query import QueryConcept
from loops.resource import Resource, FileAdapter, TextDocumentAdapter from loops.resource import Resource, FileAdapter, TextDocumentAdapter
from loops.resource import IndexAttributes as ResourceIndexAttributes from loops.resource import IndexAttributes as ResourceIndexAttributes
from loops.schema import ResourceSchemaFactory, FileSchemaFactory, NoteSchemaFactory from loops.schema import ResourceSchemaFactory, FileSchemaFactory, NoteSchemaFactory
@ -78,6 +79,7 @@ class TestSite(object):
component.provideAdapter(ConceptType) component.provideAdapter(ConceptType)
component.provideAdapter(ResourceType, (IDocument,)) component.provideAdapter(ResourceType, (IDocument,))
component.provideAdapter(TypeConcept) component.provideAdapter(TypeConcept)
component.provideAdapter(QueryConcept)
component.provideAdapter(FileAdapter, provides=IFile) component.provideAdapter(FileAdapter, provides=IFile)
component.provideAdapter(TextDocumentAdapter, provides=ITextDocument) component.provideAdapter(TextDocumentAdapter, provides=ITextDocument)
component.provideAdapter(NodeAdapter) component.provideAdapter(NodeAdapter)