Beispiel #1
0
def start_server(app):
    host = '0.0.0.0'
    port = int(os.environ[Const().ENV_LIGHT_APP_PORT])
    server = gevent.pywsgi.WSGIServer(
        (host, port),
        app,
        handler_class=geventwebsocket.handler.WebSocketHandler)
    server.serve_forever()
Beispiel #2
0
    def get_domain(self):
        if self._domain:
            return self._domain

        if self.session and 'domain' in self.session:
            return self.session['domain']

        return os.environ[Const().ENV_LIGHT_APP_DOMAIN]
Beispiel #3
0
import os
import re
import inflect
import mimetypes

from pymongo import MongoClient, DESCENDING, ASCENDING
from bson.objectid import ObjectId
from light.constant import Const
from gridfs import GridFS, GridFSBucket
from gridfs.errors import NoFile

from light.mongo.mapping import Update, Query
from light.mongo.define import Items
from light.mongo.type import Boolean, Number

CONST = Const()


class Model:
    """
    1. 创建于数据库的连接, 并保持连接池
    2. 数据库连接信息通过环境变量设定
    3. 用表结构的定义, 对保存的数据进行类型转换
    4. 用表结构的定义, 对条件中的数据进行类型转换
    5. 功能包括: 通常的CURD, GridFS操作, 数据库索引操作, 数据库用户操作
    """

    def __init__(self, domain, code=None, table=None, define=None, user=None, password=None):
        self.domain = domain
        self.code = code
        self.define = define