gavo.web.metarender module

Renderers that take services “as arguments”.

class gavo.web.metarender.CoverageRenderer(request, service)[source]

Bases: MetaRenderer

A renderer returning various forms of a service’s spatial coverage.

This will return a 404 if the service doesn’t have a coverage.spatial meta (and will bomb out if that isn’t a SMoc).

Based on the accept header, it will return a PNG if the client indicates it’s interested in that or if it accepts text/html, in which case we assume it’s a browser; otherwise, it will produce a MOC in FITS format.

classmethod isCacheable(segments, request)[source]

only cache this if we return a PNG.

Our caching system doesn’t support content negotiation, so we can’t keep the FITS (and it’s fast to generate, so that doesn’t matter so much.

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

classmethod returnAPNG(request)[source]

returns true if request indicates we’re being retrieved by a web browser.

class gavo.web.metarender.EditionRenderer(request, service)[source]

Bases: MetaRenderer

A renderer representing a (tutorial-like) text document.

Not sure yet what I’ll do when people actually retrieve these.

This must have a meta accessURL with the document URI. It may have a sourceURL meta giving the VCS URI.

name = 'edition'
class gavo.web.metarender.ExternalRenderer(request, service)[source]

Bases: ServiceBasedPage

A renderer redirecting to an external resource.

These try to access an external publication on the parent service and ask it for an accessURL. If it doesn’t define one, this will lead to a redirect loop.

In the DC, external renderers are mainly used for registration of third-party browser-based services.

classmethod isBrowseable(service)[source]

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

name = 'external'
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.metarender.HowToCiteRenderer(request, service)[source]

Bases: MetaRenderer

A renderer that lets you format citation instructions.

customTemplate = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/howtocite.html'>
name = 'howtocite'
class gavo.web.metarender.MetaRenderer(request, service)[source]

Bases: CustomTemplateMixin, ServiceBasedPage

Renderers that are allowed on all services.

checkedRenderer = False
data_bibtexentry(request, tag)[source]

returns BibTeX for the current record.

This will return None if no BibTeX can be made.

data_otherServices(request, tag)[source]

returns a list of dicts describing other services provided by the the describing RD.

The class mixing this in needs to provide a describingRD attribute for this to work. This may be the same as self.service.rd, and the current service will be excluded from the list in this case.

ifbibcode(request, tag)[source]

renders its children if the source metadata looks like a bibcode.

ifkey(keyName)[source]
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.

sortOrder(request, tag)[source]
class gavo.web.metarender.RDInfoPage(request, rd)[source]

Bases: CustomTemplateMixin, ResourceBasedPage

A page giving infos about an RD.

This is not a renderer but a helper for RDInfoRenderer.

customTemplate = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/rdinfo.html'>
data_clientRdId(request, tag)[source]
data_services(request, tag)[source]
data_tables(request, tag)[source]
defaultLoader = <gavo.web.common.doctypedStan object>
classmethod makePageTitle(rd)[source]

returns a suitable title for the rd info page.

This is a class method to allow other renderers to generate titles for link anchors.

rdsvc(request, tag)[source]
rdtable(request, tag)[source]
title(request, tag)[source]
class gavo.web.metarender.RDInfoRenderer(request, service)[source]

Bases: CustomTemplateMixin, ServiceBasedPage

A renderer for displaying various properties about a resource descriptor.

This renderer could really be attached to any service since it does not call it, but it usually lives on //services/overview.

By virtue of builtin vanity, you can reach the rdinfo renderer at /browse, and thus you can access /browse/foo/q to view the RD infos. This is the form used by table registrations.

In addition to all services, this renderer also links tableinfos for all non-temporary, on-disk tables defined in the RD. When you actually want to hide some internal on-disk tables, you can set a property internal on the table (the value is ignored).

customTemplate = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/rdlist.html'>
data_publishedRDs(request, tag)[source]
defaultLoader = <gavo.web.common.doctypedStan object>
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}.

name = 'rdinfo'
class gavo.web.metarender.RendExplainer[source]

Bases: object

is a container for various functions having to do with explaining renderers on services.

Use the explain(renderer, service) class method.

classmethod explain(renderer, service)[source]
class gavo.web.metarender.ResourceRecordMaker[source]

Bases: Resource

A page that returns resource records for internal services.

This is basically like OAI-PMH getRecord, except we’re using rd/id/svcid from our path.

Also (and that’s fairly important for purx), this will use the _metadataUpdated meta for a modified header.

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}.

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.metarender.ServiceInfoRenderer(*args, **kwargs)[source]

Bases: MetaRenderer, IdManagerMixin

A renderer showing all kinds of metadata on a service.

This renderer produces the default referenceURL page. To change its appearance, override the serviceinfo.html template.

customTemplate = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/serviceinfo.html'>
data_browserURL(request, tag)[source]
data_htmlOutputFields(request, tag)[source]
data_inputFields(request, tag)[source]
data_internalpath(request, tag)[source]
data_publications(request, tag)[source]
data_rendAvail(request, tag)[source]
data_service(request, tag)[source]
data_votableOutputFields(request, tag)[source]
defaultLoader = <gavo.web.common.doctypedStan object>
footnotes(request, tag)[source]

renders the footnotes as a definition list.

name = 'info'
notebubble(request, tag)[source]
title(request, tag)[source]
class gavo.web.metarender.TableInfoRenderer(request, service)[source]

Bases: MetaRenderer

A renderer for displaying table information.

Since tables don’t necessarily have associated services, this renderer cannot use a service to sit on. Instead, the table is being passed in as as an argument. There’s a built-in vanity tableinfo that sits on //dc_tables#show using this renderer (it could really sit anywhere else).

customTemplate = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/tableinfo.html'>
data_fields(request, tag)[source]
data_forADQL(request, tag)[source]
data_internalpath(request, tag)[source]
data_tableDef(request, tag)[source]
defaultLoader = <gavo.web.common.doctypedStan object>
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}.

ifrdmeta(metaName)[source]
iftapinfo(request, tag)[source]

renders the content if there was a tapinfo key somewhere in the query string.

name = 'tableinfo'
rdmeta(request, tag)[source]
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}

title(request, tag)[source]
class gavo.web.metarender.TableNoteRenderer(request, service)[source]

Bases: MetaRenderer

A renderer for displaying table notes.

It takes a schema-qualified table name and a note tag in the segments.

This does not use the underlying service, so it could and will run on any service. However, you really should run it on __system__/dc_tables/show, and there’s a built-in vanity name tablenote for this.

data_noteTag(request, tag)[source]
data_tableName(request, tag)[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}.

innerLoader = <twisted.web._template_util.TagLoader object>
loader = <gavo.formal.nevowc.XMLString object>
name = 'tablenote'
noteHTML(request, tag)[source]
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}

gavo.web.metarender.makeBibTeXForMetaCarrier(mc)[source]

returns a (unicode) best-effort BibTeX record for something mixing in mc.

This needs, at least, a creationDate, a creator, a referenceURL, and a title to work; if these aren’t there, you’ll get a MetaError.