There is another problem with the SkipTemplate mechanism.
When a template is skipped with "raise $SkipTemplate" or
"$skip_template(...)", then an error is printed on the console,
when actually this is not an error but intended behavior.
And if you raise $SkipTemplate(message), then only the error
is printed on the console, but the message is ignored.
The problem is in the paste.script.copydir.sub_catcher function:
try:
return func(*args, **kw)
except Exception, e:
print 'Error in file %s:' % filename
if isinstance(e, NameError):
items = vars.items()
items.sort()
for name, value in items:
print '%s = %r' % (name, value)
raise
I suggest replacing this with something like this:
try:
return func(*args, **kw)
except Exception, e:
if isinstance(e, SkipTemplate):
print 'Skipped file %s' % filename
if str(e):
print str(e)
else:
print 'Error in file %s:' % filename
if isinstance(e, NameError):
items = vars.items()
items.sort()
for name, value in items:
print '%s = %r' % (name, value)
raise
As another suggestion, the skip_template function
should also accept an optional error messages.
I.e. instead of:
def skip_template(condition=True):
if condition:
raise SkipTemplate()
I suggest the following:
def skip_template(condition=True, *args):
if condition:
raise SkipTemplate(*args)
-- Christoph
_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users