Exemplo n.º 1
0
 def __init__(self):
     self.allItems = {}
     try:
         with stdDBIO("????????") as io:
             for key in webpageManager.db_itemNeed:
                 self.allItems[key.__name__] = getAllItem(io, key)
     except:
         pass
Exemplo n.º 2
0
def add_login_user(mongodbToken,encryption,request):
    global default_login,ioTable
    key = str(uuid.uuid4())
    if len(ioTable)>100: # for more than 100 user, he will find he can't login lol but he won't know why
        #print("maximum client reached")
        return False
    try:
        client =  stdDBIO(mongodbToken=mongodbToken,content_password = encryption)
        #print("set client to memory")
        ioTable[key] = client
    except Exception as e:
        #print("should not go here",e)
        return False
    request.session["iokey"] = key #
    threading.Thread(target=_maintain_login_user,args=[key]).start()
    #print("cool")
    return True
Exemplo n.º 3
0
def addSampleToDB(samples):
    io = stdDBIO("960911nbrNBR", mode=CONNECTOR_READWRITE)
    io.setDB(Transaction.dbname)
    io.setCollection(Transaction.collection)
    for s in samples:
        io.writeObj(s)
Exemplo n.º 4
0
def updateDefaultLogin():
    global default_login
    try:
        default_login = stdDBIO("960911nbrNBR", mode=CONNECTOR_READWRITE)
    except:
        pass
Exemplo n.º 5
0
REMOTE_HOST = "https://pyecharts.github.io/assets/js"

#2018/7/6 update. Since io object which PFA use to keep a connection to database can't be stored in session since it contains SSL context
# we have to maintain it in memory for every user. We will store a unique key in user's session and with that key, the user can access to
# his in memory io object. The problem needed to pay attension is that key must be randomly generated or only known to the current user
# otherwise, if other user get the key, they can easily change their local session and obtain other users io object to access other's db
# We have to clear the in memory io objects table regularly or keep only a limited number of items to limit the memory


# solution: each time the user login, a random number will be generated accosiated with his io object
# at the same time, a new timing thread will start to count down 2h. After 2h, the io object will be destory
# currently, we allow a maximum of 100 users login. If the number exceed, we assume it is under attack and will reject login request

# a public default login session for demostration will never be shut down
default_login = stdDBIO("960911nbrNBR",mode=CONNECTOR_READWRITE)
def updateDefaultLogin():
    global default_login
    try:
        default_login = stdDBIO("960911nbrNBR", mode=CONNECTOR_READWRITE)
    except:
        pass
ioTable = {}
def add_login_user(mongodbToken,encryption,request):
    global default_login,ioTable
    key = str(uuid.uuid4())
    if len(ioTable)>100: # for more than 100 user, he will find he can't login lol but he won't know why
        #print("maximum client reached")
        return False
    try:
        client =  stdDBIO(mongodbToken=mongodbToken,content_password = encryption)