/usr/share/pyshared/myghty/args.py is in python-myghty 1.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # $Id: args.py 2013 2005-12-31 03:19:39Z zzzeek $
# args.py - component argument descriptor classes for Myghty
# Copyright (C) 2004, 2005 Michael Bayer mike_mp@zzzcomputing.com
#
# This module is part of Myghty and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
#
#
__all__ = ['ComponentArg', 'RequestArg', 'SubRequestArg', 'LocalArg', 'DynamicArg']
import myghty.exception as exception
class ComponentArg:
def __init__(self, name, required = True, default = None, linenumber = None):
self.name = name
if default is None:
self.required = required
elif not default:
self.default = None
self.required = True
else:
self.default = default
self.required = False
self.linenumber = linenumber
def do_get_arg(self, request, **params):
raise NotImplementedError()
def __repr__(self):
return "%s(%s, required = %s)" % (
self.__class__.__name__,
repr(self.name),
repr(self.required),
)
def get_arg(self, request, dictionary, **params):
try:
dictionary[self.name] = self.do_get_arg(request, **params)
except KeyError:
if self.required:
raise exception.MissingArgument("required %s argument %s not found" % (self.__class__.type, self.name))
class RequestArg(ComponentArg):
type = "request"
def do_get_arg(self, request, **params):
return request.root_request_args[self.name]
class SubRequestArg(ComponentArg):
type = "subrequest"
def do_get_arg(self, request, **params):
return request.request_args[self.name]
class LocalArg(ComponentArg):
type = "component"
def do_get_arg(self, request, **params):
return params[self.name]
class DynamicArg(ComponentArg):
type = "dynamic"
def do_get_arg(self, request, **params):
def find(request, params):
yield params
while request is not None:
yield request.request_args
request = request.parent_request
for d in find(request, params):
if d.has_key(self.name):
return d[self.name]
raise KeyError(self.name)
|