Try use properties

form = TagForm(request.POST or None, instance=tag)
errors = form.errors
if not errors:
  try:
    tag = form.save(commit=False)
    key_name = 'tag:%s' % tag.name
    saved_tag = models.Tag(key_name=key_name, **dict([(prop, getattr
(tag, prop)) for prop in Tag.properties()]))
    saved_tag.put()
    tag = saved_tag
  except ValueError, err:
    errors['__all__'] = unicode(err)


On Nov 17, 9:35 am, Andy Freeman <[EMAIL PROTECTED]> wrote:
> However, db.Model constructors take a documented key_name parameter.
>
> If entity is an instance of a db.Model subclass and 'bug
> %d'%entity.bug_id can be computed before db.Model.__init__ is called,
> that can be passed as the key_name parameter
>
> On Nov 16, 5:14 pm, djidjadji <[EMAIL PROTECTED]> wrote:
>
> > Using the object members that start with an '_', like _key_name, are
> > implementation dependent. They are not part of the GAE-API. The GAE
> > team are allowed to change them any time. You better try to find an
> > alternative method that will work in new versions of GAE, dev or
> > production.
>
> > 2008/11/9 Bad Dog <[EMAIL PROTECTED]>:
>
> > > Savraj,
>
> > > I ended up getting this to work:
> > >      data= bugForm(data=self.request.POST)
> > >      if data.is_valid():
> > >        # Save the data
> > >        entity=data.save(commit=False)
> > >        entity._key_name='bug%d'%entity.bug_id
> > >        entity.put()
>
> > > Note the _key_name  ( I found this by running the dev server in the
> > > debugger)
> > > I haven't tried deploying it yet though.
> > > -Bill
>
> > > On Nov 8, 1:07 pm, Savraj <[EMAIL PROTECTED]> wrote:
> > >> I have found a workaround -- but I would still like to know if this is
> > >> possible.
>
> > >> On Nov 6, 11:58 am, Savraj <[EMAIL PROTECTED]> wrote:
>
> > >> > Hey folks. I love app engine!
>
> > >> > Quick question -- I am using DjangoFormsto create an entity, as
> > >> > explained here:
>
> > >> >http://code.google.com/appengine/articles/djangoforms.html
>
> > >> > Can Isetthis new entity'skey_name?  It's not clear from the
> > >> > documentation.  I want tosetthe key name so I can quickly look up
> > >> > the entity in the future using Model.get_by_key_name.  Thanks in
> > >> > advance for your help!
>
> > >> > -savraj- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
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