# Path: data_model.py
# class DeveloperKeys(db.Model):
#     dateAdded      = db.DateTimeProperty(auto_now_add=True)
#     developerName  = db.StringProperty()
#     developerKey   = db.StringProperty()
#     developerEmail = db.EmailProperty()
#     requestCounter = db.IntegerProperty()
#     errorCounter   = db.IntegerProperty()


import os
import wsgiref.handlers
import logging
import webapp2 as webapp
import json
import gdata.docs.service
import gdata.spreadsheet.service
import gdata.spreadsheet.text_db
import config
from operator import itemgetter
from datetime import datetime
from datetime import date
from datetime import timedelta
from google.appengine.api import channel
from google.appengine.api import mail
from google.appengine.api import memcache
from google.appengine.api import users
from google.appengine.api.labs.taskqueue import Task
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
from google.appengine.runtime import apiproxy_errors
from data_model import DeveloperKeys
    dateString = str(today.month)+ "/" + str(today.day) + "/" + str(today.year)
    logging.info('adding %s to %s for %s on %s' % (value,category,member,dateString))

    databases = client.GetDatabases(config.GOOGLE_DOC_KEY,
                                    config.GOOGLE_DOC_TITLE)
    if len(databases) != 1:
        logging.error("database query is broken!?! can't find the document")
    for db in databases:
        tables = db.GetTables(name=member)
        for t in tables:
            if t:
                records = t.FindRecords('date == %s' % dateString)
                for r in records:
                    if r:
                        if category not in r.content:
                            logging.error('could not find %s - 0' % category)
                        else:
                            r.content[category] = str(value)
                            r.Push()

                    else:
                        logging.error("unable to find the contents for this record!?!")
            else:
                logging.error("couldn't find the table!?!")
    return

## end

class CreateDeveloperKeysHandler(webapp.RequestHandler):
    def get(self):

# Path: data_model.py
# class DeveloperKeys(db.Model):
#     dateAdded      = db.DateTimeProperty(auto_now_add=True)
#     developerName  = db.StringProperty()
#     developerKey   = db.StringProperty()
#     developerEmail = db.EmailProperty()
#     requestCounter = db.IntegerProperty()
#     errorCounter   = db.IntegerProperty()


# Path: admin.py
import os
import wsgiref.handlers
import logging
import webapp2 as webapp
import json
import gdata.docs.service
import gdata.spreadsheet.service
import gdata.spreadsheet.text_db
import config
from operator import itemgetter
from datetime import datetime
from datetime import date
from datetime import timedelta
from google.appengine.api import channel
from google.appengine.api import mail
from google.appengine.api import memcache
from google.appengine.api import users
from google.appengine.api.labs.taskqueue import Task
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
from google.appengine.runtime import apiproxy_errors
from data_model import DeveloperKeys

    dateString = str(today.month)+ "/" + str(today.day) + "/" + str(today.year)
    logging.info('adding %s to %s for %s on %s' % (value,category,member,dateString))

    databases = client.GetDatabases(config.GOOGLE_DOC_KEY,
                                    config.GOOGLE_DOC_TITLE)
    if len(databases) != 1:
        logging.error("database query is broken!?! can't find the document")
    for db in databases:
        tables = db.GetTables(name=member)
        for t in tables:
            if t:
                records = t.FindRecords('date == %s' % dateString)
                for r in records:
                    if r:
                        if category not in r.content:
                            logging.error('could not find %s - 0' % category)
                        else:
                            r.content[category] = str(value)
                            r.Push()

                    else:
                        logging.error("unable to find the contents for this record!?!")
            else:
                logging.error("couldn't find the table!?!")
    return

## end

class CreateDeveloperKeysHandler(webapp.RequestHandler):
    def get(self):

      key = DeveloperKeys()