Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Upgrade to z3c.pt 2.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
malthe committed Jul 28, 2011
1 parent ee47de0 commit 43cd037
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,10 @@
Changelog
=========

In next release...

- Upgrade to newest Zope integration package.

2.1.3 (2011-07-23)
~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 2 additions & 3 deletions setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '2.1.3'
version = '2.1.4dev'

setup(name='five.pt',
version=version,
Expand All @@ -25,8 +25,7 @@
zip_safe=False,
install_requires=[
'setuptools',
'z3c.pt>=2.0',
'Chameleon>=2.0',
'z3c.pt>=2.1',
'sourcecodegen',
],
entry_points="""
Expand Down
17 changes: 8 additions & 9 deletions src/five/pt/expressions.py
Expand Up @@ -26,7 +26,6 @@

from chameleon.astutil import Symbol
from chameleon.astutil import Static
from chameleon.astutil import NameLookupRewriteVisitor
from chameleon.codegen import template
from chameleon.utils import decode_htmlentities
from sourcecodegen import generate_code
Expand Down Expand Up @@ -207,15 +206,19 @@ class UntrustedPythonExpr(expressions.PythonExpr):
rm = RestrictionMutator()
rt = RestrictionTransform()

builtins = dict(
# Make copy of parent expression builtins
builtins = expressions.PythonExpr.builtins.copy()

# Update builtins with Restricted Python utility builtins
builtins.update(dict(
(name, static(builtin)) for (name, builtin) in utility_builtins.items()
)
))

def nt(self, node):
def rewrite(self, node):
if node.id == 'repeat':
node.id = 'wrapped_repeat'
else:
node = self.builtins.get(node.id, node)
node = super(UntrustedPythonExpr, self).rewrite(node)

return node

Expand All @@ -229,8 +232,4 @@ def parse(self, string):
# Run restricted python transform
self.rt.visit(value)

# Rewrite builtins
transform = NameLookupRewriteVisitor(self.nt)
transform.visit(value)

return value

0 comments on commit 43cd037

Please sign in to comment.