Commit 728fc7e6ce28bfcee73c4e25e50b1670d44fde20

Authored by pedro
1 parent 42d219ba
Exists in master

correção na classe do registro

git-svn-id: http://svn.brlight.net/svn/lightbase-neo/trunk/LBBulk@749 29b92fdf-8c97-4584-b987-84e8d3c556fa
lbbulk/__init__.py
... ... @@ -2,10 +2,7 @@ from pyramid.config import Configurator
2 2 from sqlalchemy import engine_from_config
3 3 from lbbulk.config.routing import make_routes
4 4  
5   -from lbbulk.models import (
6   - DBSession,
7   - Base,
8   - )
  5 +from lbbulk.model import Base, metadata, DBSession
9 6  
10 7  
11 8 def main(global_config, **settings):
... ...
lbbulk/model/Registro.py 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +from sqlalchemy import Table, Column, Integer, \
  2 + String, join, ForeignKey
  3 +from sqlalchemy.orm import column_property
  4 +from lbbulk.model import Base, metadata
  5 +
  6 +# define two Table objects
  7 +bulk_sources = Table('lb_bulk_sources', metadata,
  8 + Column('id_source', Integer, primary_key=True),
  9 + Column('nome_source', String),
  10 + )
  11 +
  12 +bulk_upload = Table('lb_bulk_upload', metadata,
  13 + Column('id_reg', Integer, primary_key=True),
  14 + Column('chave_externa', String)
  15 + Column('id_source', Integer, ForeignKey('lb_bulk_sources.id_source')),
  16 + )
  17 +
  18 +# define a join between them. This
  19 +# takes place across the bulk_sources.id_source and bulk_upload.id_source
  20 +# columns.
  21 +registro = join(bulk_sources, bulk_upload)
  22 +
  23 +# map to it
  24 +class Registro(Base):
  25 + __table__ = registro
  26 +
  27 + id_source = column_property(bulk_sources.c.id_source, bulk_upload.c.id_source)
0 28 \ No newline at end of file
... ...
lbbulk/model/__init__.py 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +from sqlalchemy import MetaData
  2 +from sqlalchemy.ext.declarative import declarative_base
  3 +from sqlalchemy.orm import scoped_session, sessionmaker
  4 +
  5 +metadata = MetaData()
  6 +Base = declarative_base()
  7 +DBSession = scoped_session(sessionmaker())
0 8 \ No newline at end of file
... ...
lbbulk/models/Registro.py
... ... @@ -1,32 +0,0 @@
1   -from sqlalchemy import Table, Column, Integer, \
2   - String, MetaData, join, ForeignKey
3   -from sqlalchemy.ext.declarative import declarative_base
4   -from sqlalchemy.orm import column_property
5   -
6   -metadata = MetaData()
7   -
8   -# define two Table objects
9   -bulk_sources = Table('lb_bulk_sources', metadata,
10   - Column('id_source', Integer, primary_key=True),
11   - Column('nome_source', String),
12   - )
13   -
14   -bulk_upload = Table('lb_bulk_upload', metadata,
15   - Column('id_reg', Integer, primary_key=True),
16   - Column('chave_externa', String)
17   - Column('id_source', Integer, ForeignKey('lb_bulk_sources.id_source')),
18   - )
19   -
20   -# define a join between them. This
21   -# takes place across the user.id and address.user_id
22   -# columns.
23   -user_address_join = join(user_table, address_table)
24   -
25   -Base = declarative_base()
26   -
27   -# map to it
28   -class AddressUser(Base):
29   - __table__ = user_address_join
30   -
31   - id = column_property(user_table.c.id, address_table.c.user_id)
32   - address_id = address_table.c.id
33 0 \ No newline at end of file
lbbulk/models/__init__.py
... ... @@ -1 +0,0 @@
1   -# package
lbbulk/views.py
1 1 from pyramid.response import Response
2 2 from pyramid.view import view_config
3 3  
4   -from sqlalchemy.exc import DBAPIError
5   -
6 4  
7 5 @view_config(route_name='home', renderer='templates/mytemplate.pt')
8 6 def my_view(request):
... ...