# HG changeset patch # User Aurelien Campeas # Date 1271345307 -7200 # Node ID 15846058378b2bcd31d86368d8cd43ed360e0bb9 # Parent 540fa73caac6e74b54e7eb273fff585fd929439b [doc/book] fix a bit the request chapter, add autodoc diff -r 540fa73caac6 -r 15846058378b doc/book/en/development/devweb/request.rst --- a/doc/book/en/development/devweb/request.rst Thu Apr 15 17:22:19 2010 +0200 +++ b/doc/book/en/development/devweb/request.rst Thu Apr 15 17:28:27 2010 +0200 @@ -1,5 +1,8 @@ The `Request` class (`cubicweb.web`) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------ + +Overview +```````` A request instance is created when an HTTP request is sent to the web server. It contains informations such as form parameters, user authenticated, etc. @@ -16,15 +19,16 @@ But also: -:Session data handling: +* `Session data handling` + * `session_data()`, returns a dictionary containing all the session data * `get_session_data(key, default=None)`, returns a value associated to the given key or the value `default` if the key is not defined * `set_session_data(key, value)`, assign a value to a key * `del_session_data(key)`, suppress the value associated to a key +* `Cookies handling` -:Cookies handling: * `get_cookie()`, returns a dictionary containing the value of the header HTTP 'Cookie' * `set_cookie(cookie, key, maxage=300)`, adds a header HTTP `Set-Cookie`, @@ -33,12 +37,14 @@ window) * `remove_cookie(cookie, key)`, forces a value to expire -:URL handling: +* `URL handling` + * `url()`, returns the full URL of the HTTP request * `base_url()`, returns the root URL of the web application * `relative_path()`, returns the relative path of the request -:And more...: +* `And more...` + * `set_content_type(content_type, filename=None)`, adds the header HTTP 'Content-Type' * `get_header(header)`, returns the value associated to an arbitrary header @@ -56,6 +62,18 @@ most of the interface of `Request` is defined in the session associated to the client. +Automatic API +````````````` -XXX autoclass ! -XXX create_entity +The elements we gave in overview for above are built in three layers, +from ``cubicweb.req.RequestSessionBase``, ``cubicweb.dbapi.DBAPIRequest`` and +``cubicweb.web.CubicWebRequestBase``. + +.. autoclass:: cubicweb.req.RequestSessionBase + :members: + +.. autoclass:: cubicweb.dbapi.DBAPIRequest + :members: + +.. autoclass:: cubicweb.web.request.CubicWebRequestBase + :members: diff -r 540fa73caac6 -r 15846058378b doc/book/en/development/devweb/views/basetemplates.rst --- a/doc/book/en/development/devweb/views/basetemplates.rst Thu Apr 15 17:22:19 2010 +0200 +++ b/doc/book/en/development/devweb/views/basetemplates.rst Thu Apr 15 17:28:27 2010 +0200 @@ -108,4 +108,6 @@ * `login` and `logout` -* `error-template` +* `error-template` specializes TheMainTemplate to do proper end-user + output if an error occurs during the computation of TheMainTemplate + (it is a fallback view). diff -r 540fa73caac6 -r 15846058378b req.py --- a/req.py Thu Apr 15 17:22:19 2010 +0200 +++ b/req.py Thu Apr 15 17:28:27 2010 +0200 @@ -43,12 +43,10 @@ request/session is the main resources accessor, mainly through it's vreg attribute: - :vreg: - the instance's registry - :vreg.schema: - the instance's schema - :vreg.config: - the instance's configuration + + :attribute vreg: the instance's registry + :attribute vreg.schema: the instance's schema + :attribute vreg.config: the instance's configuration """ def __init__(self, vreg): self.vreg = vreg @@ -140,8 +138,8 @@ raise Unauthorized(self._('only select queries are authorized')) def get_cache(self, cachename): - """ - NOTE: cachename should be dotted names as in : + """cachename should be dotted names as in : + - cubicweb.mycache - cubes.blog.mycache - etc. diff -r 540fa73caac6 -r 15846058378b web/request.py --- a/web/request.py Thu Apr 15 17:22:19 2010 +0200 +++ b/web/request.py Thu Apr 15 17:28:27 2010 +0200 @@ -523,6 +523,7 @@ def add_css(self, cssfiles, media=u'all', localfile=True, ieonly=False, iespec=u'[if lt IE 8]'): """specify a CSS file to include in the HTML headers + :param cssfiles: a CSS filename or a list of CSS filenames :param media: the CSS's media if necessary :param localfile: if True, the default data dir prefix is added to the @@ -550,15 +551,17 @@ def build_ajax_replace_url(self, nodeid, rql, vid, replacemode='replace', **extraparams): - """builds an ajax url that will replace `nodeid`s content + """builds an ajax url that will replace nodeid's content + :param nodeid: the dom id of the node to replace :param rql: rql to execute :param vid: the view to apply on the resultset :param replacemode: defines how the replacement should be done. + Possible values are : - - 'replace' to replace the node's content with the generated HTML - - 'swap' to replace the node itself with the generated HTML - - 'append' to append the generated HTML to the node's content + - 'replace' to replace the node's content with the generated HTML + - 'swap' to replace the node itself with the generated HTML + - 'append' to append the generated HTML to the node's content """ url = self.build_url('view', rql=rql, vid=vid, __notemplate=1, **extraparams)