Beispiel #1
0
    def POST(self):
        if not can_write():
            raise Forbidden('Permission Denied.')

        try:
            query = json.loads(web.data())
            h = api.get_custom_headers()
            comment = h.get('comment')
            action = h.get('action')
        except Exception as e:
            raise BadRequest(str(e))

        self.verify_types(query)
        keys = self.prepare_query(query)

        try:
            if not isinstance(query, list):
                query = [query]
            web.ctx.site.save_many(query, comment=comment, action=action)
        except client.ClientException as e:
            raise BadRequest(str(e))

        # graphite/statsd tracking of bot edits
        user = delegate.context.user and delegate.context.user.key
        if user.lower().endswith('bot'):
            botname = user.replace('/people/', '', 1)
            botname = botname.replace('.', '-')
            key = 'ol.edits.bots.'+botname
            openlibrary.core.stats.increment(key)
        return json.dumps(keys)
Beispiel #2
0
    def POST(self):
        if not can_write():
            raise Forbidden("Permission Denied.")

        try:
            query = simplejson.loads(web.data())
            h = api.get_custom_headers()
            comment = h.get('comment')
            action = h.get('action')
        except Exception as e:
            raise BadRequest(str(e))

        self.verify_types(query)
        keys = self.prepare_query(query)

        try:
            if not isinstance(query, list):
                query = [query]
            web.ctx.site.save_many(query, comment=comment, action=action)
        except client.ClientException as e:
            raise BadRequest(str(e))

        #graphite/statsd tracking of bot edits
        user = delegate.context.user and delegate.context.user.key
        if user.lower().endswith('bot'):
            botname = user.replace('/people/', '', 1)
            botname = botname.replace('.', '-')
            key = 'ol.edits.bots.'+botname
            openlibrary.core.stats.increment(key)

        return simplejson.dumps(keys)
Beispiel #3
0
 def POST(self):
     if not can_write():
         raise Forbidden("Permission Denied.")
         
     try:
         query = simplejson.loads(web.data())
         h = api.get_custom_headers()
         comment = h.get('comment')
         action = h.get('action')
     except Exception, e:
         raise BadRequest(str(e))
Beispiel #4
0
    def POST(self):
        if not can_write():
            raise Forbidden("Permission Denied.")

        try:
            query = simplejson.loads(web.data())
            h = api.get_custom_headers()
            comment = h.get('comment')
            action = h.get('action')
        except Exception, e:
            raise BadRequest(str(e))