On 9/8/07, Joshua 'jag' Ginsberg <[EMAIL PROTECTED]> wrote:

> So at my work we developed an app to provide object-level permissions.
> Ideally, we could ask a User object if it has permission on a certain object
> via a method in that User object, but absent hacking the User object, that's
> not going to happen. I can subclass User and add the methods I want -- it
> will walk and quack like a User. But then I also have to rewrite get_user()
> so that it returns a ObjectPermissionAwareUser instead of a User. I have to
> rewrite authenticate() as well. And I have to check the middleware to make
> sure it uses get_user() instead of returning a user itself.
>
> In the end we subclass User and write a method to give us an
> ObjectPermissionAwareUser when we have a User object.

You can use monkey patching [1] instead of subclassing. If you're
using nice dynamic language you can use nice dynamic features.

[1] http://en.wikipedia.org/wiki/Monkey_patching

-- 
Vsevolod Solovyov

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to