2 from zope.interface import Interface
3 from nevow import loaders
4 from nevow.util import resource_filename
6 class IClient(Interface):
11 return loaders.xmlfile(resource_filename('allmydata.web', '%s' % name))
13 def boolean_of_arg(arg):
14 assert arg.lower() in ("true", "t", "1", "false", "f", "0", "on", "off")
15 return arg.lower() in ("true", "t", "1", "on")
17 def get_arg(req, argname, default=None, multiple=False):
18 """Extract an argument from either the query args (req.args) or the form
19 body fields (req.fields). If multiple=False, this returns a single value
20 (or the default, which defaults to None), and the query args take
21 precedence. If multiple=True, this returns a tuple of arguments (possibly
22 empty), starting with all those in the query args.
25 if argname in req.args:
26 results.extend(req.args[argname])
27 if req.fields and argname in req.fields:
28 results.append(req.fields[argname].value)