Skip to content

Commit

Permalink
Remove unused imports and other small cleanups.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jeremy Hylton committed Dec 26, 2003
1 parent 1e3c62a commit 2fa2f59
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
20 changes: 9 additions & 11 deletions DT_Return.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,30 @@
# 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
import sys
from DT_Util import parse_params, name_param

class ReturnTag:
name='return'
expr=None

def __init__(self, args):
args = parse_params(args, name='', expr='')
name, expr = name_param(args,'var',1)
self.__name__, self.expr = name, expr
name, expr = name_param(args, 'var', 1)
self.__name__ = name
self.expr = expr

def render(self, md):
name=self.__name__
val=self.expr
if val is None:
val = md[name]
val = md[self.__name__]
else:
val=val.eval(md)
val = self.expr.eval(md)

raise DTReturn(val)

__call__=render
__call__ = render

class DTReturn:
def __init__(self, v):
self.v=v
self.v = v
6 changes: 4 additions & 2 deletions DT_String.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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_Var import Var, Call, Comment
Expand Down
19 changes: 10 additions & 9 deletions DT_Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
'''$Id: DT_Util.py,v 1.90 2003/11/28 16:45:22 jim Exp $'''
__version__='$Revision: 1.90 $'[11:-2]
'''$Id: DT_Util.py,v 1.91 2003/12/26 23:43:11 jeremy Exp $'''
__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 RestrictedPython.Guards import safe_builtins
from RestrictedPython.Utilities import utility_builtins
Expand All @@ -29,17 +30,17 @@
from zExceptions import Unauthorized as ValidationError

def int_param(params,md,name,default=0, st=type('')):
try: v=params[name]
except: v=default
v = params.get(name, default)
if v:
try: v=int(v)
try:
v = int(v)
except:
v=md[v]
if type(v) is st: v=int(v)
v = md[v]
if isinstance(v, str):
v = int(v)
return v or 0

try:
import ExtensionClass
from cDocumentTemplate import InstanceDict, TemplateDict, \
render_blocks, safe_callable, join_unicode
except:
Expand Down
5 changes: 2 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
This wrapper allows the (now many) document template modules to be
segregated in a separate package.
$Id: __init__.py,v 1.17 2002/08/14 22:29:53 mj Exp $'''
__version__='$Revision: 1.17 $'[11:-2]
$Id: __init__.py,v 1.18 2003/12/26 23:43:11 jeremy Exp $'''
__version__='$Revision: 1.18 $'[11:-2]

import ExtensionClass # work-around for import bug.
from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile

0 comments on commit 2fa2f59

Please sign in to comment.