-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_1.py
More file actions
47 lines (33 loc) · 1.04 KB
/
test_1.py
File metadata and controls
47 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Test the uodm"""
from __future__ import division, print_function, unicode_literals
import posixpath
import pymongo
import uodm
from uodm import Attr
__author__ = [ "Juan Carrano <jc@eiwa.ag>",
"Federico Allo Ron <far@eiwa.ag>"
]
__copyright__ = "Copyright 2016 EIWA S.A. All rights reserved."
__license__ = """Unauthorized copying of this file, via any medium is
strictly prohibited. Proprietary and confidential"""
class City(uodm.Document):
DB_COLLECTION = 'cities'
ATTRIBUTES = {
'name': Attr(),
'population': Attr('m'),
'ancient': Attr('', False),
}
class Person(uodm.Document):
DB_COLLECTION = 'people'
ATTRIBUTES = {
'name': Attr(),
'age': Attr('m'),
'city': Attr('mr', City),
'is_cool': Attr('', True)
}
if __name__ == '__main__':
import sys
mongo_conn_uri = sys.argv[1]
dbname = posixpath.basename(mongo_conn_uri)
client = pymongo.MongoClient(mongo_conn_uri)[dbname]
odm = uodm.ODM(client)