web/webctl.py
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 10 Nov 2009 18:11:24 +0100
branchstable
changeset 3816 37b376bb4088
parent 3539 f3b14d052798
child 3589 a5432f99f2d9
child 4212 ab6573088b4a
permissions -rw-r--r--
[web] set pageid at request instanciation rather than in htmlheader template In some occasions, we need to force a pageid: typically an ajax-rendererd creation form would need to use the pageid of the main page to correclty set it's page_data (e.g. rql varmker). If pageid is found in req.form, it's used, otherwise we build a new one with. make_uid(). The behaviour should be consistent with the former one in JSonController.

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

:organization: Logilab
:copyright: 2001-2009 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 import underline_title
from cubicweb.toolsutils import CommandHandler
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"""