[Checkins] SVN: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ Some new Ideas about direcitves
Christian Klinger
cklinger at novareto.de
Wed Oct 14 09:59:46 EDT 2009
Log message for revision 105065:
Some new Ideas about direcitves
Changed:
U Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/directive.py
U Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/event.py
U Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_inclusion.py
-=-
Modified: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/directive.py
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/directive.py 2009-10-14 12:00:22 UTC (rev 105064)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/directive.py 2009-10-14 13:59:46 UTC (rev 105065)
@@ -21,14 +21,5 @@
scope = martian.CLASS
store = martian.MULTIPLE
- def factory(self, value, name):
- return (value, name)
-
-class bottom(martian.MarkerDirective):
- store = martian.ONCE
- scope = martian.CLASS
-
-
-class includeall(martian.Directive):
- store = martian.ONCE
- scope = martian.CLASS
+ def factory(self, value, name=None, bottom=False):
+ return (value, name, bottom)
Modified: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/event.py
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/event.py 2009-10-14 12:00:22 UTC (rev 105064)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/event.py 2009-10-14 13:59:46 UTC (rev 105065)
@@ -3,20 +3,22 @@
from zope.app.publication.interfaces import IBeforeTraverseEvent
from zope.security.proxy import removeSecurityProxy
-from megrok.resource import include, bottom, includeall
+from megrok.resource import include
@grok.subscribe(grok.View, IBeforeTraverseEvent)
def handle(view, event):
+ with_bottom = False
view = removeSecurityProxy(view)
- all = includeall.bind().get(view)
includes = include.bind().get(view)
- #import pdb; pdb.set_trace()
- if all:
- for name in all.libs:
-
- for lib, name in includes:
- inn = getattr(lib, name)
- inn.need()
- bottom = bottom.bind().get(view)
- if botom:
+ for lib, name, bottom in includes:
+ if bottom:
+ with_bottom=True
+ if not name:
+ for l in lib.libs:
+ inn = getattr(lib, l)
+ inn.need()
+ else:
+ inn = getattr(lib, name)
+ inn.need()
+ if with_bottom:
hurry.resource.bottom()
Modified: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_inclusion.py
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_inclusion.py 2009-10-14 12:00:22 UTC (rev 105064)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_inclusion.py 2009-10-14 13:59:46 UTC (rev 105065)
@@ -60,11 +60,21 @@
>>> browser.open('http://localhost/app/all')
>>> print browser.contents
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="http://localhost/app/@@/styles/b.css" />
+ <script type="text/javascript" src="http://localhost/app/@@/styles/a.js"></script>
+ <script type="text/javascript" src="http://localhost/app/@@/styles/b.js"></script>
+ </head>
+ <body>
+ <h1> HI GROK </h1>
+ </body>
+ </html>
"""
import grok
from zope.interface import Interface
-from megrok.resource import Library, include, inclusion, bottom, includeall
+from megrok.resource import Library, include, inclusion
from hurry.resource import ResourceInclusion
@@ -74,7 +84,7 @@
inclusion(name='JS', file='a.js')
inclusion(name='JSBottom', file='b.js', bottom=True)
- inclusion(name='JSBottom', file='b.js', bottom=True)
+ inclusion(name='CSS', file='b.css', bottom=True)
class Simple(grok.View):
@@ -86,15 +96,14 @@
class Advanced(grok.View):
grok.context(Interface)
include(Styles, 'JS')
- include(Styles, 'JSBottom')
- bottom()
+ include(Styles, 'JSBottom', bottom=True)
template = grok.PageTemplateFile('templates/myview.pt')
class All(grok.View):
grok.context(Interface)
template = grok.PageTemplateFile('templates/myview.pt')
- includeall(Styles)
+ include(Styles)
More information about the checkins
mailing list