コード例 #1
0
ファイル: __init__.py プロジェクト: adityaathalye/zine
    def 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.
        """
        value = request.values.get
        error = None
        database_uri = value('database_uri', '').strip()
        
        # 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
            return render_response(request, 'error.html', {
            'finished': False,
            'error':    error
            })

        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')
コード例 #2
0
    def 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.
        """
        value = request.values.get
        error = None
        database_uri = value('database_uri', '').strip()

        # 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
            return render_response(request, 'error.html', {
                'finished': False,
                'error': error
            })

        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')
コード例 #3
0
ファイル: __init__.py プロジェクト: jace/zine-main
    def 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.
        """
        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')
コード例 #4
0
def new_instance(database_uri, instance_folder, blog_url):
    e = db.create_engine(database_uri, 
                         instance_folder)
    init_database(e)

    config_filename = os.path.join(instance_folder, 
                                   'zine.ini')
    cfg = Configuration(config_filename)
    t = cfg.edit()
    t.update(
        maintenance_mode=False,
        blog_url=blog_url,
        secret_key=gen_secret_key(),
        database_uri=database_uri,
        language='en',
        iid=new_iid(),
        plugins='vessel_theme',
        theme='vessel'
        )
    #cfg._comments['[zine]'] = CONFIG_HEADER
    try:
        t.commit()
    except ConfigurationTransactionError:
        raise