예제 #1
0
 def process_result_value(self, value, dialect):
     from rezine.utils.zeml import load_parser_data
     try:
         return load_parser_data(value)
     except ValueError: # Parser data invalid. Database corruption?
         from rezine.i18n import _
         from rezine.utils import log
         log.exception(_(u'Error when loading parsed data from database. '
                         u'Maybe the database was manually edited and got '
                         u'corrupted? The system returned an empty value.'))
         return {}
예제 #2
0
 def process_result_value(self, value, dialect):
     from rezine.utils.zeml import load_parser_data
     try:
         return load_parser_data(value)
     except ValueError:  # Parser data invalid. Database corruption?
         from rezine.i18n import _
         from rezine.utils import log
         log.exception(
             _(u'Error when loading parsed data from database. '
               u'Maybe the database was manually edited and got '
               u'corrupted? The system returned an empty value.'))
         return {}
예제 #3
0
파일: feed.py 프로젝트: rockyburt/Rezine
    def configure(self, request):
        form = FeedImportForm()

        if request.method == 'POST' and form.validate(request.form):
            feed = request.files.get('feed')
            if form.data['download_url']:
                try:
                    feed = open_url(form.data['download_url']).stream
                except Exception, e:
                    log.exception(_('Error downloading feed'))
                    flash(_(u'Error downloading from URL: %s') % e, 'error')
            if not feed:
                return redirect_to('import/feed')

            try:
                blog = parse_feed(feed)
            except Exception, e:
                log.exception(_(u'Error parsing uploaded file'))
                flash(_(u'Error parsing feed: %s') % e, 'error')
예제 #4
0
    def configure(self, request):
        form = WordPressImportForm()

        if request.method == "POST" and form.validate(request.form):
            dump = request.files.get("dump")
            if form.data["download_url"]:
                try:
                    dump = open_url(form.data["download_url"]).stream
                except Exception, e:
                    log.exception(_("Error downloading feed"))
                    flash(_(u"Error downloading from URL: %s") % e, "error")
            if not dump:
                return redirect_to("import/wordpress")

            try:
                blog = parse_feed(dump)
            except Exception, e:
                raise
                log.exception(_(u"Error parsing uploaded file"))
                flash(_(u"Error parsing uploaded file: %s") % e, "error")
예제 #5
0
    def configure(self, request):
        form = WordPressImportForm()

        if request.method == 'POST' and form.validate(request.form):
            dump = request.files.get('dump')
            if form.data['download_url']:
                try:
                    dump = open_url(form.data['download_url']).stream
                except Exception, e:
                    log.exception(_('Error downloading feed'))
                    flash(_(u'Error downloading from URL: %s') % e, 'error')
            if not dump:
                return redirect_to('import/wordpress')

            try:
                blog = parse_feed(dump)
            except Exception, e:
                raise
                log.exception(_(u'Error parsing uploaded file'))
                flash(_(u'Error parsing uploaded file: %s') % e, 'error')
예제 #6
0
def make_setup_error(exc_info=None):
    """Create a new SetupError for the last exception and log it."""
    if exc_info is None:
        exc_info = sys.exc_info()

    # log the exception
    log.exception(_(u'Plugin setup error'), 'pluginsystem', exc_info)
    exc_type, exc_value, tb = exc_info

    # if the exception is already a SetupError we only
    # have to return it unchanged.
    if isinstance(exc_value, SetupError):
        return exc_value

    # otherwise create an error message for it and return a new
    # exception.
    error, (filename, line) = summarize_exception(exc_info)
    return SetupError(_(u'Exception happend on setup: '
                        u'%(error)s (%(file)s, line %(line)d)') % {
        'error':    escape(error),
        'file':     filename,
        'line':     line
    })
예제 #7
0
def make_setup_error(exc_info=None):
    """Create a new SetupError for the last exception and log it."""
    if exc_info is None:
        exc_info = sys.exc_info()

    # log the exception
    log.exception(_(u'Plugin setup error'), 'pluginsystem', exc_info)
    exc_type, exc_value, tb = exc_info

    # if the exception is already a SetupError we only
    # have to return it unchanged.
    if isinstance(exc_value, SetupError):
        return exc_value

    # otherwise create an error message for it and return a new
    # exception.
    error, (filename, line) = summarize_exception(exc_info)
    return SetupError(
        _(u'Exception happend on setup: '
          u'%(error)s (%(file)s, line %(line)d)') % {
              'error': escape(error),
              'file': filename,
              'line': line
          })
예제 #8
0
파일: xml.py 프로젝트: rockyburt/Rezine
        using the _dispatch method and the result is returned as
        marshalled data.
        """
        try:
            params, method = xmlrpclib.loads(data)
            response = xmlrpclib.dumps(
                (self._wrap_obj(self._dispatch(method, params)),),
                methodresponse=True,
                allow_none=True,
                encoding=self.charset,
            )
        except xmlrpclib.Fault, fault:
            response = xmlrpclib.dumps(fault, allow_none=self.allow_none, encoding=self.charset)
        except:
            exc_type, exc_value, tb = exc_info = sys.exc_info()
            log.exception("Exception in XMLRPC request:", "xmlrpc", exc_info)
            response = xmlrpclib.dumps(
                xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)), encoding=self.charset, allow_none=self.allow_none
            )

        return response

    def handle_request(self, request):
        if request.method == "POST":
            response = self._marshaled_dispatch(request.data)
            return BaseResponse(response, mimetype="application/xml")
        return BaseResponse(
            "\n".join(
                (
                    '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
                    "<title>XMLRPC Interface</title>",
예제 #9
0
파일: xml.py 프로젝트: rockyburt/Rezine
        XML-RPC methods are dispatched from the marshalled (XML) data
        using the _dispatch method and the result is returned as
        marshalled data.
        """
        try:
            params, method = xmlrpclib.loads(data)
            response = xmlrpclib.dumps((self._wrap_obj(self._dispatch(method, params)),),
                                       methodresponse=True, allow_none=True,
                                       encoding=self.charset)
        except xmlrpclib.Fault, fault:
            response = xmlrpclib.dumps(fault, allow_none=self.allow_none,
                                       encoding=self.charset)
        except:
            exc_type, exc_value, tb = exc_info = sys.exc_info()
            log.exception('Exception in XMLRPC request:', 'xmlrpc', exc_info)
            response = xmlrpclib.dumps(
                xmlrpclib.Fault(1, '%s:%s' % (exc_type, exc_value)),
                encoding=self.charset, allow_none=self.allow_none
            )

        return response

    def handle_request(self, request):
        if request.method == 'POST':
            response = self._marshaled_dispatch(request.data)
            return BaseResponse(response, mimetype='application/xml')
        return BaseResponse('\n'.join((
            '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
            '<title>XMLRPC Interface</title>',
            '<h1>XMLRPC Interface</h1>',