# HG changeset patch # User Thierry Florac # Date 1421247179 -3600 # Node ID 8364fb15bfe5c85cc628ef603976a539dd759354 # Parent 7b1498967eb9bcf6c62582540e6ff925f2b19c19 Allow usage of a custom static configuration for a given view by setting a request attribute diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/interfaces/configuration.py --- a/src/ztfy/myams/interfaces/configuration.py Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/interfaces/configuration.py Wed Jan 14 15:52:59 2015 +0100 @@ -20,6 +20,9 @@ from ztfy.myams import _ +MYAMS_CONFIGURATION_NAME_KEY = 'ztfy.myams.configuration.name' + + class IMyAMSStaticConfiguration(Interface): """MyAMS static configuration""" diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/resources/css/myams.css --- a/src/ztfy/myams/resources/css/myams.css Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/resources/css/myams.css Wed Jan 14 15:52:59 2015 +0100 @@ -3492,6 +3492,9 @@ margin: 0 -5px !important; } } +.no-height { + line-height: 0; +} .clearfix, .inner-space:after { zoom: 1; diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/resources/less/typo.less --- a/src/ztfy/myams/resources/less/typo.less Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/resources/less/typo.less Wed Jan 14 15:52:59 2015 +0100 @@ -513,6 +513,10 @@ } } +.no-height { + line-height: 0; +} + .clearfix, .inner-space:after { zoom: 1; diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/tal/api.py --- a/src/ztfy/myams/tal/api.py Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/tal/api.py Wed Jan 14 15:52:59 2015 +0100 @@ -12,15 +12,17 @@ # import local interfaces from ztfy.myams.interfaces import IMyAMSApplication, IObjectData -from ztfy.myams.interfaces.configuration import IMyAMSConfiguration +from ztfy.myams.interfaces.configuration import IMyAMSConfiguration, IMyAMSStaticConfiguration, \ + MYAMS_CONFIGURATION_NAME_KEY from ztfy.myams.tal.interfaces import IMyAMSTalesAPI # import Zope3 packages -from zope.component import getUtility +from zope.component import getUtility, queryUtility from zope.interface import implements from zope.security.proxy import removeSecurityProxy # import local packages +from ztfy.utils.request import getRequestData from ztfy.utils.traversing import getParent @@ -41,11 +43,25 @@ writer = getUtility(IJSONWriter) return writer.write(data.object_data) + @property + def application(self): + return getParent(self.context, IMyAMSApplication) + def configuration(self): - application = getParent(self.context, IMyAMSApplication) + application = self.application if application is not None: return IMyAMSConfiguration(application, None) + def static_configuration(self): + configuration_name = getRequestData(MYAMS_CONFIGURATION_NAME_KEY, self.request) + if configuration_name: + configuration = queryUtility(IMyAMSStaticConfiguration, name=configuration_name) + if configuration is not None: + return configuration + configuration = self.configuration() + if configuration is not None: + return configuration.static_configuration + def resources(self): application = getParent(self.context, IMyAMSApplication) if application is not None: diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/tal/interfaces.py --- a/src/ztfy/myams/tal/interfaces.py Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/tal/interfaces.py Wed Jan 14 15:52:59 2015 +0100 @@ -25,5 +25,8 @@ def configuration(self): """Get application configuration""" + def static_configuration(self): + """Get application static configuration""" + def resources(self): """Include application's Fanstatic resources""" diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/templates/fullpage-layout.pt --- a/src/ztfy/myams/templates/fullpage-layout.pt Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/templates/fullpage-layout.pt Wed Jan 14 15:52:59 2015 +0100 @@ -1,6 +1,6 @@ + tal:define="config context/myams:configuration; static context/myams:static_configuration;"> diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/templates/fullpage-modal-layout.pt --- a/src/ztfy/myams/templates/fullpage-modal-layout.pt Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/templates/fullpage-modal-layout.pt Wed Jan 14 15:52:59 2015 +0100 @@ -1,6 +1,6 @@ + tal:define="config context/myams:configuration; static context/myams:static_configuration;"> diff -r 7b1498967eb9 -r 8364fb15bfe5 src/ztfy/myams/templates/layout.pt --- a/src/ztfy/myams/templates/layout.pt Tue Dec 16 11:04:53 2014 +0100 +++ b/src/ztfy/myams/templates/layout.pt Wed Jan 14 15:52:59 2015 +0100 @@ -1,6 +1,6 @@ + tal:define="config context/myams:configuration; static context/myams:static_configuration;"> @@ -29,8 +29,10 @@