views:

379

answers:

2

I created a custom django.auth User class which works with Google Appengine, but it involves a fair amount of copied code (practically every method).

It isn't possible to create a subclass because appengine and django have different database models with their own metaclass magic.

So my question is this: is there an elegant way to copy methods from django.auth's User class?

from google.appengine.ext import db
from django.contrib.auth import models

class User(db.Model):
    password = db.StringProperty()
    ...
    # copied method
    set_password = models.User.set_password.im_func
A: 

Im not sure I understand your question right. Why would you need to define another "User" class if Django already provides the same functionality ?

You could also just import the "User" class and add a ForeignKey to each model requiring a "user" attribute.

Etienne
I created a new User class because Django models do not work on appengine.
csytan
A: 

You might want to take a look at what the django helper or app-engine-patch does.

Helper: http://code.google.com/p/google-app-engine-django/ Patch: http://code.google.com/p/app-engine-patch/

dar