-from sqlalchemy import Column, ForeignKey
-from sqlalchemy.orm import relation
-from sqlalchemy.types import Integer, Unicode
+#
+# floof/floof/model/users.py
+#
+# Copyright (c) 2009 Scribblr
+#
-from floof.model import meta
+from elixir import Entity, Field, Unicode, belongs_to, has_many
-__all__ = ['User', 'IdentityURL']
+class User(Entity):
+ name = Field(Unicode(20))
+ has_many('identity_urls', of_kind='IdentityURL')
-class User(meta.TableBase):
- __tablename__ = 'users'
- id = Column(Integer, primary_key=True)
- name = Column(Unicode(length=20), nullable=False)
+class IdentityURL(Entity):
+ url = Field(Unicode(255))
+ belongs_to('user', of_kind='User')
-class IdentityURL(meta.TableBase):
- __tablename__ = 'identity_urls'
- url = Column(Unicode(length=255), primary_key=True)
- user_id = Column(Integer, ForeignKey('users.id'))
-
-IdentityURL.user = relation(User, lazy=False, backref="identity_urls")