Because of our new software release, there are a few applications
that might be experiencing problems where they have overridden
Model.__init__ or any of its sub-classes.  The problem is most likely
because of the way these sub-classes have been handing the _app and
_from_entity parameters.  The App Engine team is already in the
process of fixing this so that existing applications that have this
problem will be automatically fixed.

  For those who are interested in fixing their applications right
away, please allow me to explain what the problem most likely is and
what you can do to fix it.  The advice I am going to provide is
applicable to all code and is how it was intended to be used (we
recognize that developers will not always use things as intended, and
we endeavor to respect that;).

  All function and constructor parameters that begin with '_' are
meant to be "protected" and undocumented.  They are not meant to be
used or referred to be application developers.  We use them when one
part of the API needs to communicate information with another part but
we don't want it to be considered part of the actual API.
Specifically, the Model.__init__ method has the parameters _app and
_from_entity that must be correctly set by any Model sub-class to
function properly.

  Here is the SDK 1.2.5 signature including the protected parameters:

    def __init__(
        self,
        parent=None,
        key_name=None,
        _app=None,
        _from_entity=False,
        **kwds):
      ...

  A program that is having problem with the 1.2.6 version of the Model
class might have defined a Model sub-class as:

  class MyModel(db.Model):
    def __init__(
        self,
        parent=None,
        key_name=None,
        _app=None,
        _from_entity=False,
        **kwds):
      ... Do important stuff ...
      super(MyModel, self).__init__(
          parent, key_name, _app, _from_entity, **kwds)

  The problem this application will encounter is that a new positional
parameter 'key' was inserted between key_name and _app because we
(mistakenly) believed that these protected attributes would not be
used.  This means that when instantiating MyModel instances,
particularly during the Datastore 'get' process, MyModel is assigning
the '_app' value to the 'key' attribute, assigning '_from_entity' to
'_app' and overriding '_from_entity' with its default value 'False'.

  In Python, positional parameters and keyword parameters can be used
fairly interchangeably.  If a key-word parameter dictionary is passed
where a positional is expected, the value in the dictionary will be
assigned to the correct positional parameter.  The better way to have
written the MyModel constructor would have been:

  class MyModel(db.Model):
    def __init__(
        self,
        parent=None,
        key_name=None,
        **kwds):
      ... Do important stuff ...
      super(MyModel, self).__init__(
          parent, key_name, **kwds)

  One can just leave out all references to all protected parameters
and rely on them being transmitted via 'kwds'.



  Again, the App Engine team apologize for the inconvenience this has
caused and we are working to remedy it as soon as possible.

  - Rafe Kaplan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to