Skip to content

Commit

Permalink
Merged RestrictedPythonBranch!
Browse files Browse the repository at this point in the history
  • Loading branch information
hathawsh committed Apr 27, 2001
1 parent 2d7dcae commit 1f5e492
Show file tree
Hide file tree
Showing 15 changed files with 735 additions and 361 deletions.
48 changes: 26 additions & 22 deletions DT_In.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,12 @@
''' #'

__rcs_id__='$Id: DT_In.py,v 1.49 2001/04/27 18:07:09 andreas Exp $'
__version__='$Revision: 1.49 $'[11:-2]
__rcs_id__='$Id: DT_In.py,v 1.50 2001/04/27 20:27:39 shane Exp $'
__version__='$Revision: 1.50 $'[11:-2]

import sys
from DT_Util import ParseError, parse_params, name_param, str
from DT_Util import render_blocks, InstanceDict, ValidationError, VSEval, expr_globals
from DT_Util import render_blocks, InstanceDict, ValidationError, Eval
from string import find, atoi, join, split, lower
import re
from DT_InSV import sequence_variables, opt
Expand Down Expand Up @@ -445,10 +446,10 @@ def __init__(self, blocks):
if sort=='sequence-item': self.sort=''

if has_key('sort_expr'):
self.sort_expr=VSEval.Eval(args['sort_expr'], expr_globals)
self.sort_expr=Eval(args['sort_expr'])

if has_key('reverse_expr'):
self.reverse_expr=VSEval.Eval(args['reverse_expr'], expr_globals)
self.reverse_expr=Eval(args['reverse_expr'])

if has_key('reverse'):
self.reverse=args['reverse']
Expand Down Expand Up @@ -596,7 +597,7 @@ def renderwb(self, md):
else:
result = []
append=result.append
validate=md.validate
read_guard = md.read_guard
for index in range(first,end):
# preset
kw['previous-sequence']= 0
Expand Down Expand Up @@ -626,17 +627,18 @@ def renderwb(self, md):

if index==last: kw['sequence-end']=1

client=sequence[index]

if validate is not None:
try: vv=validate(sequence,sequence,None,client,md)
except: vv=0
if not vv:
if read_guard is not None:
try: client = read_guard(sequence)[index]
except ValidationError, vv:
if (params.has_key('skip_unauthorized') and
params['skip_unauthorized']):
if index==first: kw['sequence-start']=0
continue
raise ValidationError, index
tb = sys.exc_info()[2]
raise ValidationError, '(item %s): %s' % (
index, vv), tb
else:
client = sequence[index]

kw['sequence-index']=index
if type(client)==TupleType and len(client)==2:
Expand All @@ -654,6 +656,7 @@ def renderwb(self, md):
result=join(result, '')

finally:
tb = None
if cache: pop()
pop()

Expand Down Expand Up @@ -709,20 +712,21 @@ def renderwob(self, md):
try:
result = []
append=result.append
validate=md.validate
read_guard = md.read_guard
for index in range(l):
if index==last: kw['sequence-end']=1
client=sequence[index]

if validate is not None:
try: vv=validate(sequence,sequence,None,client,md)
except: vv=0
if not vv:
if read_guard is not None:
try: client = read_guard(sequence)[index]
except ValidationError, vv:
if (self.args.has_key('skip_unauthorized') and
self.args['skip_unauthorized']):
if index==1: kw['sequence-start']=0
continue
raise ValidationError, index
tb = sys.exc_info()[2]
raise ValidationError, '(item %s): %s' % (
index, vv), tb
else:
client = sequence[index]

kw['sequence-index']=index
if type(client)==TupleType and len(client)==2:
Expand All @@ -738,6 +742,7 @@ def renderwob(self, md):
result=join(result, '')

finally:
tb = None
if cache: pop()
pop()

Expand Down Expand Up @@ -841,7 +846,6 @@ def int_param(params,md,name,default=0, st=type('')):
def nocase(str1, str2):
return cmp(lower(str1), lower(str2))

import sys
if sys.modules.has_key("locale"): # only if locale is already imported
from locale import strcoll

Expand Down
8 changes: 4 additions & 4 deletions DT_Let.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
as desired.
'''

from DT_Util import render_blocks, Eval, expr_globals, ParseError, strip
from DT_Util import render_blocks, Eval, ParseError, strip
from DT_Util import str # Probably needed due to hysterical pickles.
import re

Expand All @@ -132,7 +132,7 @@ def __init__(self, blocks):
if expr[:1]=='"' and expr[-1:]=='"' and len(expr) > 1:
# expr shorthand
expr=expr[1:-1]
try: args[i] = name, Eval(expr, expr_globals).eval
try: args[i] = name, Eval(expr).eval
except SyntaxError, v:
m,(huh,l,c,src) = v
raise ParseError, (
Expand Down Expand Up @@ -174,12 +174,12 @@ def parse_let_params(text,
value='"%s"' % mo1.group(3)
l=len(mo1.group(1))
else:
if not text or not strip(text): return result
if not text or not text.strip(): return result
raise ParseError, ('invalid parameter: "%s"' % text, tag)

result.append((name,value))

text=strip(text[l:])
text=text[l:].strip()
if text: return apply(parse_let_params,(text,result,tag),parms)
else: return result

6 changes: 3 additions & 3 deletions DT_Return.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__='$Revision: 1.2 $'[11:-2]
__version__='$Revision: 1.3 $'[11:-2]

from DT_Util import parse_params, name_param, html_quote, str
import string, sys
from DT_Util import parse_params, name_param, str
import string, sys
from string import find, split, join, atoi, rfind

class ReturnTag:
Expand Down
9 changes: 4 additions & 5 deletions DT_String.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

##############################################################################
#
# Zope Public License (ZPL) Version 1.0
Expand Down Expand Up @@ -83,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
"$Id: DT_String.py,v 1.40 2001/04/27 18:07:10 andreas Exp $"
"$Id: DT_String.py,v 1.41 2001/04/27 20:27:39 shane Exp $"

from string import split, strip
import thread,re
Expand Down Expand Up @@ -506,7 +505,7 @@ def __call__(self,client=None,mapping={},**kw):
if globals: push(globals)
if mapping:
push(mapping)
md.validate=self.validate
md.read_guard=self.read_guard
if client is not None:
if type(client)==type(()):
md.this=client[-1]
Expand Down Expand Up @@ -551,8 +550,8 @@ def __call__(self,client=None,mapping={},**kw):
if pushed: md._pop(pushed) # Get rid of circular reference!
md.level=level # Restore previous level

validate__roles__=()
validate=None
read_guard__roles__=()
read_guard=None

def __str__(self):
return self.read()
Expand Down
Loading

0 comments on commit 1f5e492

Please sign in to comment.