gavo.web.constantrender module

Renderer not reacting too strongly on user input.

There’s StaticRender just delivering certain files from within a service, and there’s FixedPageRenderer that just formats a defined template.

class gavo.web.constantrender.FixedPageRenderer(request, service)[source]

Bases: CustomTemplateMixin, ServiceBasedPage, HTMLResultRenderMixin

A renderer that renders a single template.

Use something like <template key="fixed">res/ft.html</template> in the enclosing service to tell the fixed renderer where to get this template from.

In the template, you can fetch parameters from the URL using something like <n:invisible n:data="parameter FOO" n:render="string"/>; you can also define new render and data functions on the service using customRF and customDF.

This is, in particular, used for the data center’s root page.

The fixed renderer is intended for non- or slowly changing content. It is annotated as cacheable, which means that DaCHS will in general only render it once and then cache it. If the render functions change independently of the RD, use the volatile renderer.

During development, users must add ?nocache=True to a fixed page URI to force DaCHS to reload the template.

Built-in services for such browser apps should go through the //run RD.

data_parameter(parName)[source]

lets you insert an URL parameter into the template.

Non-existing parameters are returned as an empty string.

data_result(request, tag)[source]
classmethod isBrowseable(service)[source]

returns True if this renderer applied to service is usable using a plain web browser.

classmethod isCacheable(segments, request)[source]

should return true if the content rendered will only change when the associated RD changes.

request is a nevow request object. web.root.ArchiveService already makes sure that you only see GET request without arguments and without a user, so you do not need to check this.

name = 'fixed'
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}

class gavo.web.constantrender.HiPSRenderer(request, service)[source]

Bases: StaticRenderer

A static renderer with a few amenities for HiPS trees.

To make this work, set the service’s staticData property

defaultType = 'text/plain'
classmethod isBrowseable(service)[source]

returns True if this renderer applied to service is usable using a plain web browser.

classmethod isCacheable(segments, request)[source]

should return true if the content rendered will only change when the associated RD changes.

request is a nevow request object. web.root.ArchiveService already makes sure that you only see GET request without arguments and without a user, so you do not need to check this.

name = 'hips'
urlUse = 'base'
class gavo.web.constantrender.StaticRenderer(request, service)[source]

Bases: ServiceBasedPage

A renderer that just hands through files.

The standard operation here is to set a staticData property pointing to a resdir-relative directory used to serve files for. Indices for directories are created.

You can define a root resource by giving an indexFile property on the service. Note in particular that you can use an index file with an extension of shtml. This lets you use nevow templates, but since metadata will be taken from the global context, that’s probably not terribly useful. You are probably looking for the fixed renderer if you find yourself needing this.

defaultType = 'text/html'
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 isBrowseable(service)[source]

returns True if this renderer applied to service is usable using a plain web browser.

classmethod isCacheable(segments, request)[source]

should return true if the content rendered will only change when the associated RD changes.

request is a nevow request object. web.root.ArchiveService already makes sure that you only see GET request without arguments and without a user, so you do not need to check this.

name = 'static'
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}

class gavo.web.constantrender.VolatilePageRenderer(request, service)[source]

Bases: FixedPageRenderer

A renderer rendering a single template with fast-changing results.

This is like the fixed renderer, except that the results are not cached.

classmethod isCacheable(segments, request)[source]

should return true if the content rendered will only change when the associated RD changes.

request is a nevow request object. web.root.ArchiveService already makes sure that you only see GET request without arguments and without a user, so you do not need to check this.

name = 'volatile'