desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Return a :class:`.Template` from the given ``uri``. The ``uri`` resolution is relative to the ``uri`` of this :class:`.Namespace` object\'s :class:`.Template`.'
def get_template(self, uri):
return _lookup_template(self.context, uri, self._templateuri)
'Return a value from the :class:`.Cache` referenced by this :class:`.Namespace` object\'s :class:`.Template`. The advantage to this method versus direct access to the :class:`.Cache` is that the configuration parameters declared in ``<%page>`` take effect here, thereby calling up the same configured backend as that con...
def get_cached(self, key, **kwargs):
return self.cache.get(key, **kwargs)
'Return the :class:`.Cache` object referenced by this :class:`.Namespace` object\'s :class:`.Template`.'
@property def cache(self):
return self.template.cache
'Include a file at the given ``uri``.'
def include_file(self, uri, **kwargs):
_include_file(self.context, uri, self._templateuri, **kwargs)
'The Python module referenced by this :class:`.Namespace`. If the namespace references a :class:`.Template`, then this module is the equivalent of ``template.module``, i.e. the generated module for the template.'
@property def module(self):
return self.template.module
'The path of the filesystem file used for this :class:`.Namespace`\'s module or template.'
@property def filename(self):
return self.template.filename
'The URI for this :class:`.Namespace`\'s template. I.e. whatever was sent to :meth:`.TemplateLookup.get_template()`. This is the equivalent of :attr:`.Template.uri`.'
@property def uri(self):
return self.template.uri
'The path of the filesystem file used for this :class:`.Namespace`\'s module or template.'
@property def filename(self):
return self.module.__file__
'Return the multiline comment at lineno split into a list of comment line numbers and the accompanying comment line'
@staticmethod def _split_comment(lineno, comment):
return [((lineno + index), line) for (index, line) in enumerate(comment.splitlines())]
'Loads a template from a file or a string'
def load_template(self, templatename, template_string=None):
if (template_string is not None): return Template(template_string, **self.tmpl_options) if ('/' not in templatename): templatename = ((('/' + templatename.replace('.', '/')) + '.') + self.extension) return self.lookup.get_template(templatename)
'Replace characters with their character entity references. Only characters corresponding to a named entity are replaced.'
def escape_entities(self, text):
return compat.text_type(text).translate(self.codepoint2entity)
'Replace characters with their character references. Replace characters by their named entity references. Non-ASCII characters, if they do not have a named entity reference, are replaced by numerical character references. The return value is guaranteed to be ASCII.'
def escape(self, text):
return self.__escapable.sub(self.__escape, compat.text_type(text)).encode('ascii')
'Unescape character references. All character references (both entity references and numerical character references) are unescaped.'
def unescape(self, text):
return self.__characterrefs.sub(self.__unescape, text)
'Return ``True`` if this :class:`.TemplateLookup` is capable of returning a :class:`.Template` object for the given ``uri``. :param uri: String URI of the template to be resolved.'
def has_template(self, uri):
try: self.get_template(uri) return True except exceptions.TemplateLookupException: return False
'Return a :class:`.Template` object corresponding to the given ``uri``. The default implementation raises :class:`.NotImplementedError`. Implementations should raise :class:`.TemplateLookupException` if the given ``uri`` cannot be resolved. :param uri: String URI of the template to be resolved. :param relativeto: if pr...
def get_template(self, uri, relativeto=None):
raise NotImplementedError()
'Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`.'
def filename_to_uri(self, uri, filename):
return uri
'Adjust the given ``uri`` based on the calling ``filename``. When this method is called from the runtime, the ``filename`` parameter is taken directly to the ``filename`` attribute of the calling template. Therefore a custom :class:`.TemplateCollection` subclass can place any string identifier desired in the ``filename...
def adjust_uri(self, uri, filename):
return uri
'Return a :class:`.Template` object corresponding to the given ``uri``. .. note:: The ``relativeto`` argument is not supported here at the moment.'
def get_template(self, uri):
try: if self.filesystem_checks: return self._check(uri, self._collection[uri]) else: return self._collection[uri] except KeyError: u = re.sub('^\\/+', '', uri) for dir in self.directories: srcfile = posixpath.normpath(posixpath.join(dir, u)) ...
'Adjust the given ``uri`` based on the given relative URI.'
def adjust_uri(self, uri, relativeto):
key = (uri, relativeto) if (key in self._uri_cache): return self._uri_cache[key] if (uri[0] != '/'): if (relativeto is not None): v = self._uri_cache[key] = posixpath.join(posixpath.dirname(relativeto), uri) else: v = self._uri_cache[key] = ('/' + uri) els...
'Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`.'
def filename_to_uri(self, filename):
try: return self._uri_cache[filename] except KeyError: value = self._relativeize(filename) self._uri_cache[filename] = value return value
'Return the portion of a filename that is \'relative\' to the directories in this lookup.'
def _relativeize(self, filename):
filename = posixpath.normpath(filename) for dir in self.directories: if (filename[0:len(dir)] == dir): return filename[len(dir):] else: return None
'Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given string of ``text``.'
def put_string(self, uri, text):
self._collection[uri] = Template(text, lookup=self, uri=uri, **self.template_args)
'Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given :class:`.Template` object.'
def put_template(self, uri, template):
self._collection[uri] = template
'print a line or lines of python which already contain indentation. The indentation of the total block of lines will be adjusted to that of the current indent level.'
def write_indented_block(self, block):
self.in_indent_lines = False for l in re.split('\\r?\\n', block): self.line_buffer.append(l) self._update_lineno(1)
'print a series of lines of python.'
def writelines(self, *lines):
for line in lines: self.writeline(line)
'print a line of python, indenting it according to the current indent level. this also adjusts the indentation counter according to the content of the line.'
def writeline(self, line):
if (not self.in_indent_lines): self._flush_adjusted_lines() self.in_indent_lines = True if ((line is None) or re.match('^\\s*#', line) or re.match('^\\s*$', line)): hastext = False else: hastext = True is_comment = (line and len(line) and (line[0] == '#')) if ((not is...
'close this printer, flushing any remaining lines.'
def close(self):
self._flush_adjusted_lines()
'return true if the given line is an \'unindentor\', relative to the last \'indent\' event received.'
def _is_unindentor(self, line):
if (len(self.indent_detail) == 0): return False indentor = self.indent_detail[(-1)] if (indentor is None): return False match = re.match('^\\s*(else|elif|except|finally).*\\:', line) if (not match): return False return True
'indent the given line according to the current indent level. stripspace is a string of space that will be truncated from the start of the line before indenting.'
def _indent_line(self, line, stripspace=''):
return re.sub(('^%s' % stripspace), (self.indentstring * self.indent), line)
'reset the flags which would indicate we are in a backslashed or triple-quoted section.'
def _reset_multi_line_flags(self):
(self.backslashed, self.triplequoted) = (False, False)
'return true if the given line is part of a multi-line block, via backslash or triple-quote.'
def _in_multi_line(self, line):
current_state = (self.backslashed or self.triplequoted) if re.search('\\\\$', line): self.backslashed = True else: self.backslashed = False triples = len(re.findall('\\"\\"\\"|\\\'\\\'\\\'', line)) if ((triples == 1) or ((triples % 2) != 0)): self.triplequoted = (not self.tri...
'Return the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead.'
def get_visitor(self, node):
method = ('visit_' + node.__class__.__name__) return getattr(self, method, None)
'Visit a node.'
def visit(self, node):
f = self.get_visitor(node) if (f is not None): return f(node) return self.generic_visit(node)
'Called if no explicit visitor function exists for a node.'
def generic_visit(self, node):
for (field, value) in iter_fields(node): if isinstance(value, list): for item in value: if isinstance(item, AST): self.visit(item) elif isinstance(value, AST): self.visit(value)
'Retrieve a value from the cache, using the given creation function to generate a new value.'
def get_or_create(self, key, creation_function, **kw):
return self._ctx_get_or_create(key, creation_function, None, **kw)
'Retrieve a value from the cache, using the given creation function to generate a new value.'
def _ctx_get_or_create(self, key, creation_function, context, **kw):
if (not self.template.cache_enabled): return creation_function() return self.impl.get_or_create(key, creation_function, **self._get_cache_kw(kw, context))
'Place a value in the cache. :param key: the value\'s key. :param value: the value. :param \**kw: cache configuration arguments.'
def set(self, key, value, **kw):
self.impl.set(key, value, **self._get_cache_kw(kw, None))
'Retrieve a value from the cache. :param key: the value\'s key. :param \**kw: cache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend.'
def get(self, key, **kw):
return self.impl.get(key, **self._get_cache_kw(kw, None))
'Invalidate a value in the cache. :param key: the value\'s key. :param \**kw: cache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend.'
def invalidate(self, key, **kw):
self.impl.invalidate(key, **self._get_cache_kw(kw, None))
'Invalidate the cached content of the "body" method for this template.'
def invalidate_body(self):
self.invalidate('render_body', __M_defname='render_body')
'Invalidate the cached content of a particular ``<%def>`` within this template.'
def invalidate_def(self, name):
self.invalidate(('render_%s' % name), __M_defname=('render_%s' % name))
'Invalidate a nested ``<%def>`` within this template. Caching of nested defs is a blunt tool as there is no management of scope -- nested defs that use cache tags need to have names unique of all other nested defs in the template, else their content will be overwritten by each other.'
def invalidate_closure(self, name):
self.invalidate(name, __M_defname=name)
'Retrieve a value from the cache, using the given creation function to generate a new value. This function *must* return a value, either from the cache, or via the given creation function. If the creation function is called, the newly created value should be populated into the cache under the given key before being ret...
def get_or_create(self, key, creation_function, **kw):
raise NotImplementedError()
'Place a value in the cache. :param key: the value\'s key. :param value: the value. :param \**kw: cache configuration arguments.'
def set(self, key, value, **kw):
raise NotImplementedError()
'Retrieve a value from the cache. :param key: the value\'s key. :param \**kw: cache configuration arguments.'
def get(self, key, **kw):
raise NotImplementedError()
'Invalidate a value in the cache. :param key: the value\'s key. :param \**kw: cache configuration arguments.'
def invalidate(self, key, **kw):
raise NotImplementedError()
'Pass ``cause`` if this exception was caused by another exception.'
def __init__(self, message=None, cause=None):
self.message = message self.cause = cause
'Update remaining requests based on the elapsed time since they were last calculated.'
def _update_remaining(self):
if (self.remaining_requests is None): self.remaining_requests = float(limit_requests) else: since_last_call = (time.time() - self.last_call) self.remaining_requests += (since_last_call * (limit_requests / limit_interval)) self.remaining_requests = min(self.remaining_requests, flo...
'The MusicBrainz server also accepts UTF-8 encoded passwords.'
def _encode_utf8(self, msg):
encoding = (sys.stdin.encoding or locale.getpreferredencoding()) try: msg = msg.decode(encoding) except AttributeError: pass return msg.encode('utf-8')
'add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...)'
def add_argument(self, *args, **kwargs):
chars = self.prefix_chars if ((not args) or ((len(args) == 1) and (args[0][0] not in chars))): if (args and ('dest' in kwargs)): raise ValueError('dest supplied twice for positional argument') kwargs = self._get_positional_kwargs(*args, **kwargs) else: kwar...
'error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception.'
def error(self, message):
self.print_usage(_sys.stderr) args = {'prog': self.prog, 'message': message} self.exit(2, (_('%(prog)s: error: %(message)s\n') % args))
'Add a key (register ?)'
def addkey(self, key):
if (type(key) == str): if (not (key in self._apikey)): self._apikey.append(key) elif (type(key) == list): for k in key: if (not (k in self._apikey)): self._apikey.append(k)
'Removes a key (unregister ?)'
def delkey(self, key):
if (type(key) == str): if (key in self._apikey): self._apikey.remove(key) elif (type(key) == list): for k in key: if (key in self._apikey): self._apikey.remove(k)
'Sets the developer key (and check it has the good length)'
def developerkey(self, developerkey):
if ((type(developerkey) == str) and (len(developerkey) == 48)): self._developerkey = developerkey
'Pushes a message on the registered API keys. takes 5 arguments: - (req) application: application name [256] - (req) event: event name [1000] - (req) description: description [10000] - (opt) url: url [512] - (opt) contenttype: Content Type (act: None (plain text) or text/html) - (o...
def push(self, application='', event='', description='', url='', contenttype=None, priority=0, batch_mode=False, html=False):
datas = {'application': application[:256].encode('utf8'), 'event': event[:1024].encode('utf8'), 'description': description[:10000].encode('utf8'), 'priority': priority} if url: datas['url'] = url[:512] if ((contenttype == 'text/html') or (html == True)): datas['content-type'] = 'text/html' ...
'True iff b[i] is a consonant'
def cons(self, i):
if (self.b[i] in 'aeiou'): return False elif (self.b[i] == 'y'): return (True if (i == 0) else (not self.cons((i - 1)))) return True
'True iff 0...j contains vowel'
def vowel_in_stem(self):
for i in _range(0, (self.j + 1)): if (not self.cons(i)): return True return False
'True iff j, j-1 contains double consonant'
def doublec(self, j):
if ((j < 1) or (self.b[j] != self.b[(j - 1)])): return False return self.cons(j)
'True iff i-2,i-1,i is consonent-vowel consonant and if second c isn\'t w,x, or y. used to restore e at end of short words like cave, love, hope, crime'
def cvc(self, i):
if ((i < 2) or (not self.cons(i)) or self.cons((i - 1)) or (not self.cons((i - 2))) or (self.b[i] in 'wxy')): return False return True
'set j+1...k to string s, readjusting k'
def setto(self, s):
length = len(s) self.b[(self.j + 1):((self.j + 1) + length)] = s self.k = (self.j + length)
'turn terminal y into i if there\'s a vowel in stem'
def step1c(self):
if (self.ends(['y']) and self.vowel_in_stem()): self.b[self.k] = 'i'
'Read the request body into fp_out (or make_file() if None). Return fp_out.'
def read_into_file(self, fp_out=None):
if (fp_out is None): fp_out = self.make_file() self.read(fp_out=fp_out) return fp_out
'Return a file-like object into which the request body will be read. By default, this will return a TemporaryFile. Override as needed. See also :attr:`cherrypy._cpreqbody.Part.maxrambytes`.'
def make_file(self):
return tempfile.TemporaryFile()
'Return this entity as a string, whether stored in a file or not.'
def fullvalue(self):
if self.file: self.file.seek(0) value = self.file.read() self.file.seek(0) else: value = self.value return value
'Execute the best-match processor for the given media type.'
def process(self):
proc = None ct = self.content_type.value try: proc = self.processors[ct] except KeyError: toptype = ct.split('/', 1)[0] try: proc = self.processors[toptype] except KeyError: pass if (proc is None): self.default_proc() else: ...
'Called if a more-specific processor is not found for the ``Content-Type``.'
def default_proc(self):
pass
'Read bytes from self.fp and return or write them to a file. If the \'fp_out\' argument is None (the default), all bytes read are returned in a single byte string. If the \'fp_out\' argument is not None, it must be a file-like object that supports the \'write\' method; all bytes read will be written to the fp, and that...
def read_lines_to_boundary(self, fp_out=None):
endmarker = (self.boundary + ntob('--')) delim = ntob('') prev_lf = True lines = [] seen = 0 while True: line = self.fp.readline((1 << 16)) if (not line): raise EOFError('Illegal end of multipart body.') if (line.startswith(ntob('--')) and prev_lf)...
'Called if a more-specific processor is not found for the ``Content-Type``.'
def default_proc(self):
if self.filename: self.file = self.read_into_file() else: result = self.read_lines_to_boundary() if isinstance(result, basestring): self.value = result else: self.file = result
'Read the request body into fp_out (or make_file() if None). Return fp_out.'
def read_into_file(self, fp_out=None):
if (fp_out is None): fp_out = self.make_file() self.read_lines_to_boundary(fp_out=fp_out) return fp_out
'Read bytes from the request body and return or write them to a file. A number of bytes less than or equal to the \'size\' argument are read off the socket. The actual number of bytes read are tracked in self.bytes_read. The number may be smaller than \'size\' when 1) the client sends fewer bytes, 2) the \'Content-Leng...
def read(self, size=None, fp_out=None):
if (self.length is None): if (size is None): remaining = inf else: remaining = size else: remaining = (self.length - self.bytes_read) if (size and (size < remaining)): remaining = size if (remaining == 0): self.finish() if (...
'Read a line from the request body and return it.'
def readline(self, size=None):
chunks = [] while ((size is None) or (size > 0)): chunksize = self.bufsize if ((size is not None) and (size < self.bufsize)): chunksize = size data = self.read(chunksize) if (not data): break pos = (data.find(ntob('\n')) + 1) if pos: ...
'Read lines from the request body and return them.'
def readlines(self, sizehint=None):
if (self.length is not None): if (sizehint is None): sizehint = (self.length - self.bytes_read) else: sizehint = min(sizehint, (self.length - self.bytes_read)) lines = [] seen = 0 while True: line = self.readline() if (not line): break ...
'Process the request entity based on its Content-Type.'
def process(self):
h = cherrypy.serving.request.headers if (('Content-Length' not in h) and ('Transfer-Encoding' not in h)): raise cherrypy.HTTPError(411) self.fp = SizedReader(self.fp, self.length, self.maxbytes, bufsize=self.bufsize, has_trailers=('Trailer' in h)) super(RequestBody, self).process() request_p...
'Close and reopen all file handlers.'
def reopen_files(self):
for log in (self.error_log, self.access_log): for h in log.handlers: if isinstance(h, logging.FileHandler): h.acquire() h.stream.close() h.stream = open(h.baseFilename, h.mode) h.release()
'Write the given ``msg`` to the error log. This is not just for errors! Applications may call this at any time to log application-specific information. If ``traceback`` is True, the traceback of the current exception (if any) will be appended to ``msg``.'
def error(self, msg='', context='', severity=logging.INFO, traceback=False):
if traceback: msg += _cperror.format_exc() self.error_log.log(severity, ' '.join((self.time(), context, msg)))
'An alias for ``error``.'
def __call__(self, *args, **kwargs):
return self.error(*args, **kwargs)
'Write to the access log (in Apache/NCSA Combined Log format). See the `apache documentation <http://httpd.apache.org/docs/current/logs.html#combined>`_ for format details. CherryPy calls this automatically for you. Note there are no arguments; it collects the data itself from :class:`cherrypy.request<cherrypy._cpreque...
def access(self):
request = cherrypy.serving.request remote = request.remote response = cherrypy.serving.response outheaders = response.headers inheaders = request.headers if (response.output_status is None): status = '-' else: status = response.output_status.split(ntob(' '), 1)[0] ...
'Return now() in Apache Common Log Format (no timezone).'
def time(self):
now = datetime.datetime.now() monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] month = monthnames[(now.month - 1)].capitalize() return ('[%02d/%s/%04d:%02d:%02d:%02d]' % (now.day, month, now.year, now.hour, now.minute, now.second))
'Flushes the stream.'
def flush(self):
try: stream = cherrypy.serving.request.wsgi_environ.get('wsgi.errors') except (AttributeError, KeyError): pass else: stream.flush()
'Emit a record.'
def emit(self, record):
try: stream = cherrypy.serving.request.wsgi_environ.get('wsgi.errors') except (AttributeError, KeyError): pass else: try: msg = self.format(record) fs = '%s\n' import types if (not hasattr(types, 'UnicodeType')): stream....
'Run all check_* methods.'
def __call__(self):
if self.on: oldformatwarning = warnings.formatwarning warnings.formatwarning = self.formatwarning try: for name in dir(self): if name.startswith('check_'): method = getattr(self, name) if (method and hasattr(method, '__call_...
'Function to format a warning.'
def formatwarning(self, message, category, filename, lineno, line=None):
return ('CherryPy Checker:\n%s\n\n' % message)
'Check for Application config with sections that repeat script_name.'
def check_app_config_entries_dont_start_with_script_name(self):
for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue if (not app.config): continue if (sn == ''): continue sn_atoms = sn.strip('/').split('/') for key in app.config.keys(): key_at...
'Check for mounted Applications that have site-scoped config.'
def check_site_config_entries_in_app_config(self):
for (sn, app) in iteritems(cherrypy.tree.apps): if (not isinstance(app, cherrypy.Application)): continue msg = [] for (section, entries) in iteritems(app.config): if section.startswith('/'): for (key, value) in iteritems(entries): f...
'Check for mounted Applications that have no config.'
def check_skipped_app_config(self):
for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue if (not app.config): msg = ('The Application mounted at %r has an empty config.' % sn) if self.global_config_contained_paths: ...
'Check for Application config with extraneous brackets in section names.'
def check_app_config_brackets(self):
for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue if (not app.config): continue for key in app.config.keys(): if (key.startswith('[') or key.endswith(']')): warnings.warn(('The applicat...
'Check Application config for incorrect static paths.'
def check_static_paths(self):
request = cherrypy.request for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue request.app = app for section in app.config: request.get_resource((section + '/dummy.html')) conf = request.config.get ...
'Process config and warn on each obsolete or deprecated entry.'
def _compat(self, config):
for (section, conf) in config.items(): if isinstance(conf, dict): for (k, v) in conf.items(): if (k in self.obsolete): warnings.warn(('%r is obsolete. Use %r instead.\nsection: [%s]' % (k, self.obsolete[k], section))) elif (k ...
'Process config and warn on each obsolete or deprecated entry.'
def check_compatibility(self):
self._compat(cherrypy.config) for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue self._compat(app.config)
'Process config and warn on each unknown config namespace.'
def check_config_namespaces(self):
for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue self._known_ns(app)
'Assert that config values are of the same type as default values.'
def check_config_types(self):
self._known_types(cherrypy.config) for (sn, app) in cherrypy.tree.apps.items(): if (not isinstance(app, cherrypy.Application)): continue self._known_types(app.config)
'Warn if any socket_host is \'localhost\'. See #711.'
def check_localhost(self):
for (k, v) in cherrypy.config.items(): if ((k == 'server.socket_host') and (v == 'localhost')): warnings.warn("The use of 'localhost' as a socket host can cause problems on newer systems, since 'localhost' can map to either an IPv4 ...
'Copy func parameter names to obj attributes.'
def _setargs(self):
try: for arg in _getargs(self.callable): setattr(self, arg, None) except (TypeError, AttributeError): if hasattr(self.callable, '__call__'): for arg in _getargs(self.callable.__call__): setattr(self, arg, None) except NotImplementedError: pass ...
'Return a dict of configuration entries for this Tool.'
def _merged_args(self, d=None):
if d: conf = d.copy() else: conf = {} tm = cherrypy.serving.request.toolmaps[self.namespace] if (self._name in tm): conf.update(tm[self._name]) if ('on' in conf): del conf['on'] return conf
'Compile-time decorator (turn on the tool in config). For example:: @tools.proxy() def whats_my_base(self): return cherrypy.request.base whats_my_base.exposed = True'
def __call__(self, *args, **kwargs):
if args: raise TypeError(('The %r Tool does not accept positional arguments; you must use keyword arguments.' % self._name)) def tool_decorator(f): if (not hasattr(f, '_cp_config')): f._cp_config = {} subspace = (((self.namespace + '.') + s...
'Hook this tool into cherrypy.request. The standard CherryPy request object will automatically call this method when the tool is "turned on" in config.'
def _setup(self):
conf = self._merged_args() p = conf.pop('priority', None) if (p is None): p = getattr(self.callable, 'priority', self._priority) cherrypy.serving.request.hooks.attach(self._point, self.callable, priority=p, **conf)
'Use this tool as a CherryPy page handler. For example:: class Root: nav = tools.staticdir.handler(section="/nav", dir="nav", root=absDir)'
def handler(self, *args, **kwargs):
def handle_func(*a, **kw): handled = self.callable(*args, **self._merged_args(kwargs)) if (not handled): raise cherrypy.NotFound() return cherrypy.serving.response.body handle_func.exposed = True return handle_func
'Hook this tool into cherrypy.request. The standard CherryPy request object will automatically call this method when the tool is "turned on" in config.'
def _setup(self):
conf = self._merged_args() p = conf.pop('priority', None) if (p is None): p = getattr(self.callable, 'priority', self._priority) cherrypy.serving.request.hooks.attach(self._point, self._wrapper, priority=p, **conf)
'Hook this tool into cherrypy.request. The standard CherryPy request object will automatically call this method when the tool is "turned on" in config.'
def _setup(self):
cherrypy.serving.request.error_response = self._wrapper
'Hook this tool into cherrypy.request. The standard CherryPy request object will automatically call this method when the tool is "turned on" in config.'
def _setup(self):
hooks = cherrypy.serving.request.hooks conf = self._merged_args() p = conf.pop('priority', None) if (p is None): p = getattr(self.callable, 'priority', self._priority) hooks.attach(self._point, self.callable, priority=p, **conf) locking = conf.pop('locking', 'implicit') if (locking =...