[Checkins] SVN: z3c.pt/trunk/ Added conditional application security configuration to play nice with zope.security proxies.
Malthe Borch
mborch at gmail.com
Mon Sep 1 11:28:16 EDT 2008
Log message for revision 90656:
Added conditional application security configuration to play nice with zope.security proxies.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/configure.zcml
U z3c.pt/trunk/src/z3c/pt/interfaces.py
U z3c.pt/trunk/src/z3c/pt/utils.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-01 15:23:52 UTC (rev 90655)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-01 15:28:16 UTC (rev 90656)
@@ -13,6 +13,10 @@
Features
+- Added security configuration for the TALES iterator (repeat
+ dictionary). This is made conditional on the availability of the
+ application security framework. [malthe]
+
- Dynamic attributes are now ordered as they appear in the
template. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/configure.zcml
===================================================================
--- z3c.pt/trunk/src/z3c/pt/configure.zcml 2008-09-01 15:23:52 UTC (rev 90655)
+++ z3c.pt/trunk/src/z3c/pt/configure.zcml 2008-09-01 15:28:16 UTC (rev 90656)
@@ -1,4 +1,5 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml">
<include package="zope.component" file="meta.zcml" />
@@ -13,6 +14,17 @@
<adapter
name="string"
factory=".expressions.StringTranslation" />
+
+ <configure zcml:condition="installed zope.app.component">
+
+ <include package="zope.app.component" file="meta.zcml" />
+ <include package="zope.app.security" file="meta.zcml" />
+
+ <class class=".utils.repeatitem">
+ <allow interface=".interfaces.ITALESIterator" />
+ </class>
+
+ </configure>
</configure>
Modified: z3c.pt/trunk/src/z3c/pt/interfaces.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/interfaces.py 2008-09-01 15:23:52 UTC (rev 90655)
+++ z3c.pt/trunk/src/z3c/pt/interfaces.py 2008-09-01 15:28:16 UTC (rev 90656)
@@ -53,3 +53,86 @@
define_var ::= Name python_expression
"""
+
+class ITALIterator(interface.Interface):
+ """A TAL iterator
+
+ Not to be confused with a Python iterator.
+ """
+
+ def next():
+ """Advance to the next value in the iteration, if possible
+
+ Return a true value if it was possible to advance and return
+ a false value otherwise.
+ """
+
+class ITALESIterator(ITALIterator):
+ """TAL Iterator provided by TALES
+
+ Values of this iterator are assigned to items in the repeat namespace.
+
+ For example, with a TAL statement like: tal:repeat="item items",
+ an iterator will be assigned to "repeat/item". The iterator
+ provides a number of handy methods useful in writing TAL loops.
+
+ The results are undefined of calling any of the methods except
+ 'length' before the first iteration.
+ """
+
+ def index():
+ """Return the position (starting with "0") within the iteration
+ """
+
+ def number():
+ """Return the position (starting with "1") within the iteration
+ """
+
+ def even():
+ """Return whether the current position is even
+ """
+
+ def odd():
+ """Return whether the current position is odd
+ """
+
+ def parity():
+ """Return 'odd' or 'even' depending on the position's parity
+
+ Useful for assigning CSS class names to table rows.
+ """
+
+ def start():
+ """Return whether the current position is the first position
+ """
+
+ def end():
+ """Return whether the current position is the last position
+ """
+
+ def letter():
+ """Return the position (starting with "a") within the iteration
+ """
+
+ def Letter():
+ """Return the position (starting with "A") within the iteration
+ """
+
+ def roman():
+ """Return the position (starting with "i") within the iteration
+ """
+
+ def Roman():
+ """Return the position (starting with "I") within the iteration
+ """
+
+ def item():
+ """Return the item at the current position
+ """
+
+ def length():
+ """Return the length of the sequence
+
+ Note that this may fail if the TAL iterator was created on a Python
+ iterator.
+ """
Modified: z3c.pt/trunk/src/z3c/pt/utils.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/utils.py 2008-09-01 15:23:52 UTC (rev 90655)
+++ z3c.pt/trunk/src/z3c/pt/utils.py 2008-09-01 15:28:16 UTC (rev 90656)
@@ -1,6 +1,9 @@
+from zope import interface
+
import sys
+import config
import logging
-import config
+import interfaces
from UserDict import UserDict
@@ -56,6 +59,8 @@
raise TypeError("Read-only dictionary does not support assignment.")
class repeatitem(object):
+ interface.implements(interfaces.ITALESIterator)
+
def __init__(self, iterator, length):
self.length = length
self.iterator = iterator
More information about the Checkins
mailing list