コード例 #1
0
ファイル: server.py プロジェクト: pocoweb/poco
logging.basicConfig(format="%(asctime)s|%(levelname)s|%(name)s|%(message)s",
                    level=logging.WARNING,
                    datefmt="%Y-%m-%d %I:%M:%S")


def getConnection():
    if(settings.replica_set):
        return pymongo.MongoReplicaSetClient(settings.mongodb_host, replicaSet=settings.replica_set)
    else:
        return pymongo.Connection(settings.mongodb_host)


mongo_client = MongoClient(getConnection())

mongo_client.reloadApiKey2SiteID()

# jquery serialize()  http://api.jquery.com/serialize/
# http://stackoverflow.com/questions/5784400/un-jquery-param-in-server-side-python-gae
# http://www.tsangpo.net/2010/04/24/unserialize-param-in-python.html

# TODO: referer;
# TODO: when to reload site ids.


class LogWriter:
    def __init__(self):
        self.local_file = open(settings.local_raw_log_file, "a")

    def closeLocalLog(self):
        self.local_file.close()
コード例 #2
0
logging.basicConfig(format="%(asctime)s|%(levelname)s|%(name)s|%(message)s",
                    level=logging.WARNING,
                    datefmt="%Y-%m-%d %I:%M:%S")


def getConnection():
    if (settings.replica_set):
        return pymongo.MongoReplicaSetClient(settings.mongodb_host,
                                             replicaSet=settings.replica_set)
    else:
        return pymongo.Connection(settings.mongodb_host)


mongo_client = MongoClient(getConnection())

mongo_client.reloadApiKey2SiteID()

# jquery serialize()  http://api.jquery.com/serialize/
# http://stackoverflow.com/questions/5784400/un-jquery-param-in-server-side-python-gae
# http://www.tsangpo.net/2010/04/24/unserialize-param-in-python.html

# TODO: referer;
# TODO: when to reload site ids.


class LogWriter:
    def __init__(self):
        self.local_file = open(settings.local_raw_log_file, "a")

    def closeLocalLog(self):
        self.local_file.close()