Weird, I was _just_ discussing this with a colleague at our office.

If you want a really hard check and are willing to pay some overhead
for it, AND you can't use the key_name approach that Robert suggests
which is the best solution, you can use a technique like this:
http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/

We've typically used this for a User entity where we need a unique
email address, but we don't want to drive the email address into the
key_name because email addresses change.

j

On Jul 20, 9:42 pm, cwaldbieser <[email protected]> wrote:
> I have 3 models:  A customer account, a service, and a model that
> represents a customer's subscription to the service.  The subscription
> is essentially:
>
> class Subscription(db.Model):
>   customer = db.ReferenceProperty(Customer)
>   service = db.ReferenceProperty(Service)
>
> I have a user interface that allows creating or cancelling a
> customer's subscription.  I want to be able to create a subscription
> only if an existing subscription does not already exist.  I thought
> that a transaction might be the key, but I can't do a query in
> transaction unless it is by key or an ancestor query.  So I am not
> sure what to do.
>
> Any thoughts?
>
> Thanks,
> Carl

-- 
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.

Reply via email to