added view and actions for a pseudo-folder concept type
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2457 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
3524ab83be
commit
ebefd631a2
6 changed files with 148 additions and 5 deletions
|
@ -221,6 +221,15 @@
|
|||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<zope:adapter
|
||||
name="folder.html"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.folder.FolderView"
|
||||
permission="zope.View"
|
||||
/>
|
||||
|
||||
<!-- resource manager -->
|
||||
|
||||
<addform
|
||||
|
|
57
browser/folder.py
Executable file
57
browser/folder.py
Executable file
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Copyright (c) 2008 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Elements for handling and presentation of pseudo folders.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
|
||||
from cybertools.browser.action import actions
|
||||
from loops.browser.action import DialogAction
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.util import _
|
||||
|
||||
|
||||
actions.register('createFolder', 'portlet', DialogAction,
|
||||
title=_(u'Create Folder...'),
|
||||
description=_(u'Create a new folder.'),
|
||||
viewName='create_concept.html',
|
||||
dialogName='createFolder',
|
||||
typeToken='.loops/concepts/folder',
|
||||
fixedType=True,
|
||||
innerForm='inner_concept_form.html',
|
||||
)
|
||||
|
||||
actions.register('editFolder', 'portlet', DialogAction,
|
||||
title=_(u'Edit Folder...'),
|
||||
description=_(u'Modify folder.'),
|
||||
viewName='edit_concept.html',
|
||||
dialogName='editFolder',
|
||||
)
|
||||
|
||||
|
||||
class FolderView(ConceptView):
|
||||
|
||||
def getActions(self, category='concept', page=None):
|
||||
if category == 'portlet':
|
||||
return actions.get(category, ['createFolder', 'editFolder'],
|
||||
view=self, page=page)
|
||||
return []
|
||||
|
71
helpers.txt
71
helpers.txt
|
@ -280,6 +280,13 @@ i.e. the 'topic' concept, via an adapter:
|
|||
>>> ITopic.providedBy(cc1Adapter)
|
||||
True
|
||||
|
||||
There is a shortcut to getting the typeInterface adapter for an object.
|
||||
|
||||
>>> from loops.common import adapted
|
||||
>>> cc1Adapter = adapted(cc1)
|
||||
>>> ITopic.providedBy(cc1Adapter)
|
||||
True
|
||||
|
||||
|
||||
Simple access to type information with BaseView
|
||||
-----------------------------------------------
|
||||
|
@ -299,8 +306,8 @@ context object's type:
|
|||
<Topic object ...>
|
||||
|
||||
|
||||
Concepts as queries
|
||||
-------------------
|
||||
Concepts as Queries
|
||||
===================
|
||||
|
||||
We first have to set up the query type, i.e. a type concept associated
|
||||
with the IQueryConcept interface. The query type concept itself has already
|
||||
|
@ -348,8 +355,8 @@ view/multi-adapter with this name:
|
|||
<class 'SimpleView'>
|
||||
|
||||
|
||||
Controlling presentation using view properties
|
||||
----------------------------------------------
|
||||
Controlling Presentation Using View Properties
|
||||
==============================================
|
||||
|
||||
>>> from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
||||
>>> from zope.annotation.attribute import AttributeAnnotations
|
||||
|
@ -405,3 +412,59 @@ browser).
|
|||
>>> controller = Controller(view, request)
|
||||
>>> controller.skinName.value
|
||||
'SuperSkin'
|
||||
|
||||
|
||||
Folders
|
||||
=======
|
||||
|
||||
We may provide a concept type called a folder - there is no special
|
||||
functionality about it but it may be used for building a pseudo hierarchy
|
||||
using nested folders. This may make it easier for users to map the
|
||||
structures of their documents in the filesystem to the loops concept
|
||||
map.
|
||||
|
||||
>>> from loops.setup import addAndConfigureObject
|
||||
>>> tFolder = addAndConfigureObject(concepts, Concept, 'folder',
|
||||
... title=u'Folder', conceptType=typeObject)
|
||||
|
||||
Usually we want to create folders only in objects of a certain type,
|
||||
e.g. in a domain. So we activate the folder creation action by providing
|
||||
the domain type with a corresponding option.
|
||||
|
||||
>>> tDomain = concepts['domain']
|
||||
>>> taDomain = adapted(tDomain)
|
||||
>>> taDomain.options = ['action.portlet:createFolder']
|
||||
|
||||
Importing the FolderView will register this action.
|
||||
|
||||
>>> from loops.browser.folder import FolderView
|
||||
|
||||
If we now create a domain and set up a view on it it will provide the
|
||||
folder creation action.
|
||||
|
||||
>>> general = addAndConfigureObject(concepts, Concept, 'general',
|
||||
... title=u'General', conceptType=tDomain)
|
||||
|
||||
>>> from loops.browser.concept import ConceptView
|
||||
>>> view = ConceptView(general, TestRequest())
|
||||
>>> sorted(a.name for a in view.getActions('portlet'))
|
||||
['createFolder']
|
||||
|
||||
Let's now create a folder.
|
||||
|
||||
>>> f01 = addAndConfigureObject(concepts, Concept, 'f01',
|
||||
... title=u'Test Folder', conceptType=tFolder)
|
||||
|
||||
A folder should be associated with a FolderView that provides two actions
|
||||
for editing the folder and for creating a new subfolder.
|
||||
|
||||
>>> view = FolderView(f01, TestRequest())
|
||||
>>> sorted(a.name for a in view.getActions('portlet'))
|
||||
['createFolder', 'editFolder']
|
||||
|
||||
|
||||
Fin de partie
|
||||
=============
|
||||
|
||||
>>> placefulTearDown()
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ from zope import schema
|
|||
from zope.app.container.constraints import contains, containers
|
||||
from zope.app.container.interfaces import IContainer, IOrderedContainer
|
||||
from zope.app.file.interfaces import IImage as IBaseAsset
|
||||
from zope.app.folder.interfaces import IFolder
|
||||
from zope.component.interfaces import IObjectEvent
|
||||
from zope.size.interfaces import ISized
|
||||
|
||||
|
|
Binary file not shown.
|
@ -17,6 +17,9 @@ msgstr "Begriff"
|
|||
msgid "Resource"
|
||||
msgstr "Ressource"
|
||||
|
||||
msgid "Folder"
|
||||
msgstr "Ordner"
|
||||
|
||||
msgid "Log out"
|
||||
msgstr "Abmelden"
|
||||
|
||||
|
@ -32,6 +35,18 @@ msgstr "Ressource anlegen..."
|
|||
msgid "Create a new resource object."
|
||||
msgstr "Eine neue Ressource erzeugen"
|
||||
|
||||
msgid "Create Folder..."
|
||||
msgstr "Ordner anlegen..."
|
||||
|
||||
msgid "Create a new folder."
|
||||
msgstr "Einen neuen Ordner anlegen"
|
||||
|
||||
msgid "Edit Folder..."
|
||||
msgstr "Ordner bearbeiten..."
|
||||
|
||||
msgid "Modify folder."
|
||||
msgstr "Ordner ändern"
|
||||
|
||||
msgid "Edit Blog Post..."
|
||||
msgstr "Eintrag bearbeiten..."
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue