Esempio n. 1
0
 def delete(cls, rhandler, guid, **kw):
     helper = RequestHelper(rhandler)
     try:
         ArtifactAccessor.delete(guid)
         helper.set_status(204)
     except NotFoundException, ex:
         helper.error(404)
Esempio n. 2
0
    def put(self, source_name):
        helper = RequestHelper(self)
        
        source_name = urllib.unquote(source_name)
        success, values = read_json_fields(helper, "url", "active", logger=logging)
        if not success:
            return
        url, active = values
        
        # a Feed must be sole owner of an ArtifactSource;
        # fails if source already exists and is already linked to a feed
        source = ArtifactSourceAccessor.get_by_name(source_name, return_none=True)
        if source:
            source_feed_key = Feed.get_by_source(source, keys_only=True, return_none=True)
            if source_feed_key:
                msg = "source '%s' is referenced by feed %s" % (source_name, source_feed_key.name())
                helper.error(409, msg)
        else:
            source = ArtifactSourceAccessor.create(source_name)
        
        # creates UrlResource if necessary
        resource = UrlResourceAccessor.get_by_url(url, return_none=True)
        if not resource:
            resource = UrlResourceAccessor.create(url)

        # create or update Feed
        feed = Feed.get_by_source_name(source_name, return_none=True)
        if feed:
            feed.artifact_source = source
            feed.url_resource = resource
            feed.put()
        else:
            Feed.create(source_name, artifact_source=source, url=url, url_resource=resource, active=bool(active))
        helper.set_status(204)
Esempio n. 3
0
 def delete(self, name, **kw):
     helper = RequestHelper(self)
     try:
         ArtifactSourceAccessor.delete_by_name(name)
         helper.set_status(204)
     except NotFoundException, ex:
         helper.error(404)
         return
Esempio n. 4
0
 def put(self, name, **kw):
     helper = RequestHelper(self)
     source = ArtifactSourceAccessor.get_by_name(name, return_none=True)
     if source:
         helper.set_status(409, "duplicate ArtifactSouce")
         return
     ArtifactSourceAccessor.create(name)
     helper.set_status(204)
Esempio n. 5
0
 def put(self, name, **kw):
     helper = RequestHelper(self)
     source = ArtifactSourceAccessor.get_by_name(name, return_none=True)
     if source:
         helper.set_status(409, "duplicate ArtifactSouce")
         return
     ArtifactSourceAccessor.create(name)
     helper.set_status(204)
Esempio n. 6
0
 def delete(self, name, **kw):
     helper = RequestHelper(self)
     try:
         ArtifactSourceAccessor.delete_by_name(name)
         helper.set_status(204)
     except NotFoundException, ex:
         helper.error(404)
         return
Esempio n. 7
0
 def delete(self, source_name):
     helper = RequestHelper(self)
     source_name = urllib.unquote(source_name)
     feed = Feed.get_by_source_name(source_name, return_none=True)
     if not feed:
         helper.error(404)
         return
     feed.delete()
     helper.set_status(204)
Esempio n. 8
0
 def delete(self):
     helper = RequestHelper(self)
     search_results = self.__search(helper)
     if search_results:
         keys = [u.key() for u in search_results]
         db.delete(keys)
         helper.write_json([k.name() for k in keys])
     else:
         helper.set_status(204)
Esempio n. 9
0
 def delete(self):
     helper = RequestHelper(self)
     memcache.flush_all()
     helper.set_status(204)
Esempio n. 10
0
 def args_call(*args, **kw):
     handler = args[0]
     helper = RequestHelper(handler)
     helper.set_status(403)
Esempio n. 11
0
 def delete(self, key):
     helper = RequestHelper(self)
     ConfigurationAccessor.update(**{key: None})
     helper.set_status(204)
Esempio n. 12
0
 def delete(self, username):
     """ unfollows the specified user """
     helper = RequestHelper(self)
     t_api = TwitterConnector.new_api()
     t_api.DestroyFriendship(username)
     helper.set_status(204)
Esempio n. 13
0
 def put(self, username):
     """ follows the specified user """
     helper = RequestHelper(self)
     t_api = TwitterConnector.new_api()
     t_api.CreateFriendship(username)
     helper.set_status(204)
Esempio n. 14
0
 def delete(self, key):
     helper = RequestHelper(self)
     ConfigurationAccessor.update(**{key: None})
     helper.set_status(204)