Commit 687a32db authored by Jeremy Hylton's avatar Jeremy Hylton

Remove unused imports and other small cleanups.

The ExtensionClass imports mentions something about an import lock
problem, but provides no details.  The tests seem unaffected, so I'm
guessing this had to do with the old extension class that was a C
extension.
parent a1b6c4b7
...@@ -10,10 +10,9 @@ ...@@ -10,10 +10,9 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from DT_Util import parse_params, name_param, str from DT_Util import parse_params, name_param
import sys
class ReturnTag: class ReturnTag:
name='return' name='return'
...@@ -21,21 +20,20 @@ class ReturnTag: ...@@ -21,21 +20,20 @@ class ReturnTag:
def __init__(self, args): def __init__(self, args):
args = parse_params(args, name='', expr='') args = parse_params(args, name='', expr='')
name, expr = name_param(args,'var',1) name, expr = name_param(args, 'var', 1)
self.__name__, self.expr = name, expr self.__name__ = name
self.expr = expr
def render(self, md): def render(self, md):
name=self.__name__
val=self.expr
if val is None: if val is None:
val = md[name] val = md[self.__name__]
else: else:
val=val.eval(md) val = self.expr.eval(md)
raise DTReturn(val) raise DTReturn(val)
__call__=render __call__ = render
class DTReturn: class DTReturn:
def __init__(self, v): def __init__(self, v):
self.v=v self.v = v
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"$Id: DT_String.py,v 1.51 2002/08/14 22:29:52 mj Exp $" "$Id: DT_String.py,v 1.52 2003/12/26 23:43:11 jeremy Exp $"
import thread,re,exceptions,os import os
import thread
import re
from DT_Util import ParseError, InstanceDict, TemplateDict, render_blocks, str from DT_Util import ParseError, InstanceDict, TemplateDict, render_blocks, str
from DT_Var import Var, Call, Comment from DT_Var import Var, Call, Comment
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
'''$Id: DT_Util.py,v 1.90 2003/11/28 16:45:22 jim Exp $''' '''$Id: DT_Util.py,v 1.91 2003/12/26 23:43:11 jeremy Exp $'''
__version__='$Revision: 1.90 $'[11:-2] __version__='$Revision: 1.91 $'[11:-2]
import re
import re, os
from html_quote import html_quote, ustr # for import by other modules, dont remove! from html_quote import html_quote, ustr # for import by other modules, dont remove!
from RestrictedPython.Guards import safe_builtins from RestrictedPython.Guards import safe_builtins
from RestrictedPython.Utilities import utility_builtins from RestrictedPython.Utilities import utility_builtins
...@@ -29,17 +30,17 @@ ParseError='Document Template Parse Error' ...@@ -29,17 +30,17 @@ ParseError='Document Template Parse Error'
from zExceptions import Unauthorized as ValidationError from zExceptions import Unauthorized as ValidationError
def int_param(params,md,name,default=0, st=type('')): def int_param(params,md,name,default=0, st=type('')):
try: v=params[name] v = params.get(name, default)
except: v=default
if v: if v:
try: v=int(v) try:
v = int(v)
except: except:
v=md[v] v = md[v]
if type(v) is st: v=int(v) if isinstance(v, str):
v = int(v)
return v or 0 return v or 0
try: try:
import ExtensionClass
from cDocumentTemplate import InstanceDict, TemplateDict, \ from cDocumentTemplate import InstanceDict, TemplateDict, \
render_blocks, safe_callable, join_unicode render_blocks, safe_callable, join_unicode
except: except:
......
...@@ -15,8 +15,7 @@ __doc__='''Package wrapper for Document Template ...@@ -15,8 +15,7 @@ __doc__='''Package wrapper for Document Template
This wrapper allows the (now many) document template modules to be This wrapper allows the (now many) document template modules to be
segregated in a separate package. segregated in a separate package.
$Id: __init__.py,v 1.17 2002/08/14 22:29:53 mj Exp $''' $Id: __init__.py,v 1.18 2003/12/26 23:43:11 jeremy Exp $'''
__version__='$Revision: 1.17 $'[11:-2] __version__='$Revision: 1.18 $'[11:-2]
import ExtensionClass # work-around for import bug.
from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment