Changeset 5616

Show
Ignore:
Timestamp:
10/25/08 12:26:35 (3 months ago)
Author:
Gustavo
Message:

Updated the references to "identity" in the SQLAlchemy tutorial

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • docs/2.0/docs/main/SQLAlchemy.rst

    r5170 r5616  
    2222 
    2323* `__init__.py`: This is where the database access is setup. Your tables should be imported into this module, and you're highly encouaged to define them in a separate module - `entities`, for example. 
    24 * `identity.py`: This file will be created if you enabled identity in the quickstart. It defines the three tables TG2 identity relies on: `User` (for the registered members in your website), `Group` (for the teams a member may belong to, and to which you can assign permissions) and `Permission` (a permission granted to one or more groups); it also defines two intermediary tables: One for the many-to-many relationship between the groups and the permissions, and another one for the many-to-many relationship between the users and the groups. 
     24* `auth.py`: This file will be created if you enabled authentication and authorization in the quickstart. It defines the three tables :mod:`tgext.authorization.quickstart` relies on: `User` (for the registered members in your website), `Group` (for the teams a member may belong to, and to which you can assign permissions) and `Permission` (a permission granted to one or more groups); it also defines two intermediary tables: One for the many-to-many relationship between the groups and the permissions, and another one for the many-to-many relationship between the users and the groups. 
    2525 
    2626Auto-reflection of tables has to happen after all the configuration is read, and the app is setup, so we provide simple init_model method (defined in `model/__init__.py`) that is not called until after everything is setup for you. 
     
    3535* The declarative method, which relies on a built-in plugin for SQLAlchemy called `Declarative <http://www.sqlalchemy.org/docs/05/plugins.html#plugins_declarative>`_. This is the most intuitive method for table definition. 
    3636 
    37 The tables defined by the quickstart in `model/identity.py` are based on the declarative method, so you may want to check it out to see how columns are defined for these tables, as well as to see real examples of many-to-one, one-to-many and many-to-many relationships. For more information, you may read `the ORM tutorial <http://www.sqlalchemy.org/docs/05/ormtutorial.html>`_ and the documentation for `the Declarative extension <http://www.sqlalchemy.org/docs/05/plugins.html#plugins_declarative>`_. 
     37The tables defined by the quickstart in `model/auth.py` are based on the declarative method, so you may want to check it out to see how columns are defined for these tables, as well as to see real examples of many-to-one, one-to-many and many-to-many relationships. For more information, you may read `the ORM tutorial <http://www.sqlalchemy.org/docs/05/ormtutorial.html>`_ and the documentation for `the Declarative extension <http://www.sqlalchemy.org/docs/05/plugins.html#plugins_declarative>`_. 
    3838 
    3939Once you have defined your tables in a separate module in the `model` package, they should be imported from `model/__init__.py`. So the end of this file would look like this: 
     
    4242 
    4343  # Import your model modules here.  
    44   from identity import User, Group, Permission 
     44  from auth import User, Group, Permission 
    4545  # Say you defined these three classes in the 'movies' 
    4646  # module of your 'model' package. 
     
    127127 
    128128 
    129 Using non-default names for identity-related tables and mapped classes 
    130 ------------------------------------------------------------------------ 
     129Using non-default names for auth-related classes 
     130------------------------------------------------ 
    131131 
    132 If you don't want to use the default names for your identity-related tables and mapped classes, it's easy to replace them. 
    133  
    134 Once you have renamed the class names, go to `{your-app}/config/app_cfg.py` and edit these lines accordingly:: 
    135  
    136   # To replace the 'User' class by 'Member': 
    137   base_config.sa_auth.user_class = model.Member 
    138   # To use a different table name for the registered users: 
    139   base_config.sa_auth.users_table = 'member' 
    140   # To replace the 'Group' class by 'Team': 
    141   base_config.sa_auth.group_class = model.Team 
    142   # To use a different table name for the groups in your website: 
    143   base_config.sa_auth.groups_table = 'team' 
    144   # The Permission class and its table are not modified; we're happy with their names. 
    145   base_config.sa_auth.permission_class = model.Permission 
    146   base_config.sa_auth.permissions_table = 'permission' 
    147  
     132If you don't want to use the default names for your auth-related classes, it's easy to replace them. 
     133Please check the documentation for :mod:`tgext.authorization.quickstart` to 
     134learn how to do it. 
    148135 
    149136Quick database creation