Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Please bring Model._get_kind() to public Model.get_kind() #222

Closed
GoogleCodeExporter opened this issue Jun 10, 2015 · 3 comments
Closed

Comments

@GoogleCodeExporter
Copy link

According to comment:
"Cezary Wagner Could we bring Model._get_kind() to public i.e. Model.get_kind() 
need to construct keys I think so.

Guido van Rossum It is public. It only starts with underscore so that it 
doesn't prevent you from having a property named 'get_kind'. Please use the 
tracker, or the mailing list for suggestions, not the cheat sheet."

I mean public all methods methodName, protected for internal use _methodName, 
private for class use __methodName - so I should never use _* or __* since it 
reserved by API developers.

Sure I could write class theBest.Model(ndb.Model) to extend but think that 
get_kind() should be in ndb.Model and all ndb._* should be not used to give you 
more freedom and make me more safe.


Original issue reported on code.google.com by Cezary.W...@gmail.com on 5 Nov 2012 at 7:33

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant