[Checkins] SVN: megrok.chameleon/trunk/ Merge branch sylvain-grokcore-view-only.
Sylvain Viollon
sylvain at infrae.com
Fri Sep 18 10:53:19 EDT 2009
Log message for revision 104335:
Merge branch sylvain-grokcore-view-only.
Changed:
U megrok.chameleon/trunk/CHANGES.txt
U megrok.chameleon/trunk/buildout.cfg
U megrok.chameleon/trunk/setup.py
U megrok.chameleon/trunk/src/megrok/chameleon/README.txt
U megrok.chameleon/trunk/src/megrok/chameleon/components.py
U megrok.chameleon/trunk/src/megrok/chameleon/configure.zcml
U megrok.chameleon/trunk/src/megrok/chameleon/ftesting.zcml
U megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app.py
U megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app_templates/food.cpt
U megrok.chameleon/trunk/src/megrok/chameleon/tests/genshi_fixture/app.py
U megrok.chameleon/trunk/src/megrok/chameleon/tests/test_megrok_chameleon.py
-=-
Modified: megrok.chameleon/trunk/CHANGES.txt
===================================================================
--- megrok.chameleon/trunk/CHANGES.txt 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/CHANGES.txt 2009-09-18 14:53:19 UTC (rev 104335)
@@ -4,6 +4,10 @@
0.2 (unreleased)
================
+* Provides a macros access from the template.
+
+* Don't depend anymore on grok, but only grokcore.view.
+
* Added support for `path()` and `exists()` in page templates. This
was introduced from `z3c.pt`.
Modified: megrok.chameleon/trunk/buildout.cfg
===================================================================
--- megrok.chameleon/trunk/buildout.cfg 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/buildout.cfg 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,17 +1,22 @@
[buildout]
develop = .
parts = app data zopectl test
-extends = http://grok.zope.org/releaseinfo/grok-1.0a4.cfg
+find-links = http://download.zope.org/distribution/
+extends = http://grok.zope.org/releaseinfo/grok-1.0b2.cfg
versions = versions
newest = false
+extensions = buildout.dumppickedversions
+
[versions]
-chameleon.zpt = 1.0.0
-chameleon.genshi = 1.0b3
-chameleon.core = 1.0.0
-zope.container = 3.8.1
zope.i18n = 3.5
zope.testing = 3.7.0
+grokcore.view = 1.12.1
+chameleon.core = 1.0.0
+chameleon.genshi = 1.0b4
+chameleon.zpt = 1.0.0
+sourcecodegen = 0.6.11
+z3c.pt = 1.0b16
[data]
recipe = zc.recipe.filestorage
@@ -37,7 +42,7 @@
password="grok"
/>
- <!-- Replace the following directive if you don't want
+ <!-- Replace the following directive if you do not want
public access -->
<grant permission="zope.View"
principal="zope.Anybody" />
@@ -61,5 +66,7 @@
[test]
recipe = zc.recipe.testrunner
-eggs = megrok.chameleon
+eggs =
+ megrok.chameleon
+ lxml
defaults = ['--tests-pattern', '^f?tests$', '-v']
Modified: megrok.chameleon/trunk/setup.py
===================================================================
--- megrok.chameleon/trunk/setup.py 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/setup.py 2009-09-18 14:53:19 UTC (rev 104335)
@@ -22,7 +22,7 @@
'Programming Language :: Python :: 2.5',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
- ],
+ ],
keywords="grok chameleon template",
author="Uli Fouquet",
author_email="grok-dev at zope.org",
@@ -33,14 +33,19 @@
include_package_data=True,
zip_safe=False,
install_requires=['setuptools',
- 'grok',
+ 'zope.component',
+ 'zope.publisher',
+ 'grokcore.view',
+ 'grokcore.component',
'z3c.testsetup',
'chameleon.zpt',
'chameleon.genshi',
'z3c.pt',
'lxml', # Needed by chameleon.genshi
+ # for ftests:
+ 'grokcore.viewlet',
+ 'zope.securitypolicy',
+ 'zope.app.zcmlfiles',
+ 'zope.app.authentication',
],
- entry_points="""
- # Add entry points here
- """,
)
Modified: megrok.chameleon/trunk/src/megrok/chameleon/README.txt
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/README.txt 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/README.txt 2009-09-18 14:53:19 UTC (rev 104335)
@@ -50,9 +50,9 @@
grok the `megrok.chameleon` package. This way the new template types
are registered with the framework::
- >>> import grok
- >>> grok.testing.grok('megrok.chameleon')
- >>> grok.testing.grok('megrok.chameleon.tests.cpt_fixture')
+ >>> import grokcore.view
+ >>> grokcore.view.testing.grok('megrok.chameleon')
+ >>> grokcore.view.testing.grok('megrok.chameleon.tests.cpt_fixture')
We create a mammoth, which should provide us a bunch of chameleon page
template driven views and put it in the database to setup location
@@ -103,9 +103,9 @@
>>> print open(food_cpt, 'rb').read()
<html>
<body>
- <span tal:define="foo 'a FOO'" >
+ <span tal:define="foo 'a FOO'">
${view.me_do()}
- <span tal:replace="view.me_do()" />
+ <span tal:replace="structure view.me_do()" />
CSS-URL: ${static['test.css']()}
My context is: ${view.url(context)}
${foo}
@@ -121,7 +121,8 @@
<html>
<body>
<span>
- ...<ME GROK EAT MAMMOTH!>
+ <ME GROK EAT MAMMOTH!>
+ <ME GROK EAT MAMMOTH!>
CSS-URL: http://127.0.0.1/@@/megrok.chameleon.tests.cpt_fixture/test.css
My context is: http://127.0.0.1/manfred
a FOO
@@ -233,12 +234,11 @@
We can also define inline templates. In our ``app.py`` we defined an
inline template like this::
- import grok
from megrok.chameleon import components
...
- class Inline(grok.View):
+ class Inline(grokcore.view.View):
sometext = 'Some Text'
inline = components.ChameleonPageTemplate(
@@ -426,9 +426,8 @@
grok the `megrok.chameleon` package. This way the new template types
are registered with the framework::
- >>> import grok
- >>> grok.testing.grok('megrok.chameleon')
- >>> grok.testing.grok('megrok.chameleon.tests.genshi_fixture')
+ >>> grokcore.view.testing.grok('megrok.chameleon')
+ >>> grokcore.view.testing.grok('megrok.chameleon.tests.genshi_fixture')
We create a mammoth, which should provide us a bunch of Genshi driven
views and put it in the database to setup location info::
Modified: megrok.chameleon/trunk/src/megrok/chameleon/components.py
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/components.py 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/components.py 2009-09-18 14:53:19 UTC (rev 104335)
@@ -26,7 +26,7 @@
# Chameleon Zope Page Templates...
#
class ChameleonPageTemplate(GrokTemplate):
-
+
def setFromString(self, string):
self._filename = None
self._template = PageTemplate(string)
@@ -51,7 +51,11 @@
exists=evaluate_exists,
))
return namespace
-
+
+ @property
+ def macros(self):
+ return self._template.macros
+
def render(self, view):
return self._template(**self.getNamespace(view))
@@ -68,7 +72,7 @@
class ChameleonGenshiTemplate(GrokTemplate):
filename = None
_format = None
-
+
def setFromString(self, string):
self._filename = None
self._template = GenshiTemplate(string, format=self._format)
@@ -95,7 +99,7 @@
class ChameleonGenshiTextTemplate(GrokTemplate):
filename = None
-
+
def setFromString(self, string):
self._filename = None
self._template = GenshiTextTemplate(string)
@@ -111,7 +115,7 @@
if self._filename is not None:
self.setFromFilename(self._filename, self._prefix)
return self._template(**self.getNamespace(view))
-
+
class ChameleonGenshiTextTemplateFactory(GlobalUtility):
implements(interfaces.ITemplateFileFactory)
name('cgt')
Modified: megrok.chameleon/trunk/src/megrok/chameleon/configure.zcml
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/configure.zcml 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/configure.zcml 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,10 +1,11 @@
-<configure
+<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok">
- <include package="grok" />
+ <include package="grokcore.view" file="meta-minimal.zcml" />
+ <include package="grokcore.view" />
<include package="chameleon.zpt" />
<include package="z3c.pt" />
<grok:grok package="." />
-
+
</configure>
Modified: megrok.chameleon/trunk/src/megrok/chameleon/ftesting.zcml
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/ftesting.zcml 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/ftesting.zcml 2009-09-18 14:53:19 UTC (rev 104335)
@@ -2,13 +2,20 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok"
i18n_domain="megrok.chameleon"
- package="megrok.chameleon"
- >
+ package="megrok.chameleon">
- <include package="grok" />
<include package="megrok.chameleon" />
+ <include package="grokcore.viewlet" file="meta.zcml" />
+ <include package="grokcore.viewlet" />
+
<!-- Typical functional testing security setup -->
+ <include package="zope.app.zcmlfiles" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
+
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+
<securityPolicy
component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
/>
Modified: megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app.py
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app.py 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app.py 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,36 +1,41 @@
-import grok
+from grokcore.component.interfaces import IContext
+from zope.app.container.btree import BTreeContainer
+from zope.interface import implements
from megrok.chameleon import components
-class Mammoth(grok.Application, grok.Container):
- pass
+import grokcore.view
+import grokcore.viewlet
-class CavePainting(grok.View):
+class Mammoth(BTreeContainer):
+ implements(IContext)
+
+class CavePainting(grokcore.view.View):
pass
-class Food(grok.View):
-
+class Food(grokcore.view.View):
+
text = "<ME GROK EAT MAMMOTH!>"
-
+
def me_do(self):
return self.text
-class Inline(grok.View):
+class Inline(grokcore.view.View):
sometext = 'Some Text'
inline = components.ChameleonPageTemplate(
"<html><body>ME GROK HAS INLINES! ${view.sometext}</body></html>")
-class Vars(grok.View):
+class Vars(grokcore.view.View):
pass
-class Expressions(grok.View):
+class Expressions(grokcore.view.View):
pass
-class MainArea(grok.ViewletManager):
- grok.name('main')
+class MainArea(grokcore.viewlet.ViewletManager):
+ grokcore.viewlet.name('main')
-class MainContent(grok.Viewlet):
- grok.view(Expressions)
- grok.viewletmanager(MainArea)
+class MainContent(grokcore.viewlet.Viewlet):
+ grokcore.viewlet.view(Expressions)
+ grokcore.viewlet.viewletmanager(MainArea)
def render(self):
return 'Hello from viewlet'
Modified: megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app_templates/food.cpt
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app_templates/food.cpt 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/tests/cpt_fixture/app_templates/food.cpt 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,8 +1,8 @@
<html>
<body>
-<span tal:define="foo 'a FOO'" >
+<span tal:define="foo 'a FOO'">
${view.me_do()}
-<span tal:replace="view.me_do()" />
+<span tal:replace="structure view.me_do()" />
CSS-URL: ${static['test.css']()}
My context is: ${view.url(context)}
${foo}
Modified: megrok.chameleon/trunk/src/megrok/chameleon/tests/genshi_fixture/app.py
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/tests/genshi_fixture/app.py 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/tests/genshi_fixture/app.py 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,31 +1,35 @@
-import grok
+from grokcore.component.interfaces import IContext
+from zope.app.container.btree import BTreeContainer
+from zope.interface import implements
from megrok.chameleon import components
-class Mammoth(grok.Application, grok.Container):
- pass
+import grokcore.view
-class CavePainting(grok.View):
+class Mammoth(BTreeContainer):
+ implements(IContext)
+
+class CavePainting(grokcore.view.View):
pass
-class Static(grok.View):
+class Static(grokcore.view.View):
def render(self): return
pass
-class Gatherer(grok.View):
+class Gatherer(grokcore.view.View):
pass
-
-class Food(grok.View):
-
+
+class Food(grokcore.view.View):
+
text = "ME GROK EAT MAMMOTH!"
-
+
def me_do(self):
return self.text
-class Hunter(grok.View):
-
+class Hunter(grokcore.view.View):
+
game = "MAMMOTH!"
-class Inline(grok.View):
+class Inline(grokcore.view.View):
pass
inline = components.ChameleonPageTemplate(
Modified: megrok.chameleon/trunk/src/megrok/chameleon/tests/test_megrok_chameleon.py
===================================================================
--- megrok.chameleon/trunk/src/megrok/chameleon/tests/test_megrok_chameleon.py 2009-09-18 14:38:59 UTC (rev 104334)
+++ megrok.chameleon/trunk/src/megrok/chameleon/tests/test_megrok_chameleon.py 2009-09-18 14:53:19 UTC (rev 104335)
@@ -1,5 +1,10 @@
import z3c.testsetup
+import zope.testing.doctest
from megrok.chameleon.tests import FunctionalLayer
+flags = (zope.testing.doctest.ELLIPSIS |
+ zope.testing.doctest.NORMALIZE_WHITESPACE)
+
test_suite = z3c.testsetup.register_all_tests('megrok.chameleon',
+ optionflags=flags,
layer=FunctionalLayer)
More information about the checkins
mailing list