I have a MyModel model (extending Google db.Model) and I want to track the number of models created.
I think the code from the Google I / O conversation on Sharding Counters is not bad, so I use this. But I'm not sure where I should call increment when creating new code. (I use Django, and I kept the familiar models.py models, views.py, etc. For project applications.)
There are a couple of possibilities that seem to come to mind where you can put incremental code:
Overload Model.put () so that it increments the counter when the model was first saved, and similarly overload Model.delete () to decrease the counter
Attach some kind of listener to the save / delete and check that the save has a new model (does GAE have such listeners?)
Put the counter increment code in a function in view.py that creates / removes models
I would be very grateful for suggestions and thoughts on how to do this best (and the pros / cons of each option).
Thanks for reading.
Best, Brian
( "- " ), "App Engine Fan" ( " " ) ( : " ", "" App Engine).
"", , , - , "", (2), , "" "" ( , ), ( , "" , , put - , , ).
put
Source: https://habr.com/ru/post/1716997/More articles:Высота 100% при SPAN с несколькими столбцами - htmlPython smtp gmail authentication error (sending email via gmail smtp server) - pythonConvert image format from .bmp to other image formats in vb.net - vb.netUITableView Threats: keep getting this runtime error with unrecognized selector - iphoneLucene Index Optimization - luceneAm I doing it wrong? SVN merge changes from trunk to git branch. Using merge --squash - gitHow to make the tooltip move with the mouse? - c #Find every execution execution count in Java - javaWhat is the most cross-platform friendly coding language? - programming-languages | fooobar.comIs there a way to install Delphi 2010 on Windows 2000? - delphiAll Articles