gavo.web.weberrors module

Default error displays for the data center and error helper code.

Everything in here must render synchronuosly.

You probably should not construct anything in this module directly but rather just raise the appropriate exceptions from svcs.

class gavo.web.weberrors.AuthenticatePage(error)[source]

Bases: ErrorPage

handles

alias of Authenticate

loader = <XMLFile of '/home/msdemlei/gavo/trunk/gavo/resources/templates/unauth.html'>
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}

status = 401
titleMessage = 'Authentication Required'
class gavo.web.weberrors.BadMethodPage(error)[source]

Bases: ErrorPage

afterMessage = Tag('p', children=['You may find whatever you were really looking for by inspecting our ', Tag('a', attributes={'href': '/'}, children=['list of published services']), '.'])
beforeMessage = 'You just tried to use some HTTP method to access this resource that this resource does not support.  This probably means that this resource is for exclusive use for specialized clients.'
handles

alias of BadMethod

status = 405
titleMessage = 'Bad Method'
class gavo.web.weberrors.ErrorDisplay(error)[source]

Bases: ErrorPage

afterMessage = [Tag('p', children=["Problems of this sort usually mean we considered the possibility of something like this happening; if the above doesn't give you sufficient hints to fix the problem, please complain to the address given below."]), Tag('p')]
beforeMessage = 'A piece of code failed:'
handles

alias of ReportableError

status = 500
titleMessage = 'Error'
class gavo.web.weberrors.ErrorPage(error)[source]

Bases: TemplatedPage, CommonRenderers

A base for error handling pages.

The idea is that you set the “handles” class attribute to the exception you handle. The exception has to match exactly, i.e., no isinstancing is done.

You also must set status to the HTTP status code the error should return.

All error pages have a failure attribute that’s a twisted failure with all the related mess (e.g., tracebacks).

You have the status and message data methods.

In custom exceptions, you can attach stan in htmlMessage, and ErrorPages will show that as the error message.

afterMessage = Tag('p', children=["This generic text shouldn't be here.  The child class should override afterMessage."])
aftermessage(request, tag)[source]
beforeMessage = "We're sorry, but something didn't work out:"
beforemessage(request, tag)[source]
data_status(request, tag)[source]
footer(request, tag)[source]
handles = None
hint(request, tag)[source]
loader = <gavo.web.common.doctypedStan object>
message(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}

status = 500
titleMessage = 'Unspecified Error'
titlemessage(request, tag)[source]
class gavo.web.weberrors.ForbiddenPage(error)[source]

Bases: ErrorPage

afterMessage = Tag('div', children=[Tag('p', children=['This usually means you tried to use a renderer on a service that does not support it.  If you did not come up with the URL in question yourself, complain fiercely to the staff of ', Tag('', children=['[web]sitename']), '.']), Tag('p')])
beforeMessage = "We're sorry, but the resource you requested is forbidden."
handles

alias of ForbiddenURI

status = 403
titleMessage = 'Forbidden'
class gavo.web.weberrors.FoundPage(error)[source]

Bases: RedirectBase

beforeMessage = ['The resource you requested can be found at ', Tag('a', children=[Tag('')]), '.']
handles

alias of Found

status = 302
titleMessage = 'Found'
class gavo.web.weberrors.InternalServerErrorPage(error)[source]

Bases: ErrorPage

A catch-all page served when no other error page seemed responsible.

afterMessage = Tag('p', children=['This is always a bug in our software, and we would really be grateful for a report to the contact address below, preferably with a description of what you were trying to do, including any data pieces if applicable.  Thanks.'])
beforeMessage = (Tag('p', children=['Your action has caused a(n) ', Tag('span', attributes={'nevow:data': 'excname'}), ' exception to occur.  As additional info, the failing code gave:']),)
data_excname(request, tag)[source]
handles

alias of Error

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}

renderInnerException(request)[source]

called when rendering already has started.

We don’t know where we’re sitting, so we try to break out as well as we can.

status = 500
titleMessage = 'Uncaught Exception'
class gavo.web.weberrors.NotAcceptable(error)[source]

Bases: ErrorPage

afterMessage = ''
beforeMessage = 'The server cannot generate the data you requested.  The associated message is:'
handles

alias of DataError

status = 406
titleMessage = 'Not Acceptable'
class gavo.web.weberrors.NotFoundPage(error)[source]

Bases: ErrorPage

afterMessage = [Tag('p', children=['If this message resulted from following a link from ', Tag('strong', children=['within the data center']), ', you have discovered a bug, and we would be extremely grateful if you could notify us.']), Tag('p', children=['If you got here following an ', Tag('strong', children=['external link']), ', we would be grateful for a notification as well.  We will ask the external operators to fix their links or provide redirects as appropriate.']), Tag('p', children=['In either case, you may find whatever you were looking for by inspecting our ', Tag('a', attributes={'href': '/'}, children=['list of published services']), '.']), Tag('p')]
beforeMessage = "We're sorry, but the resource you requested could not be located."
handles

alias of UnknownURI

status = 404
titleMessage = 'Not Found'
class gavo.web.weberrors.NotFoundPageWithFancyMessage(message)[source]

Bases: NotFoundPage

A NotFoundPage with a message that’s taken from a piece of stan.

handles = None
message(request, tag)[source]
class gavo.web.weberrors.NullPage(error)[source]

Bases: ErrorPage

handles

alias of _Silence

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.weberrors.OtherNotFoundPage(error)[source]

Bases: NotFoundPage

handles

alias of NotFoundError

class gavo.web.weberrors.RDNotFoundPage(error)[source]

Bases: NotFoundPage

handles

alias of RDNotFound

class gavo.web.weberrors.RedirectBase(error)[source]

Bases: ErrorPage

afterMessage = Tag('p', children=['You should not see this page -- either your browser or our site is broken.  Complain.'])
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.weberrors.RedirectPage(error)[source]

Bases: RedirectBase

beforeMessage = ['The resource you requested is available from a ', Tag('a', children=['different URL']), '.']
handles

alias of WebRedirect

status = 301
titleMessage = 'Moved Permanently'
class gavo.web.weberrors.SeeOtherPage(error)[source]

Bases: RedirectBase

beforeMessage = ['Please turn to a ', Tag('a', children=['different URL']), ' to go on.']
handles

alias of SeeOther

status = 303
titleMessage = 'See Other'
gavo.web.weberrors.Silence()[source]

returns a failure.Failure that cases this module to not touch request at all.

You want to return this from errbacks that already have spit out their error message.

class gavo.web.weberrors.UploadTooLargePage(error)[source]

Bases: ErrorPage

handles

alias of RequestEntityTooLarge

status = 413
titleMessage = 'Upload too big'
gavo.web.weberrors.getDCErrorPage(flr)[source]

returns a t.w resource for a twisted failure.

gavo.web.weberrors.renderDCErrorPage(flr, request)[source]

renders a resource a twisted failure.

This finishes request itself. It returns t.w.server.NOT_DONE_YET because of that, so you can write return renderDCErrorPage from a render method (or similar).