The only easy way to set parent= is to bypass the DAL, because you do
not get easy access to the google key for the entity that is needed to
set a parent=.

To use Google specific stuff, you can use the gae_db.Model directly.

To effectively use Google logins, you *must* use gae_db.UserProperty
(users can change the email associated with their google account, so
it is the only way to reliably/uniquely identify a user).

For example, I use this for Google users on http://ru.ly:

class GaeUsers(gae_db.Model):
  user = gae_db.UserProperty()
  created_at = gae_db.DateTimeProperty(auto_now_add=True)

def get_current_user():
  user = gae_users.get_current_user()
  local_user = None
  if user:
    local_user = GaeUsers.all().filter('user =',user).get()
    if local_user is None:
      local_user = GaeUsers(user=user)
      local_user.put()
  return local_user


Robin


On Feb 20, 11:13 am, "Sebastian E. Ovide" <[email protected]>
wrote:
> On Fri, Feb 20, 2009 at 12:36 AM, Robin B <[email protected]> wrote:
>
> > I have the transactions working, but it is not fully compatible with
> > web2py DAL, but it could be soon ( needs type coercion, db.table.ALL,
> > etc)  Also in web2py, you cannot set the entity group when inserting,
> > so transactions will only involve 1 record.  (eg atomically read/
> > modify/write a counter in a transaction)
>
> that is great, at least we can do counters !...
>
> and how could we specify a parent in a antity with web2py ? is there any
> simple way ?
>
> thanks !
>
>
>
> > If you needed transactions immediately, you could do this:
>
> > from google.appengine.ext import gdb
>
> > def txn():
> >  post = db.posts[post_id]
> >  post.update_record(title='foo')
> >  return post
>
> > post = gdb.run_in_transaction(txn)
>
> > On a side note, I have batch operations working too. But I recently
> > read that batch operations are just O(n), which unfortunately means no
> > joins or efficient batch operations will be possible for now, but I
> > have not benchmarked it on the real google datastore to know for sure.
>
> > Robin
>
> > On Feb 19, 3:31 pm, sebastian <[email protected]> wrote:
> > > Hi All,
>
> > > is there any schedule for the GAE transactions/entity groups ?
>
> > > if not, how would it be the best way (web2py upgrades compatible !) to
> > > use entity groups and transaction with web2py ?
>
> > > thanks
>
> > > On Jan 19, 2:59 pm, Robin B <[email protected]> wrote:
>
> > > > > Groups under the DAL to be a single record. Since Big Table
> > > > > transactions are limited to one Entity Group pertransaction, this
> > > > > means that we are limited to one record pertransaction. Right?
>
> > > > You have it right.
>
> > > > > In the example above, 'count' is just an example of some arbitrary
> > > > > column in the record, right? Can I have multiple assignments? Can I
> > > > > mix lambda and non-lambda assignments? E.g.:
>
> > > > >     row.update_record(count=lambda r: r.count+1, vote_score=lambda r:
> > > > > calculate_vote_score(), preference='blue')
>
> > > > Yes, you would be able to mix lamdas/functions and values.
>
> > > > On the subject of passing lamdas as attributes, the field.default=
> > > > should also recognize any lambda/callable and call it on demand:
>
> > > > def uuid():
> > > >   import uuid
> > > >   return uuid.uuid4()
>
> > > > db.table.created_at.default=t2.now
> > > > db.table.uuid.default=uuid
>
> > > > Robin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to