diff options
author | Marcin Kuzminski <marcin@python-works.com> | 2010-12-05 17:22:57 +0100 |
---|---|---|
committer | Marcin Kuzminski <marcin@python-works.com> | 2010-12-05 17:22:57 +0100 |
commit | 402a828b5ab6010813c8d2dd2ce8448d6eecc5aa (patch) | |
tree | d35771cfbb06891a01f9ca340f72338859c14a90 /rhodecode/model/__init__.py | |
parent | d29feac9fea564c5d15d7d6c285010f4a1466591 (diff) |
docs updates
--HG--
branch : beta
Diffstat (limited to 'rhodecode/model/__init__.py')
-rw-r--r-- | rhodecode/model/__init__.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/rhodecode/model/__init__.py b/rhodecode/model/__init__.py index 2943cb46..1ac7732e 100644 --- a/rhodecode/model/__init__.py +++ b/rhodecode/model/__init__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- """ - package.rhodecode.model.__init__ - ~~~~~~~~~~~~~~ + rhodecode.model.__init__ + ~~~~~~~~~~~~~~~~~~~~~~~~ + The application's model objects :created_on: Nov 25, 2010 @@ -11,17 +12,20 @@ :example: - from paste.deploy import appconfig - from pylons import config - from sqlalchemy import engine_from_config - from rhodecode.config.environment import load_environment - - conf = appconfig('config:development.ini', relative_to = './../../') - load_environment(conf.global_conf, conf.local_conf) - - engine = engine_from_config(config, 'sqlalchemy.') - init_model(engine) - #RUN YOUR CODE HERE + + .. code-block:: python + + from paste.deploy import appconfig + from pylons import config + from sqlalchemy import engine_from_config + from rhodecode.config.environment import load_environment + + conf = appconfig('config:development.ini', relative_to = './../../') + load_environment(conf.global_conf, conf.local_conf) + + engine = engine_from_config(config, 'sqlalchemy.') + init_model(engine) + # RUN YOUR CODE HERE """ # This program is free software; you can redistribute it and/or @@ -44,11 +48,21 @@ from rhodecode.model import meta log = logging.getLogger(__name__) def init_model(engine): - """Call me before using any of the tables or classes in the model""" + """Initializes db session, bind the engine with the metadata, + Call this before using any of the tables or classes in the model, preferably + once in application start + + :param engine: engine to bind to + """ log.info("initializing db models for %s", engine) meta.Base.metadata.bind = engine class BaseModel(object): + """Base Model for all RhodeCode models, it adds sql alchemy session + into instance of model + + :param sa: If passed it reuses this session instead of creating a new one + """ def __init__(self, sa=None): if sa is not None: |