diff rhodecode/model/__init__.py @ 811:bb35ad076e2f beta

docs updates
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 05 Dec 2010 17:22:57 +0100
parents a7f50911a945
children 07a6e8c65526 a3b2b4b4e440
line wrap: on
line diff
--- a/rhodecode/model/__init__.py	Sun Dec 05 15:47:49 2010 +0100
+++ b/rhodecode/model/__init__.py	Sun Dec 05 17:22:57 2010 +0100
@@ -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 @@
 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: