Closed GoogleCodeExporter closed 9 years ago
NDB has a different rule for public vs. protected names. Many (but not all) of
the names starting with an underscore are actually considered public APIs,
because we don't want to reserve their method names as property names. We just
alias the more user-friendly underscore-less names for convenience (e.g. the
real method is _put(), and you should really use this, but we let you use put()
as long as you don't have a property named 'put').
The problem with doing the aliasing for _get_kind() is that you don't just use
_get_kind(), you must also override it if you want your class to have a custom
kind name (not equal to the class name). If I used the trick (which I use
elsewhere) to alias get_kind() to _get_kind(), users would expect that they
could override get_kind() and it would be hard to do the right thing regardless
of whether they are overriding get_kind() or _get_kind().
So please just get used to using _get_kind() for this purpose -- just like you
have to use _properties.
Original comment by guido@google.com
on 5 Nov 2012 at 8:07
[deleted comment]
Thanks for very fast explanation _get_kind and _properties and general rules of
API.
If chain is get_kind() and _get_kind() it is not matter what will be called
first - I mean that is not matter what will be overridden by developer but what
your API will use - am I wrong?
I think that feature allow make different name in datastore and in code - gives
simplicity of writing code and sacrifice readability - it is maybe need to
solve conflict when two define same named model if both not want use namespace.
It is complex since some _* are public and all [^_]* is public. - it need some
documentation since in GAE documentation it is not know. More clear is rule
that public is all [^_]* since _* should be reserved for internal use or clear
documentation listing all public starting with _*.
Try to find _get_kind on api function list - official documentation say
something about _get_kind but it is deeply hidden.
https://developers.google.com/appengine/docs/python/ndb/
Maybe there is need to add to python ___* for protected I just kidding but it
could to separate different needs like public, less public, protected, private.
Original comment by Cezary.W...@gmail.com
on 6 Nov 2012 at 7:24
Original issue reported on code.google.com by
Cezary.W...@gmail.com
on 5 Nov 2012 at 7:33