1
"""Setup the central_library application"""
2
import logging
3
4
import datetime
5
6
from central_library.config.environment import load_environment
7
8
log = logging.getLogger(__name__)
9
10
def setup_app(command, conf, vars):
11
    """Place any commands to setup central_library here"""
12
    load_environment(conf.global_conf, conf.local_conf)
13
14
    # Load the models
15
    from central_library.model import meta
16
    meta.metadata.bind = meta.engine
17
18
    # Create the tables if they aren't there already
19
    meta.metadata.create_all(checkfirst=True)
20
    
21
    from central_library.model import User, Copy, Item
22
23
    quentin = User(u"Quentin McUserpants", u"123 E. Main St.\nBoondocksville, XY, 12345")
24
    
25
    book1 = Item(u"A Million Random Digits with 100,000 Normal Deviates", u"RAND Corporation", 9780833030474, datetime.date(2002, 12, 25), "book")
26
    book2 = Item(u"Watchmen", u"Alan Moore and Dave Gibbons", 9780930289232, datetime.date(1995, 4, 1), "book")
27
    copy1 = Copy(book1, datetime.date(2005, 1, 1), u"dogeared")
28
    copy2 = Copy(book1, datetime.date.today(), u"brand new")
29
    copy3 = Copy(book2, datetime.date.today(), u"brand new")
30
    sess = meta.Session()
31
    sess.add_all([quentin, book1, book2, copy1, copy2, copy3])
32
    sess.commit()