annotate rhodecode/model/__init__.py @ 752:89b9037d68b7 beta

fixed Example celery config to ampq, fixed session problems on models and celery, implemented one base model as a parent for other
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 24 Nov 2010 17:15:33 +0100
parents 1e757ac98988
children a7f50911a945
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """The application's model objects"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2 import logging
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
3 from rhodecode.model import meta
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
4 log = logging.getLogger(__name__)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
5
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
6 def init_model(engine):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
7 """Call me before using any of the tables or classes in the model"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
8 log.info("INITIALIZING DB MODELS")
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
9 meta.Base.metadata.bind = engine
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
10 #meta.Base2.metadata.bind = engine2
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
11
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12 #THIS IS A TEST FOR EXECUTING SCRIPT AND LOAD PYLONS APPLICATION GLOBALS
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 #from paste.deploy import appconfig
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 #from pylons import config
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
15 #from sqlalchemy import engine_from_config
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
16 #from rhodecode.config.environment import load_environment
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
17 #
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
18 #conf = appconfig('config:development.ini', relative_to = './../../')
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
19 #load_environment(conf.global_conf, conf.local_conf)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
20 #
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
21 #engine = engine_from_config(config, 'sqlalchemy.')
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
22 #init_model(engine)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 # DO SOMETHING
752
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
24
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
25
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
26 class BaseModel(object):
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
27
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
28 def __init__(self, sa=None):
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
29 if sa is not None:
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
30 self.sa = sa
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
31 else:
89b9037d68b7 fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
32 self.sa = meta.Session()