straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

implement (cross) reference model by name in KeyListProperty #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a feature request.

Got two cross-reference classes: Group and Person

If it were Django, according to docs
(http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey):
If you need to create a relationship on a model that has not yet been
defined, you can use the name of the model, rather than the model object itself

But in GAE's ReferenceProperty this is not an option. Having
KeyListProperty, however, I think I could allow the following:

class Group(db.Model):
    instructors = KeyListProperty('Person')

class Person(db.Model):
    base_group = ReferenceProperty(Group)

alas, reference by class name does not work for KeyListProperty. I should
confess that I was not able to figure out how the reference by name works
in django.db.models.fields.related.ForeingKey, so I failed propose a patch.
Could you please implement in the KeyListProperty a reference by name for
the class in the same models.py module?

P.S. BTW I see two workarounds: first is

class Base(polymodel.Polymodel):
    pass

class Group(db.Model):
    instructors = KeyListProperty(Base)

class Person(Base):
    base_group = ReferenceProperty(Group)

and the second:

class Group(db.Model):
    pass

class Person(db.Model):
    pass

class Norm(db.Model):
    group = ReferenceProperty(Group)
    person = ReferenceProperty(Person)

Both are not quite elegant.

Original issue reported on code.google.com by A.A.Vasi...@gmail.com on 11 Feb 2009 at 5:18

GoogleCodeExporter commented 9 years ago
Please report this to App Engine. I don't intend to extensively modify Google's 
Model
beyond fixing bugs and making it work with Django, at all. Otherwise we risk 
breaking
everything one day. Another solution is that you contribute to or sponsor a 
real port
of Django's Model:
http://groups.google.com/group/django-developers/browse_thread/thread/516626d18f
6f3fca

Original comment by wkornew...@gmail.com on 11 Feb 2009 at 5:34

GoogleCodeExporter commented 9 years ago
Thanks for answer. I read the discussion and hope that your initiative will 
found
developer's support. Anyway, even current results of your work are astonishing.

Original comment by A.A.Vasi...@gmail.com on 12 Feb 2009 at 4:59