summaryrefslogtreecommitdiffstats
path: root/manas/model/model.template
blob: 2cf9c40ddcbead13c1bd55cbdf5529f165f3d0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from pylons import config
from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from manas.model import metadata

# Normal tables may be defined and mapped at module level.
 
foo_table = Table("Foo", metadata,
     Column("id", types.Integer, primary_key=True),
     Column("bar", types.String(255), nullable=False),
     )

class Foo(object):
    def __init__(self, **kw):
        """automatically mapping attributes"""
        for key, value in kw.iteritems():
            setattr(self, key, value)

mapper(Foo, foo_table)

Classes for reflected tables may be defined here, but the table and
mapping itself must be done in the init_model function.