Again thanks for the suggestion.  Using the low-level interface works 
beautifully.  I had to read the source code of appengine to figure out 
wholly how to use it, but once that was done, I almost like the low-level 
interface more than the high-level one.  Entities behave like dictionaries 
(plus the key field), simple translations to/from protocol buffers, etc. 
The only weird thing is that for StringList properties, you cannot set the 
StringList field to []: you need to set it to None. 
This is kind of silly; they should have added an internal translation from 
[] to None to make this transparent. 
However, all my code works beautifully now, and I can get the benefits of 
expando models without even having to worry about having expando models! 

Luca

On Wednesday, July 10, 2013 9:03:07 AM UTC-7, Luca de Alfaro wrote:
>
> Thanks!  This is a great suggestion; it might be the only one that works 
> (short of giving up doing what I wanted to do in Python). 
> The interesting thing is that the Java side has no trouble at all reading 
> those entities. 
>
> Luca
>
> On Wednesday, July 10, 2013 12:11:51 AM UTC-7, timh wrote:
>>
>> And here is some example code for getting and putting raw entities - ie 
>> no model involved
>>
>> from google.appengine.api import datastorefrom google.appengine.api import 
>> datastore_errorsdef get_entities(keys):    rpc = 
>> datastore.GetRpcFromKwargs({})    keys, multiple = 
>> datastore.NormalizeAndTypeCheckKeys(keys)    entities = None    try:        
>> entities = datastore.Get(keys, rpc=rpc)    except 
>> datastore_errors.EntityNotFoundError:        assert not multiple            
>> return entitiesdef put_entities(entities):    rpc = 
>> datastore.GetRpcFromKwargs({})    keys = datastore.Put(entities, rpc=rpc)    
>> return keys
>>
>>
>> On Wednesday, July 10, 2013 3:09:56 PM UTC+8, timh wrote:
>>>
>>> Alternately make the property not required  (required=False), load the 
>>> entities set the value of the list to a [] and then rewrite, once you have 
>>> migrated all the entities you can then
>>> set the property to be required.
>>>
>>> You do need to think about model migration when changing classes 
>>> adding/removing or changing the types of properties.
>>>
>>> T
>>>
>>> On Wednesday, July 10, 2013 3:07:25 PM UTC+8, timh wrote:
>>>>
>>>> Have you tried setting the default value to [] as per that error ?
>>>>
>>>> If your model is blowing up you can always fetch the underlying data 
>>>> without a model, fix the data up and write it back.
>>>>
>>>> T
>>>>
>>>> On Wednesday, July 10, 2013 9:56:50 AM UTC+8, Luca de Alfaro wrote:
>>>>>
>>>>> This is pretty bad!
>>>>>
>>>>> As pointed out in 
>>>>> https://code.google.com/p/googleappengine/issues/detail?id=8962 , if 
>>>>> you add a StringListProperty to a model with existing entities in the 
>>>>> datastore, then you cannot read those entities any more! 
>>>>> Furthermore, in Java it is apparently possible to write entities with 
>>>>> null StringListProperty fields.  Those entities cannot then be read from 
>>>>> Python! 
>>>>> These are pretty big problems -- is there any solution? 
>>>>>
>>>>> Luca
>>>>>
>>>>> On Tuesday, March 23, 2010 5:57:17 AM UTC-7, Geoffrey Spear wrote:
>>>>>>
>>>>>> On Mar 22, 11:09 pm, dhruvbird <dhruvb...@gmail.com> wrote:
>>>>>> > Hello,
>>>>>> >   I have a model with a single attribute that is a 
>>>>>> StringListProperty.
>>>>>> > I get an error if I define it as such:
>>>>>> >
>>>>>> > class Test(db.Expando):
>>>>>> >     people = db.StringListProperty(required=False, indexed=True)
>>>>>> >
>>>>>> > However, on changing it to:
>>>>>> > class Test(db.Expando):
>>>>>> >     people = db.StringListProperty(required=True, indexed=True,
>>>>>> > default=[])
>>>>>> >
>>>>>> > It starts working. Any ideas why this is happening??
>>>>>>
>>>>>> ListPropertys are always required; you can't set their value to None.
>>>>>> If a particular entity has no values for the ListProperty, you need to
>>>>>> set it to the empty list.  (Note that you can still set a default
>>>>>> value of 'None', which magically uses an empty list, not None, as the
>>>>>> default value.)
>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to