Frank,
Thanks for the tip and for debugging that issue. I was completely lost. 
However, when I try your workaround, despite that my IDE can see that os 
has a function called putenv, for some reason App Engine does not. I get 
this error trying it that way:
 

os.putenv(datastore._ENV_KEY, "")
AttributeError: 'module' object has no attribute 'putenv'

 

Any idea on how to mitigate this? I have imported os but this is extremely 
strange. I'm on 2.7.3 and am able to use putenv in my own interpreter.

 

Thanks,

Richard


On Tuesday, August 21, 2012 10:25:30 PM UTC-7, Frank VanZile wrote:

> Here is my stack of the same problem.
>
>   File "C:\work\twist.2\server\backend\lib\images\image_helper.py", line 
> 18, in
> get_serving_url
>     return images.get_serving_url(image_blob_key)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\imag
> es\__init__.py", line 1793, in get_serving_url
>     return rpc.get_result()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\apip
> roxy_stub_map.py", line 604, in get_result
>     return self.__get_result_hook(self)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\imag
> es\__init__.py", line 1889, in get_serving_url_hook
>     rpc.check_success()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\apip
> roxy_stub_map.py", line 570, in check_success
>     self.__rpc.CheckSuccess()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\apip
> roxy_rpc.py", line 156, in _WaitImpl
>     self.request, self.response)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\apip
> roxy_stub.py", line 160, in MakeSyncCall
>     method(request, response)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\imag
> es\images_stub.py", line 296, in _Dynamic_GetUrlBase
>     datastore.Put(entity_info)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\data
> store.py", line 579, in Put
>     return PutAsync(entities, **kwargs).get_result()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\data
> store.py", line 556, in PutAsync
>     return _GetConnection().async_put(config, entities, local_extra_hook)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\datastor
> e\datastore_rpc.py", line 1534, in async_put
>     pbs = [self.__adapter.entity_to_pb(entity) for entity in entities]
>   File "C:\work\twist.2\server\backend\lib\external\ndb\model.py", line 
> 561, in
> entity_to_pb
>     pb = ent._to_pb()
> AttributeError: 'Entity' object has no attribute '_to_pb'
>
>
> i have ran into the same type of problem before.  the problem is the sdk 
> tries to cache the datastore_rpc connection.  see _GetConnection in 
> datastore.py
>
> def _GetConnection():
>   """Retrieve a datastore connection local to the thread."""
>
>   connection = None
>   if os.getenv(_ENV_KEY):
>     try:
>       connection = _thread_local.connection
>     except AttributeError:
>       pass
>   if connection is None:
>     connection = datastore_rpc.Connection(adapter=_adapter)
>     _SetConnection(connection)
>   return connection
>
> an incorrect datastore connection is being used for that call from this 
> connection cache.
>
> you can hack around it by adding this before the get_serving_url call.  
>
>             import os
>             from google.appengine.api import datastore
>             os.environ[datastore._ENV_KEY] = ''
>             os.putenv(datastore._ENV_KEY, '')
>             datastore._thread_local.connection = None
>
>
>
> On Tuesday, August 21, 2012 6:59:25 PM UTC-7, Takashi Matsuo (Google) 
> wrote:
>>
>>
>> Can you show me the whole stacktrace?
>> What is your app-id?
>>
>>
>> On Wed, Aug 22, 2012 at 7:14 AM, Richard Arrano <[email protected]>wrote:
>>
>>> Hello,
>>> I have a function that takes a user image upload and saves both the blob 
>>> key and a serving URL. After upgrading to 1.7.1, I now get an error trying 
>>> to save the updated entity to the datastore. The property pictures is an 
>>> ndb.StringProperty(repeated=True, indexed=False) and the property 
>>> picture_keys is an ndb.BlobKeyProperty(repeated=True) where the former will 
>>> hold the image serving URLs for the blob keys in the latter. In a 
>>> transaction, I read the uploaded file and generate a serving URL and save 
>>> the blob key and the serving URL. This worked last night before upgrading 
>>> to 1.7.1, but now I get an error on:
>>>  
>>>
>>>     article.pictures.append(get_serving_url(blob_info.key()))
>>>
>>>  
>>>
>>> AttributeError: 'Entity' object has no attribute '_to_pb'
>>>  
>>> Without fail on the development server, this line now generates that 
>>> error. Was there a change to the API and I should be doing something 
>>> differently? If so, what?
>>>  
>>> Thanks,
>>> Richard
>>>  
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Google App Engine" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/google-appengine/-/Bg4zC34iDOcJ.
>>> 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.
>>>
>>
>>
>>
>> -- 
>> Takashi Matsuo | Developers Advocate | [email protected]
>>
>>  

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/Zd6UNvGnY5YJ.
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