gavo.web.root module

The root resource of the data center.

class gavo.web.root.ArchiveService[source]

Bases: TemplatedPage

The root resource on the data center.

It does the main dispatching based on four mechanisms:

  1. redirects – one-segments fragments that redirect somewhere else.

    This is for “bad” shortcuts corresponding to input directory name exclusively (since it’s so messy). These will not match if path has more than one segment.

  2. statics – first segment leads to a resource that gets passed any

    additional segments.

  3. mappings – first segment is replaced by something else, processing

    continues.

  4. resource based – consisting of an RD id, a service id, a renderer and

    possibly further segments.

The first three mechanisms only look at the first segment to determine any action (except that redirect is skipped if len(segments)>1).

The statics and mappings are configured on the class level.

classmethod addMapping(key, segments)[source]
classmethod addRedirect(key, destination)[source]
classmethod addStatic(key, resource)[source]
getChild(name, request)[source]

Retrieve a ‘child’ resource from me.

Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().

This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.

For example, the URL /foo/bar/baz will normally be:

| site.resource.getChild('foo').getChild('bar').getChild('baz').

However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.

Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.

classmethod installVanityMap()[source]

builds the redirects prescribed by the system-wide vanity map.

mappings = {'HSOY': ['tableinfo', 'hsoy.main'], 'TOSS': ['toss', 'q', 'legacy', 'form'], 'browse': ['__system__', 'services', 'overview', 'rdinfo'], 'datalinkuws': ['__system__', 'products', 'p', 'dlasync'], 'fhssa': ['flashheros', 'q', 'ssa', 'ssap.xml'], 'genrd': ['__system__', 'run', 'genrd'], 'getproduct': ['__system__', 'products', 'p', 'get'], 'getproducts': ['__system__', 'products', 'products', 'p', 'get'], 'oai.xml': ['__system__', 'services', 'registry', 'pubreg.xml'], 'odoc': ['__system__', 'services', 'overview', 'external'], 'regrss': ['registryrss', 'q', 'rss', 'static', 'feed.xml'], 'sdexter': ['dexter', 'ui', 'ui', 'custom'], 'seffe': ['__system__', 'services', 'overview', 'admin'], 'tableinfo': ['__system__', 'dc_tables', 'show', 'tableinfo'], 'tablenote': ['__system__', 'dc_tables', 'show', 'tablenote'], 'tap': ['__system__', 'tap', 'run']}
redirects = {'ColStats-1': '/schemata/Colstats-v1.0.xsd', 'adql': '/__system__/adql/query/form', 'apfs': '/apfs/res/apfs_new/catquery/form', 'inflight': '/inflight/res/lc1/ui/fixed', 'lensdemo/view/q/form': '/lensunion/q/im/form', 'ppmxl': '/ppmxl/q/cone/info'}
render(request)[source]

Render a given resource. See L{IResource}’s render method.

I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.

Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.

@see: L{IResource.render}

statics = {'.well-known': <gavo.web.ifpages.WellKnown object>, '3rdparty': <gavo.web.ifpages.ThirdPartyCachePage object>, 'clientcount': <gavo.web.ifpages.CurReaders object>, 'fancyroot': <twisted.web.resource.Resource object>, 'favicon.ico': FilePath('/home/unimut/www/unimut/favicon.ico'), 'favicon.png': <twisted.web.static.Data object>, 'getRR': <gavo.web.metarender.ResourceRecordMaker object>, 'login': <gavo.web.ifpages.LoginPage object>, 'robots.txt': <gavo.web.ifpages.RobotsTxt object>, 'schemata': <gavo.web.ifpages.SchemaServer object>, 'static': <gavo.web.ifpages.StaticServer object>, 'teapot': <gavo.web.ifpages.Teapot object>, 'test': <gavo.web.webtests.Tests object>}
timestampStarted = 1697806282.6679134
gavo.web.root.formatDefaultLog(timestamp, request)[source]

returns a log line for request in DaCHS’ default format.

It doesn’t include IP addresses, referrers or user agents, which means you should be fine as far as processing personal data is concerned.

The format itself should be compatible with “combined” logs.

gavo.web.root.getLogFormatter()[source]

returns a log formatter for this site.

Right now, this just interprets [web]logger.

gavo.web.root.makeFaviconPNG()[source]

returns a “small” version of the logo.

This is used mainly for SAMP logos at them moment.