Syncing Django users to Google Apps without monkeypatching

I am writing a Django application and I would like an account to be created on our Google Apps public email using the Provisioning API whenever an account is created locally.

I would only use signals, but since I would like the passwords to be synchronized across different sites, I have a monkey tagged User.objects.create_user

and User.set_password

with wrappers to create google accounts and update passwords accordingly.

Monkeypatching seemed to be frowning, so I had to know if there is a better way to do this?

+1


source to share


4 answers


Have you considered subclassing User Models? This can create a different set of problems and is only available with newer versions (not sure when the changes came in, I'm on the go).



+1


source


Subclassing is the best route if you can change all of your code to use the new class. I think this is supported in the latest version of Django.



0


source


Monkeypatching is definitely bad. It's hard to say anything since you have provided so little code / information. But I am assuming you have the password in cleartext at some point (in view, in form), so why not sync manually?

0


source


I subclass a user with Django 1.0.2. Basically you are creating another table that references the user_id.

class User(MyBaseModel):
    user = models.OneToOneField(User, help_text="The django created User object")

      

and then at runtime

@login_required
def add(request) :
    u = request.user.get_profile()

      

Then you can easily overwrite the required methods.

And for those who haven't heard of monkeypatching: http://en.wikipedia.org/wiki/Monkey_patch . This is the conclusion from the partisan patch .

0


source







All Articles