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:
gavo.web.weberrors.ErrorPage
-
handles
¶ alias of
gavo.svcs.common.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:
gavo.web.weberrors.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
gavo.svcs.common.BadMethod
-
status
= 405¶
-
titleMessage
= 'Bad Method'¶
-
-
class
gavo.web.weberrors.
ErrorDisplay
(error)[source]¶ Bases:
gavo.web.weberrors.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
gavo.utils.excs.ReportableError
-
status
= 500¶
-
titleMessage
= 'Error'¶
-
-
class
gavo.web.weberrors.
ErrorPage
(error)[source]¶ Bases:
gavo.formal.nevowc.TemplatedPage
,gavo.web.common.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."])¶
-
beforeMessage
= "We're sorry, but something didn't work out:"¶
-
handles
= None¶
-
loader
= <gavo.web.common.doctypedStan object>¶
-
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'¶
-
-
class
gavo.web.weberrors.
ForbiddenPage
(error)[source]¶ Bases:
gavo.web.weberrors.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
gavo.svcs.common.ForbiddenURI
-
status
= 403¶
-
titleMessage
= 'Forbidden'¶
-
-
class
gavo.web.weberrors.
FoundPage
(error)[source]¶ Bases:
gavo.web.weberrors.RedirectBase
-
beforeMessage
= ['The resource you requested can be found at ', Tag('a', children=[Tag('')]), '.']¶
-
handles
¶ alias of
gavo.svcs.common.Found
-
status
= 302¶
-
titleMessage
= 'Found'¶
-
-
class
gavo.web.weberrors.
InternalServerErrorPage
(error)[source]¶ Bases:
gavo.web.weberrors.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:']),)¶
-
handles
¶ alias of
gavo.utils.excs.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:
gavo.web.weberrors.ErrorPage
-
afterMessage
= ''¶
-
beforeMessage
= 'The server cannot generate the data you requested. The associated message is:'¶
-
handles
¶ alias of
gavo.utils.excs.DataError
-
status
= 406¶
-
titleMessage
= 'Not Acceptable'¶
-
-
class
gavo.web.weberrors.
NotFoundPage
(error)[source]¶ Bases:
gavo.web.weberrors.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
gavo.svcs.common.UnknownURI
-
status
= 404¶
-
titleMessage
= 'Not Found'¶
-
-
class
gavo.web.weberrors.
NotFoundPageWithFancyMessage
(message)[source]¶ Bases:
gavo.web.weberrors.NotFoundPage
A NotFoundPage with a message that’s taken from a piece of stan.
-
handles
= None¶
-
-
class
gavo.web.weberrors.
NullPage
(error)[source]¶ Bases:
gavo.web.weberrors.ErrorPage
-
handles
¶ alias of
gavo.web.weberrors._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:
gavo.web.weberrors.NotFoundPage
-
handles
¶ alias of
gavo.utils.excs.NotFoundError
-
-
class
gavo.web.weberrors.
RDNotFoundPage
(error)[source]¶ Bases:
gavo.web.weberrors.NotFoundPage
-
handles
¶ alias of
gavo.utils.excs.RDNotFound
-
-
class
gavo.web.weberrors.
RedirectBase
(error)[source]¶ Bases:
gavo.web.weberrors.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:
gavo.web.weberrors.RedirectBase
-
beforeMessage
= ['The resource you requested is available from a ', Tag('a', children=['different URL']), '.']¶
-
handles
¶ alias of
gavo.svcs.common.WebRedirect
-
status
= 301¶
-
titleMessage
= 'Moved Permanently'¶
-
-
class
gavo.web.weberrors.
SeeOtherPage
(error)[source]¶ Bases:
gavo.web.weberrors.RedirectBase
-
beforeMessage
= ['Please turn to a ', Tag('a', children=['different URL']), ' to go on.']¶
-
handles
¶ alias of
gavo.svcs.common.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.