web/webctl.py
author Adrien Chauve <adrien.chauve@logilab.fr>
Tue, 06 Apr 2010 16:50:53 +0200
changeset 5155 1dea6e0fdfc1
parent 4252 6c4f109c2b03
child 5415 6bb0c3a53589
permissions -rw-r--r--
Switched from TwistedWeb2 to TwistedWeb - added HTTPResponse class in etwist/http.py (could be then abstracted in cubicweb/web) - added twisted.web2 http_headers.py file in cubicweb/web to handle HTTP headers conversion between raw headers and python object - deleted caching for base views (except for startup views). A better solution would be using weak entity tags (but they don't seem to be implemented in twisted.web). - added forbidden access message when browsing static local directories - tested with TwistedWeb 8, 9 and 10 TODO: ===== - Handle file uploading in forms. twisted.web seems to keep very little information (only file content) about uploaded files in twisted_request.args['input_field_name']. But it doesn't seem to keep track of filenames. Possible solutions : - use web2 code to parse raw request content still stored and available in twisted_request.content - find a magic function in twisted.web API to get the filenames - More tests.

"""cubicweb-ctl commands and command handlers common to twisted/modpython
web configuration

:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
__docformat__ = "restructuredtext en"

from cubicweb.toolsutils import CommandHandler, underline_title
from logilab.common.shellutils import ASK

class WebCreateHandler(CommandHandler):
    cmdname = 'create'

    def bootstrap(self, cubes, inputlevel=0):
        """bootstrap this configuration"""
        print '\n' + underline_title('Generic web configuration')
        config = self.config
        if config.repo_method == 'pyro':
            print '\n' + underline_title('Pyro configuration')
            config.input_config('pyro', inputlevel)
        if ASK.confirm('Allow anonymous access ?', False):
            config.global_set_option('anonymous-user', 'anon')
            config.global_set_option('anonymous-password', 'anon')

    def postcreate(self):
        """hooks called once instance's initialization has been completed"""