Hi Folks, I'm building a relatively modest iPhone/iPad MMO and plan to use GAE for the backend. There seem to be some features I consider critical missing from the Data Store, but it's quite possible that there are alternatives and I'm simply missing them. I planned to create a Request for Enhancement thread, but I'd appreciate some input from GAE vets first.
I extended db.Model into my own model class in which I am trying to correct these "omissions". I added a 'create' function specifically for inserting new objects into the Data Store. Some items that appear to be missing: 1) Unique Keys The lack of any way to specify unique keys for fields outside of the key_name is well documented. I borrowed and modified the UniqueConstraint class from user Blixt in this <a href="http:// stackoverflow.com/questions/1185628/how-do-i-define-a-unique-property- for-a-model-in-google-app-engine">thread</a>. This works great in my creation() method, but it does nothing for attempts to update the field at a later date. I thought about moving the check into init(), which would be better but then I have to figure out how to filter out UniqueKey generated keys which originally came from this object when it was stored previously. Doable, but messy and a bit slow. It does nothing for updates of a unique field in an instance. Again, not knowing which keys were generated from this object initially makes the tasks of deleting no longer needed UniqueKeys messy. I'm also unsure how best to kick off the check. Ideally, I'd like to check any time the value of a field involved in a unique key is changed. How do I get at the Properties get and set methods to override them? I can live with making unique fields immutable, but there currently no way I can find to do that, which leads me too... 2) Immutable Fields Is there a way to specify that a Property cannot be changed after creation? If I knew how to refer to the set() method for property values I could simply override them to disallow updates. Is there a better way? 3) db.DictProperty I really wish there were a way to specify that the db.ListProperty should use a dict structure, with user specified names (i.e. key_names) for each member. I have Character objects which include numerous references to other db.Model objects in them. The referenced instances are grouped by classes which are handled quite differently. The obvious implementation is to use on db.ListProperty(db.Key) for each class, but I lose any ability to know which key belongs to which instance without doing a query. I'd really like to retain the convenience of being able to refer to a stat via model_instance.stats.stat_name.value, but by this method it has to be model_instance.stats.stat_instance_key.value. Unless I maintain a separate map of stat_instance_key to stat_name, I have to run a query to get the correct stat_instance_key each time I want to reference a stat. Inefficient and ugly, IMO. Currently, I just created a dict attribute called stats which points to all of the Stat instances and refers to them by name. I can populate the dict in init() with Stat instances that are children of the Character, and I can store each Stat instance in the character's put(). Is there a better way to do this? If you've made it this far, thanks for your attention. I started to post code in this message, but it's too long as it is. -- 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.
