Loading ...
Sorry, an error occurred while loading the content.

4884[Cheetahtemplate-discuss] NameMapper issues with Google App Engine db.Model objects

Expand Messages
  • Chad George
    Aug 14, 2010
    • 0 Attachment
      In AppEngine, db.Model objects unfortunately implement a "has_key()"
      method that checks if a model instance has had a key assigned to it
      yet.

      This causes NameMapper.py to determine that it should use dictionary
      style access instead of getattr().

      I think there are two possible solutions:
      1. use hasattr(obj, "keys") instead of hasattr(obj, "has_key")
      2. try to use hasattr()/getattr() ... before trying dictionary access

      I tested #1 and it seems to work...but I'm too new to Cheetah to know
      if there are unintended consequences

      For #2 the biggest issue I see is in _valueForName() ... you
      definitely don't want to hit the exception on every access to a
      dictionary, so you'd need another call to hasattr() ... which
      presumably was just done before getting to _valueForName() in the
      first place.

      Probably not a big deal either way. I'm not sure if there was a
      pre-existing design decision to try dictionary access before attribute
      access.

      - Chad

      ------------------------------------------------------------------------------
      This SF.net email is sponsored by

      Make an app they can't live without
      Enter the BlackBerry Developer Challenge
      http://p.sf.net/sfu/RIM-dev2dev
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Show all 3 messages in this topic