| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python2.5 | 1 #!/usr/bin/python2.5 |
| 2 # Copyright (c) 2008 MalFind | 2 # Copyright (c) 2008 MalFind |
| 3 | 3 |
| 4 __author__ = "mavrommatis@gmail.com (Panayiotis Mavrommatis)" | 4 __author__ = "mavrommatis@gmail.com (Panayiotis Mavrommatis)" |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import logging | 7 import logging |
| 8 import cgi | |
|
provos
2008/05/16 17:24:51
this is no alpha ordered.
Panayiotis
2008/05/16 17:33:57
On 2008/05/16 17:24:51, provos wrote:
> this is no
| |
| 8 | 9 |
| 9 import handler_lib | 10 import handler_lib |
| 11 import model | |
|
provos
2008/05/16 17:24:51
there is a comment missing here about what model p
| |
| 10 | 12 |
| 11 from google.appengine.ext import db | 13 from google.appengine.ext import db |
| 12 from google.appengine.ext import webapp | 14 from google.appengine.ext import webapp |
| 13 from google.appengine.ext.webapp import template | 15 from google.appengine.ext.webapp import template |
| 14 | 16 |
| 15 class Stats(webapp.RequestHandler): | 17 class Stats(webapp.RequestHandler): |
| 16 '''Handles a /stats request.''' | 18 '''Handles a /stats request.''' |
| 17 def get(self): | 19 def get(self): |
| 18 queries = db.GqlQuery( | 20 queries = db.GqlQuery( |
| 19 'SELECT * FROM Query ORDER BY when DESC LIMIT 10').fetch(10) | 21 'SELECT * FROM Query ORDER BY when DESC LIMIT 10').fetch(10) |
| 20 digests = db.GqlQuery( | 22 digests = db.GqlQuery( |
| 21 'SELECT * FROM Digest LIMIT 10').fetch(10) | 23 'SELECT * FROM Digest LIMIT 10').fetch(10) |
| 22 values = { | 24 values = { |
| 23 'queries': queries, 'digests': digests, | 25 'queries': queries, 'digests': digests, |
| 24 'userdata': handler_lib.GetUserData() | 26 'userdata': handler_lib.GetUserData() |
| 25 } | 27 } |
| 26 path = os.path.join(os.path.dirname(__file__), 'html/stats.html') | 28 path = os.path.join(os.path.dirname(__file__), 'html/stats.html') |
| 27 self.response.out.write(template.render(path, values)) | 29 self.response.out.write(template.render(path, values)) |
| 30 | |
| 31 | |
| 32 def post(self): | |
|
provos
2008/05/16 17:24:51
how about you provide comments for your methods? h
Panayiotis
2008/05/16 17:33:57
On 2008/05/16 17:24:51, provos wrote:
> how about
| |
| 33 hash = self.request.get("digest") | |
| 34 if model.models.Digest.gql("WHERE hash = :1", hash).get() is None: | |
|
provos
2008/05/16 17:24:51
this looks like SQL, but SQL does not have a = spa
| |
| 35 digest = model.models.Digest(hash=hash) | |
| 36 digest.put() | |
| 37 | |
| 38 logging.info("Added digest %s" % hash) | |
|
provos
2008/05/16 17:24:51
i have seen this kind of code somewhere else befor
| |
| 39 self.response.out.write('<html><body>Added:<pre>') | |
| 40 self.response.out.write(cgi.escape(hash)) | |
| 41 self.response.out.write('</pre></body></html>') | |
| OLD | NEW |