datastore exception handling examples

2 views
Skip to first unread message

David

unread,
Oct 10, 2008, 6:07:18 AM10/10/08
to Google App Engine

Hi,

Are there any articles or sample code, showing how to robustly handle
datastore exceptions, for production standard code?

Being a fresh python programmer, I find the api docs a bit light in
this area and some concrete examples of not only what exceptions I
should be handling and best practicies of what to do when exceptions
occer to keep my app running would be very useful.

David.




Marzia Niccolai

unread,
Oct 10, 2008, 12:25:04 PM10/10/08
to google-a...@googlegroups.com
Hi David,

Currently we don't have any articles covering this subject, but thanks for the suggestion!  We would like to expand a lot of the articles offered, including on our datastore which seems to be a hot topic.

I would suggest checking out some of our samples in the meantime:
http://code.google.com/p/google-app-engine-samples

-Marzia

Bill

unread,
Oct 10, 2008, 1:24:55 PM10/10/08
to Google App Engine
> Are there any articles or sample code, showing how to robustly handle
> datastore exceptions, for production standard code?

David,

I recently modified my memcached, sharded counter system to handle
various datastore exceptions:
http://billkatz.com/2008/10/Fault-tolerant-counters-for-App-Engine
You can look at or copy the open source code referenced in that
article.

It also depends on your app requirements. The above counter shouldn't
be used for banking, for example, because if there are simultaneous
memcache and datastore errors, you lose pending increments. But if
you want something that minimizes the impact of exceptions for things
like votes, it's a reasonable approach.

-Bill

David

unread,
Oct 11, 2008, 8:45:05 AM10/11/08
to Google App Engine

@Marzia Niccolai:

thanks for taking the time to reply, I look forward to the articles
when they come in due course.

In the mean time I'll check out the example code and see what I can
incorporate >_<

@Bill:

thanks, ill take a look.

izaac

unread,
Oct 17, 2008, 1:50:59 AM10/17/08
to Google App Engine
I got this simple method it's not finished yet but at least is using
the exceptions package from db

def post(self):

data = GuestBookForm(data=self.request.POST)
if data.is_valid():
# what's going on here, GuestBook not callable ?

user_sign = data.save(commit=False)
user_sign.user= users.get_current_user()
from google.appengine.ext.db import BadValueError
try:
user_sign.save()
except BadValueError, e:
logging.error("There was an error saving comment: %s\n
Error: %s" % (self.request.get('text'), e))

self.redirect('/guestbook')

hope it helps you

On Oct 11, 5:45 am, David <david.wil...@entertainmentcloud.com> wrote:
> @Marzia Niccolai:
>
> thanks for taking the time to reply, I look forward to the articles
> when they come in due course.
>
> In the mean time I'll check out the example code and see what I can
> incorporate >_<
>
> @Bill:
>
> thanks, ill take a look.
>
> On Oct 10, 6:24 pm, Bill <billk...@gmail.com> wrote:
>
>
>
> > > Are there any articles or sample code, showing how to robustly handle
> > >datastoreexceptions, for production standard code?
>
> > David,
>
> > I recently modified my memcached, sharded counter system to handle
> > variousdatastoreexceptions:http://billkatz.com/2008/10/Fault-tolerant-counters-for-App-Engine
> > You can look at or copy the open source code referenced in that
> > article.
>
> > It also depends on your app requirements.  The above counter shouldn't
> > be used for banking, for example, because if there are simultaneous
> > memcache anddatastoreerrors, you lose pending increments.  But if
Reply all
Reply to author
Forward
0 new messages