implement skin switching in BaseView
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1134 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
273a05a5d1
commit
e96289a34b
6 changed files with 48 additions and 7 deletions
|
@ -34,6 +34,11 @@ class Loops(Folder):
|
||||||
|
|
||||||
implements(ILoops)
|
implements(ILoops)
|
||||||
|
|
||||||
|
_skinName = ''
|
||||||
|
def getSkinName(self): return self._skinName
|
||||||
|
def setSkinName(self, skinName): self._skinName = skinName
|
||||||
|
skinName = property(getSkinName, setSkinName)
|
||||||
|
|
||||||
def getLoopsRoot(self):
|
def getLoopsRoot(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ from zope.app.intid.interfaces import IIntIds
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.dottedname.resolve import resolve
|
from zope.dottedname.resolve import resolve
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
from zope.app.publisher.browser import applySkin
|
||||||
|
from zope.publisher.interfaces.browser import ISkin
|
||||||
from zope.schema.vocabulary import SimpleTerm
|
from zope.schema.vocabulary import SimpleTerm
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
|
||||||
|
@ -39,8 +41,23 @@ class BaseView(object):
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
#self.context = context
|
#self.context = context
|
||||||
|
# TODO: get rid of removeSecurityProxy() call
|
||||||
self.context = removeSecurityProxy(context)
|
self.context = removeSecurityProxy(context)
|
||||||
self.request = request
|
self.request = request
|
||||||
|
skin = None
|
||||||
|
# TODO: get ISkinController adapter instead
|
||||||
|
skinName = self.loopsRoot.skinName
|
||||||
|
if skinName:
|
||||||
|
skin = zapi.queryUtility(ISkin, skinName)
|
||||||
|
if skin is not None:
|
||||||
|
applySkin(self.request, skin)
|
||||||
|
self.skin = skin
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def resourceBase(self):
|
||||||
|
skinSetter = self.skin and ('/++skin++' + self.skin.__name__) or ''
|
||||||
|
# TODO: put '/@@' etc after path to site instead of directly after URL0
|
||||||
|
return self.request.URL[0] + skinSetter + '/@@'
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def modified(self):
|
def modified(self):
|
||||||
|
|
|
@ -67,6 +67,21 @@
|
||||||
view="AddLoopsContainer.html"
|
view="AddLoopsContainer.html"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<containerViews
|
||||||
|
for="loops.interfaces.ILoops"
|
||||||
|
contents="zope.ManageContent"
|
||||||
|
add="zope.ManageContent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<editform
|
||||||
|
label="Edit Loops Container"
|
||||||
|
name="edit.html"
|
||||||
|
schema="loops.interfaces.ILoops"
|
||||||
|
fields="skinName"
|
||||||
|
for="loops.interfaces.ILoops"
|
||||||
|
permission="zope.ManageContent"
|
||||||
|
menu="zmi_views" title="Edit" />
|
||||||
|
|
||||||
<!-- concept manager -->
|
<!-- concept manager -->
|
||||||
|
|
||||||
<addform
|
<addform
|
||||||
|
|
|
@ -43,12 +43,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div metal:fill-slot="footer">
|
|
||||||
<a href="#"
|
|
||||||
tal:attributes="href string:${view/menu/url}/impressum">Impressum</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</tal:show>
|
</tal:show>
|
||||||
|
|
|
@ -50,7 +50,11 @@
|
||||||
<require
|
<require
|
||||||
permission="zope.View"
|
permission="zope.View"
|
||||||
attributes="getLoopsUri loopsTraverse getConceptManager
|
attributes="getLoopsUri loopsTraverse getConceptManager
|
||||||
getResourceManager getViewManager" />
|
getResourceManager getViewManager skinName" />
|
||||||
|
|
||||||
|
<require
|
||||||
|
permission="zope.ManageContent"
|
||||||
|
set_schema=".interfaces.ILoops" />
|
||||||
|
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,12 @@ class ILoops(ILoopsObject):
|
||||||
"""
|
"""
|
||||||
contains(IConceptManager, IResourceManager, IViewManager)
|
contains(IConceptManager, IResourceManager, IViewManager)
|
||||||
|
|
||||||
|
skinName = schema.ASCIILine(
|
||||||
|
title=_(u'Skin Name'),
|
||||||
|
description=_(u'Name of the skin to use'),
|
||||||
|
default='',
|
||||||
|
required=False)
|
||||||
|
|
||||||
def getLoopsUri(obj):
|
def getLoopsUri(obj):
|
||||||
""" Return the relativ path to obj, starting with '.loops/...'.
|
""" Return the relativ path to obj, starting with '.loops/...'.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue