Hi Tonny,
The SDK maintains a mapping between kind name and class. The kind name is
determined by calling kind() on your class, and defaults to the
(unqualified) name of the class. Because you have two classes with the same
name in different modules, they both have the same kind name.

The solution is to override kind() on one or both classes:

class MyModel(db.Model):
  @classmethod
  def kind(self):
    return 'some_other_value'


-Nick Johnson

On Wed, Oct 21, 2009 at 11:00 AM, Tonny <[email protected]> wrote:

>
> I ran into a fuzzy little thing today. I have to classes with the same
> name in different modules and both inherits from the Model class
> (let's call them x.A and y.A). I've created an instance of x.A (let's
> call it a1) and put it to the datastore, i then referenced the
> instance from an a.B entity (let's say b1). Now later fetching b1 and
> accessing the a1 through the reference property on b1 i get an object
> of the class y.A. How did this happen?
>
> Maybe i should put this to code:
>
> module x
> class A(db.Model):
>  name = db.StringProperty()
> class B(db.Model):
>  name = db.StringProperty
>  other = db.ReferenceProperty(reference_class=A)
>
> module y
> class A(db.Model):
>  name = db.StringProperty()
>
> # now let's create som entities
> a1 = x.A(name='Test')
> a1.put()
> b1 = x.B(name = 'Some Name', other=a1)
> b1.put()
> b2 = x.B.all().filter('name =', 'Some Name').get()
> a2 = b2.other # now this will be an instance of y.A, even though we've
> created no such instance or worked with module y in module a or the
> end code snippet.
>
> Magic, a bug, a feature?
>
> Regards
> Tonny
> >
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to