3 pkg_resources.require("SQLAlchemy>=0.4.9")
4 pkg_resources.require("Elixir>=0.4.0")
6 # with this line enabled, other models cannot import this file.
7 # it results in the wrong metadata value being loaded, I think.
8 #from turbogears.database import metadata, mapper
11 #pkg_resources.require("SQLObject>=0.7.1")
12 #from turbogears.database import PackageHub, AutoConnectHub
13 #from turbogears import config
14 #uri = config.get("sqlobject.dburi")
15 #from sqlobject import connectionForURI,sqlhub
16 #sqlhub.processConnection = connectionForURI(uri)
19 # NOTE: this try, will allow external modules to import the model without
20 # requring the turbogears garbage.
22 print traceback.print_exc()
25 from elixir import Entity, Field, OneToMany, ManyToOne, ManyToMany
26 from elixir import options_defaults, using_options, setup_all
27 from elixir import String, Unicode, Integer, DateTime
28 options_defaults['autosetup'] = False
29 # NOTE: due to the module path length, this is required.
30 options_defaults['shortnames'] = True
32 from monitor.database.dborm import mon_metadata, mon_session
33 __metadata__ = mon_metadata
34 __session__ = mon_session
36 def findby_or_create(cls, if_new_set={}, **kwargs):
37 result = cls.get_by(**kwargs)
39 result = cls(**kwargs)
40 result.set(**if_new_set)
42 Entity.findby_or_create = classmethod(findby_or_create)
44 from monitor.database.info.action import *
45 from monitor.database.info.findbad import *
46 from monitor.database.info.history import *
47 from monitor.database.info.plc import *