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?
source to share
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 .
source to share