Exemplo n.º 1
0
def new(db_handle, db_table, add_modified_field=True, add_archived_field=True):
    record = copy.deepcopy(db[db_table])

    db_fk_settings(record, add_archived_field)

    record["__db__name__"] = db_table

    timestamp, timestamp_str = utils._get_current_timestamp()
    record["rec_timestamp"] = timestamp
    record["rec_timestamp_str"] = timestamp_str

    if add_modified_field:
        record["last_modified_timestamp"] = ""
        record["last_modified_timestamp_str"] = ""

    if add_archived_field:
        _db_add_archive_field(record)

    random_hex = os.urandom(24).hex()
    random_int = random.randint(config.G_RANDOM_START, config.G_RANDOM_END)
    req_id = random_hex + "-" + str(random_int)

    record["_id"] = ObjectId()
    record["ipkey"] = str(record["_id"])
    record["pkey"] = record["ipkey"] + "-" + req_id
    mongo_record_model = model.mongo_model(record, record, db_handle)
    return mongo_record_model
Exemplo n.º 2
0
def new_record(db_handle, db_table, db_table_fks, add_modified_field = config.G_RECORD_ADD_MODIFIED_TIMESTAMP, add_archived_field = config.G_RECORD_ADD_ARCHIVED_TIMESTAMP):
    record = copy.deepcopy(db[db_table])
    
    record = _clean_record(record, db_table_fks[db_table], add_archived_field)

    record["__db__name__"     ] = db_table

    timestamp, timestamp_str    = utils._get_current_timestamp()
    record["rec_timestamp"    ] = timestamp
    record["rec_timestamp_str"] = timestamp_str
    
    if add_modified_field:
        record["last_modified_timestamp"] = ""
        record["last_modified_timestamp_str"] = ""

    if add_archived_field:
        _db_add_archive_field(record)

    random_hex   = os.urandom(24).hex()
    random_int   = random.randint( config.G_RANDOM_START , config.G_RANDOM_END )
    req_id       = random_hex + "-" + str(random_int)

    record["_id"  ] = ObjectId()
    record["ipkey"] = str( record["_id"] )
    record["pkey" ] = record["ipkey"] + "-" + req_id
    mongo_record_model      = model.mongo_model( record , record , db_handle )
    return  mongo_record_model 
Exemplo n.º 3
0
def load(db_handle, db_table):
    record = copy.deepcopy(db[db_table])

    db_fk_settings(record)

    record["__db__name__"] = db_table
    mongo_record_model = model.mongo_model({}, record, db_handle)
    return mongo_record_model
Exemplo n.º 4
0
def new(db_handle, db_table):
    timestamp = int(time.time()) * 1000
    record = db[db_table]
    record["__db__name__"] = db_table
    record["rec_timestamp"] = timestamp
    record["rec_timestamp_str"] = time.strftime(
        '%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))
    record["_id"] = ObjectId()
    record["pkey"] = str(record["_id"])
    mongo_record_model = model.mongo_model(record, record, db_handle)
    return mongo_record_model
Exemplo n.º 5
0
def new(db_handle, db_table):
    timestamp = int(time.time()) * 1000
    record = db[db_table]
    record["__db__name__"] = db_table
    record["rec_timestamp"] = timestamp
    record["rec_timestamp_str"] = time.strftime(
        '%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))

    now_time = int(time.time() * 1000)
    random_int = random.randint(config.G_RANDOM_START, config.G_RANDOM_END)

    _id = ObjectId()
    record["ipkey"] = str(_id)
    record["pkey"] = str(_id) + "-" + str(now_time) + "-" + str(random_int)

    mongo_record_model = model.mongo_model(record, record, db_handle)
    return mongo_record_model
Exemplo n.º 6
0
def load(db_handle, db_table):
    record = db[db_table]
    record["__db__name__"] = db_table
    mongo_record_model = model.mongo_model({}, record, db_handle)
    return mongo_record_model