Logo Search packages:      
Sourcecode: zine version File versions  Download package

def zine::websetup::WebSetup::start_setup (   self,
  request 
)

This is called when all the form data is validated
and Zine is ready to install the data. In theory
this can also be called if no form validation is done and
someone faked the request. But because that's the fault of
the administrator we don't care about that.

Definition at line 141 of file __init__.py.

00141                                   :
        """
        This is called when all the form data is validated
        and Zine is ready to install the data. In theory
        this can also be called if no form validation is done and
        someone faked the request. But because that's the fault of
        the administrator we don't care about that.
        """
        value = request.values.get
        error = None
        database_uri = value('database_uri', '').strip()

        try:
            from zine.database import init_database

            # create database and all tables
            e = db.create_engine(database_uri, self.instance_folder)
            init_database(e)
        except Exception, error:
            error = str(error).decode('utf-8', 'ignore')
        else:
            from zine.database import users, user_privileges, privileges
            from zine.privileges import BLOG_ADMIN

            # create admin account
            user_id = e.execute(users.insert(),
                username=value('admin_username'),
                pw_hash=gen_pwhash(value('admin_password')),
                email=value('admin_email'),
                real_name=u'',
                description=u'',
                extra={},
                display_name='$username',
                is_author=True
            ).last_inserted_ids()[0]

            # insert a privilege for the user
            privilege_id = e.execute(privileges.insert(),
                name=BLOG_ADMIN.name
            ).last_inserted_ids()[0]
            e.execute(user_privileges.insert(),
                user_id=user_id,
                privilege_id=privilege_id
            )

            # set up the initial config
            config_filename = path.join(self.instance_folder, 'zine.ini')
            cfg = Configuration(config_filename)
            t = cfg.edit()
            t.update(
                maintenance_mode=environment.MODE != 'development',
                blog_url=request.url_root,
                secret_key=gen_secret_key(),
                database_uri=database_uri,
                language=request.translations.language,
                iid=new_iid(),
                # load one plugin by default for a better theme
                plugins='vessel_theme',
                theme='vessel'
            )
            cfg._comments['[zine]'] = CONFIG_HEADER
            try:
                t.commit()
            except ConfigurationTransactionError:
                _ = request.translations.gettext
                error = _('The configuration file (%s) could not be opened '
                          'for writing. Please adjust your permissions and '
                          'try again.') % config_filename

        # use a local variable, the global render_response could
        # be None because we reloaded zine and this module.
        return render_response(request, error and 'error.html' or 'finished.html', {
            'finished': True,
            'error':    error
        })

    def __call__(self, environ, start_response):


Generated by  Doxygen 1.6.0   Back to index