Exemple #1
0
def adddata():
    db = connect.get_db()
    dats = connect.readdatabaseall(db)

    if request.method == 'POST':
        if request.form['username'] != 0:
            res = dats.adddata(request.form['username'], request.form['mail'])
            if res == True:
                print('ок')

            else:
                print('хреново')
    return render_template('index.html', name=dats.getdata())
Exemple #2
0
    def __new__(cls, name, bases, attrs):

        if name not in ['MetaEnum', 'BaseDocument']:
            _db = get_db()
            if 'collection_name' in attrs:
                collection = _db[attrs['collection_name']]
            else:
                collection = _db[name.lower()]
            attrs.update({'collection':collection})
            attrs.update({'DoesNotExist': type("DoesNotExist", (DoesNotExist,), {'reason': '%s does not exist' % name.lower()})})

        new_cls = super(MetaDocument, cls).__new__(cls, name, bases, attrs)
        return new_cls
Exemple #3
0
def hello_world():
    db = connect.get_db()
    dats = connect.readdatabaseall(db)
    print(dats)
    return render_template('index.html', name=dats.getdata())
Exemple #4
0
 def get_collection(self,coll_name):
     db=get_db()
     return db[coll_name]
Exemple #5
0
import os
import re
import connect
from datetime import datetime

PUBLICATION = 'ALLPUBS://'

db = connect.get_db()

def get_file_db_info(folder, filename):
    """Returns dt_cms_schema.CMSFile ID"""
    sql = str.format("CALL dt_cms_dreamweaver.GetFileDBInfo('{p}', '{fo}', '{fi}', 1)",
                     p=PUBLICATION,fo=folder,fi=filename)
    res = db.execute_sql(sql, True)
    return res[0][0]

def start_file_put(folder, filename):
    """Returns dt_cms_dreamweaver.TempFileStorage ID"""
    sql = str.format("CALL dt_cms_dreamweaver.StartFilePut('{p}', '{fo}', '{fi}'",
                     p=PUBLICATION,fo=folder,fi=filename)
    res = db.execute_sql(sql, True)
    return res[0][0]

def update_file_content(content, file_id):
    content = re.sub(r"'", "''", content)
    sql = str.format("UPDATE dt_cms_schema.CMSFile SET content='{c}' WHERE ID={i}",
                     c=content,i=file_id)
    db.execute_sql(sql, False)

def compile_file(folder, filename, modified):
    """Returns the modified date you passed in, because DTI"""
Exemple #6
0
    def drop_collection(cls):

        db =get_db()
        db.drop_collection(cls._collection)