Git Product home page Git Product logo

Comments (4)

cd34 avatar cd34 commented on August 20, 2024

That is another case of documentation being missed.

The way it works is:

auth_id -----> extended profile
   |----> local auth
   |----> openID provider.

the extended profile is a parallel table to the authentication table, and the user table actually allows multiple authentication methods to be associated with a single authentication id. This way, a user on your system could have a local auth and attach a Facebook auth to it. They would have two different ways to log into the same Auth ID.

I've cleaned up the docs slightly, but, need to document things a little better as that was written before the main rewrite of Apex.

from apex.

lovekc avatar lovekc commented on August 20, 2024

so right now if I want to add the first name and last name fields I can do something like this?

in models/init.py
from apex.models import AuthID

class ForeignKeyProfile(Base):
tablename = 'auth_user_profile'
id = Column(types.BigInteger, primary_key=True)
auth_id = Column(types.BigInteger, ForeignKey(AuthID.id), index=True)

""" Add your locally defined options here
"""
first_name = Column(Unicode(80))
last_name = Column(Unicode(80))

user = relationship(AuthID, backref=backref('profile', uselist=False))
def __int__(self,auth_id, first_name, last_name);
    self.auth_id = auth_id
    self.first_name = first_name
    self.last_name = last_name

in project/models/profile.py
from apex.forms import RegisterForm
from project.models import DBSession
from project.models import ForeignKeyProfile

class NewRegisterForm(RegisterForm):
first_name = TextField(u'First Name', [validators.length(max=10)])
last_name = TextField(u'Last Name', [validators.length(max=10)])
def after_signup(self, user):
profile = ForeignKeyProfile(auth_id=user.auth_id,first_name=self.data['first_name'], last_name=self.data['last_name']) # is this correct???????
DBSession.add(profile)
DBSession.flush()

by the way ,under the "If you are using OpenID providers: section". why there is
project/profile.py and project/models/profile.py ? there should be only one file, right?
and class openid_after(object): should be class openid_after(RegisterForm): , right ???

also what is the usage of the ExtendedProfile class in apex_example/models.py ?

Thank you ! sorry to ask you so many questions. I'm a newbie

from apex.

lovekc avatar lovekc commented on August 20, 2024

shouldn't be AuthID = relationship(AuthID, backref=backref('profile', uselist=False)) rather than
user = relationship(AuthID, backref=backref('profile', uselist=False)) ? Thank you!

from apex.

cd34 avatar cd34 commented on August 20, 2024

I need to remove one of those sections. The early version of Apex made the distinction between a locally created user and an OpenID created user. The one on the top of that page is the most accurate.

project/profile.py and project/models/profile.py is a typo, it should be in models.

openid_after(object): should be class openid_after(RegisterForm):

You're sending an object through, not the form. However, the documentation is again out of date here. Here's a sample from some code using the current version of Apex.

class openid_after:
    def after_signup(self, **kwargs):
        request = kwargs.pop('request', False)
        if kwargs.has_key('user'):
            user = kwargs.pop('user', False)
            profile = get_or_create(DBSession, User_Profile, auth_id=user.id)
        DBSession.flush()
        return request

user = relationship(AuthID, backref=backref('profile', uselist=False))

You are correct, overactive search and replace when fixing the docs.

Leaving this open until I get a chance to fix the docs and update the example

from apex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.