Table of Contents
from:
from turbogears.database import PackageHub from sqlobject import *to:
from elixir import *
from:
class List(SQLObject): passto:
class List(Entity): pass
from:
class List(SQLObject): title = UnicodeCol(notNone=True)to (Elixir 0.4):
class List(Entity): title = Field(Unicode, nullable=False)or to (Elixir 0.3):
class List(Entity): has_field('title', Unicode, nullable=False)
from:
class List(SQLObject): items = MultipleJoin('Item') class Item(SQLObject): list = ForeignKey('List')to (Elixir 0.4):
class List(Entity): OneToMany('Items') class Item(Entity): ManyToOne('List')or to (Elixir 0.3):
class List(Entity): has_many('items', of_kind='Item') class Item(Entity): belongs_to('list', of_kind='List')
Check http://elixir.ematia.de/trac/wiki/TutorialDivingIn to become familiar with the usage of elixir.
Same, but you need to specify the argument name.
from:
records = User.getByName("Fred")
to:
records = User.get_by(name = "Fred")
Use ‘c’ in sqlalchemy instead of ‘q’ in sqlobject.
from:
records = User.select(User.q.user_name == "Fred")
to (Elixir 0.4):
records = User.query.filter(User.c.user_name == "Fred").all()
or to (Elixir 0.3):
records = User.select(User.c.user_name == "Fred")
selectByName method -> select_Name method
from:
records = User.selectByName("Fred")
to (Elixir 0.4):
records = User.query.filter_by(name = "Fred").all()
or to (Elixir 0.3):
records = User.select_by(name = "Fred")