Esempio n. 1
0
    def start_setup(self, request):
        """
        This is called when all the form data is validated
        and Rezine 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()

        rezine_app = create_instance(instance_folder=self.instance_folder,
                                     database_uri=database_uri,
                                     admin_username=value('admin_username'),
                                     admin_password=value('admin_password'),
                                     admin_email=value('admin_email'))

        from rezine._core import setup_rezine
        rezine_app = setup_rezine(self.instance_folder)

        t = rezine_app.cfg.edit()
        t.update(
            maintenance_mode=environment.MODE != 'development',
            blog_url=request.url_root,
            language=request.translations.language,
        )
        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.') % rezine_app.cfg.filename
            return render_response(request, 'error.html', {
            'finished': False,
            'error':    error
            })

        # use a local variable, the global render_response could
        # be None because we reloaded rezine and this module.
        return render_response(request, error and 'error.html' \
                                   or 'finished.html', {
            'finished': True,
            'error':    error
        })
Esempio n. 2
0
 def get_rezine_instance(self):
     if not self.instance_path:
         self.parser.error('you need to pass your Rezine instance path.')
     if not hasattr(self, 'rezine_instance'):
         self.rezine_instance = setup_rezine(expanduser(self.instance_path))
     return self.rezine_instance
Esempio n. 3
0
 def get_rezine_instance(self):
     if not self.instance_path:
         self.parser.error('you need to pass your Rezine instance path.')
     if not hasattr(self, 'rezine_instance'):
         self.rezine_instance = setup_rezine(expanduser(self.instance_path))
     return self.rezine_instance