Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from sqlalchemy.orm import *
from sqlalchemy import Table, Column, ForeignKey, Integer
from sqlalchemy.types import Integer, Unicode, String, DateTime
from pylons_openid.model import meta
def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
meta.engine = engine
user_table = Table('user', meta.metadata,
Column('id', Integer, primary_key=True),
Column('username', String(128), nullable=False),
Column('password', String(128), nullable=False),
Column('acl', String(16), nullable=False),
Column('name', String(32), nullable=False),
Column('dateLogin', DateTime),
Column('sessionId', String(32)),
Column('ip', String(16)),
user_openid_table = Table('user_openid', meta.metadata,
Column('id', Integer, primary_key=True),
Column('verifiedEmail', String(200), nullable=False),
Column('displayName', String(200), nullable=False),
Column('preferredUsername', String(200), nullable=False),
Column('providerName', String(100), nullable=False),
Column('identifier', String(200), nullable=False),
Column('email', String(200), nullable=False),
Column('user_id', Integer, ForeignKey("")),
class User(object):
def __init__(self, id=None, username=None, password=None, acl=None, name=None, dateLogin=None, sessionId=None, ip=None): = id
self.username = username
self.password = password
self.acl = acl = name
self.dateLogin = dateLogin
self.sessionId = sessionId
self.ip = ip
def __repr__(self):
class UserOpenId(object):
def __init__(self, id=None, verifiedEmail=None, displayName=None, preferredUsername=None, providerName=None, identifier=None, email=None, user_id=None): = id
self.verifiedEmail = verifiedEmail
self.displayName = displayName
self.preferredUsername = preferredUsername
self.providerName = providerName
self.identifier = identifier = email
self.user_id = user_id
def __repr__(self):
return "%s (%s) %s" % (self.providerName, self.verifiedEmail, self.identifier)
mapper(User, user_table, properties={
"openids": relation(UserOpenId)
mapper(UserOpenId, user_openid_table, properties={
"user": relation(User)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.