def RetriveSongsBySite(site_name): #if you dont pass anything in it gets all the sites if site_name == '': site = Site.all().fetch(150) else: site = Site.all().filter('name =', site_name).fetch(1) return site
def get(self): sites = Site.all() context = { 'sites': sites, } sites_for_output = {} # loop over the sites for site in sites: # and store each one in the output variable site_for_output = { "url": site.url, "issues": site.issue_set.count(), } sites_for_output[site.name] = site_for_output # create the JSON object we're going to return json = simplejson.dumps(sites_for_output, sort_keys=False) # serve the response with the correct content type #self.response.headers['Content-Type'] = 'application/json' # write the json to the response self.response.out.write(json)
def get(self): "Ping each site in turn and record the response" # get all the sites we're going to ping sites = Site.all() # loop over all of the current sites for site in sites: # ping each site ping_site(site) self.redirect("/")
def observation_update_all(): sites = Site.all().fetch(limit = 200) for site in sites: taskqueue.add(url = "/admin/sites/%s/observation/update" % site.key().id_or_name(), queue_name="update") taskqueue.add(url = "/admin/sites/%s/observation/update2" % site.key().id_or_name(), queue_name="update") if request.args.get("redirect"): flash("Started update observation tasks for all sites") return redirect(url_for('sites')) return Response(status = 204)
def post(self): site_name = self.request.get('site_name') #this is dodgy, I would rather do something like Site.get(name=site_name) but I can't get that #to work... p = Site.all().filter('name =', site_name).fetch(1) if users.get_current_user(): Song(site = p[0], title = self.request.get('title'), mp3_url = self.request.get('mp3_url'), likes = 0).put() self.redirect('/?' + urllib.urlencode({'site_name': p[0].name}))
def load_site_posts(start_date=None): sites = Site.all() for site in sites: last = Post.last(site.id) if last is not None: print "%s, %s, %s" % (str(site.id), str( last.site_id), str(last.post_id)) start_date = last.creation_date else: print "Using predefined start date" print "Start loading %s, since %s" % (str(site), str(start_date)) result = load_posts(site.id, site.api_name, start_date) if result is not None: print result
def get(self): # we are enforcing loggins so we know we have a user user = users.get_current_user() # we need the logout url for the frontend logout = users.create_logout_url("/") # get all the sites we're going to ping sites = Site.all() # add the logour url to our template context context = {"logout": logout, "sites": sites} # prepare the context for the template # calculate the template path path = os.path.join(os.path.dirname(__file__), "templates", "index.html") # render the template with the provided context self.response.out.write(template.render(path, context))
def get(self): query = self.request.get("q") if not query: sites = Site.all() else: sites = Site.gql("WHERE url=:1", "http://%s" % query) context = { 'sites': sites, 'query': query, } # prepare the context for the template # calculate the template path path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html') # render the template with the provided context self.response.out.write(template.render(path, context))
def get(self): "List all the sites in JSON" # get all the sites sites = Site.all() # repreare out dict sites_for_output = {} # loop over the sites for site in sites: # and store each one in the output variable site_for_output = {"url": site.url, "email": site.email} sites_for_output[site.name] = site_for_output # create the JSON object we're going to return json = simplejson.dumps(sites_for_output, sort_keys=False) # serve the response with the correct content type # self.response.headers['Content-Type'] = 'application/json' # write the json to the response self.response.out.write(json)
def post(self): """ site = Site( name = 'name', url = 'http://url.com', slug = 'slug', ) site.put() issue = Issue( title = 'title', description = 'description', site = site, ) issue.put() """ # get url and then decide if we have a site already or # need to create one name = self.request.get("name") url = self.request.get("url") try: site = Site.gql("WHERE url=:1", url)[0] except IndexError: """ import sys import pdb for attr in ('stdin', 'stdout', 'stderr'): setattr(sys, attr, getattr(sys, '__%s__' % attr)) pdb.set_trace() """ site = Site( name = name, url = url, slug = slugify(name), ) site.put() title = self.request.get("title") description = self.request.get("description") issue = Issue( title = title, description = description, site = site, ) issue.put() context = { 'issue': issue, 'sites': Site.all(), } # prepare the context for the template # calculate the template path path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html') # render the template with the provided context self.response.out.write(template.render(path, context))
def sites(): return render_template("sites.html", sites=Site.all().fetch(limit=200))
def sites(): return json_list_response(Site.all().fetch(limit = 200))
def add_example_sites(): for site in Site.all(): site.owner = site.admins[0] site.put()
''' Created on Feb 23, 2011 @author: jackdreilly ''' from models import Site qlsites = Site.all().fetch(100) def findSite(url,type): return [site for site in qlsites if site.name in url and site.type == type][0]
def sites(): return render_template("sites.html", sites = Site.all().fetch(limit = 200))