Turbogears 2 e Elixir

8:29 am Programação, Python

Para se integrar o elixir no turbogears 2, basta editar o arquivo model/__init__.py do seu projeto para ficar desse jeito:

# -*- coding: utf-8 -*-

from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import elixir

maker = sessionmaker(autoflush=True, autocommit=False,
DBSession = scoped_session(maker)
elixir.session = DBSession
elixir.options_defaults["shortnames"] = True

DeclarativeBase = declarative_base()

metadata = DeclarativeBase.metadata
elixir.metadata = metadata

def init_model(engine):
    """Call me before using any of the tables or classes in the model."""


from xyz.model.auth import User, Group, Permission
from xyz.model.entidades import Xyz


E para declarar suas entidades, basta fazer do jeito do Elixir, estendendo a classe elixir.Entity.

Com essa integração conseguimos utilizar o padrão Active Record.

One Response

  1. home intercom systems Says:

    If you are planning an expansion to your property its simple
    that you need to acquire and then install additional security sensors in order to protect an extended section of your own house.
    Wireless alarm systems keep off the thieves and burglaries,
    making your home more secure when you are out. All the products on the site come with a manufacturer’s warranty and a 30 day money back offer, so if
    you do not like the doorbell that you buy, you can simply return it and
    get your money back, no questions asked.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.