views:

187

answers:

1

I have 6000 data of district, subdistrict. I need to represent this on dependent dropdown. The datamodel is for example;

class Location(db.Model):
    location_name = db.StringProperty()
    //location_parent = db.IntegerProperty()
    location_parent = db.ReferenceProperty() //

location_parent is reference to key() or id()? Still cannot decide which one is good. When i use key() as reference then using JSON to create jquery dependent drop down. My page loading/query and rendering time the dropdown is quite slow? Can i use key().id() as drop down option value to lighten up the page load? Any better solution for this parent/child reference for the drop down? For example: for the district record/entities the location-parent is null, for sub district record location_name will contain reference to parent district record.

Other issue is to reverse geocoding the location to store or display geoPoint (lat,long)? Is google MAP API always find the exact lat,long of specific region boundaries or any error checking for the result?

A: 

You've got several different questions there, but your primary schema is probably insufficient. You shouldn't use string or integer properties to store a reference to another datastore entity. This is what db.ReferenceProperty is for. Once you've stored a proper reference to another datastore entity, you can easily refer to the entity's key(), key().name(), or key().id(), as well as look up the entity using .get(), .get_by_key_name(), and .get_by_id().

protobuf
I try modified my scheme to your answer, this is might be a internal reference as documented here: http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ReferenceProperty? So use ReferenceProperty or SelfReferenceProperty?
Ivan Slaughter