{"id":197962,"date":"2013-10-17T15:32:04","date_gmt":"2013-10-17T11:32:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=197962"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=197962","title":{"rendered":"<span class=\"post_title\">\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e Pony ORM \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 Django<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/188842\/\">\u043f\u043e\u0441\u0442<\/a> \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b <a href=\"http:\/\/www.ponyorm.com\/\">Pony ORM<\/a>, \u043f\u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0439 \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 Django ORM \u0438 SQLAlchemy.<\/p>\n<p>  \u0412\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u044c \u043d\u0435\u043e\u0440\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0438 \u043e\u0437\u0430\u0431\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c Pony ORM \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0427\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0441\u043c \u043f\u043e\u0434\u043a\u0430\u0442\u043e\u043c.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0421\u043e\u0431\u043b\u0430\u0437\u043d\u044b<\/h4>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043d\u043e\u0432\u043e. \u042d\u0442\u043e\u0442 \u0441\u043e\u0431\u043b\u0430\u0437\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0438\u0442\u0430\u0435\u0442 \u043d\u0430\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0432\u0448\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043a\u043e\u0440\u043d\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043e\u0431\u044a\u0435\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u0430 \u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f Django \u0441\u0442\u0430\u0432\u044f\u0442 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0443\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438 \u0436\u0438\u0440\u043d\u044b\u0439 \u043a\u0440\u0435\u0441\u0442.<\/p>\n<h4>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430<\/h4>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b Django ORM, \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/Deepwalker\/aldjemy\">Aldjemy<\/a>. \u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043d\u0430\u0432\u0435\u0441\u043a\u0430 \u043d\u0430\u0434 Django ORM, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Django \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 SQLAlchemy. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043e\u0441\u043d\u043e\u0432\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u2014 \u0432\u0441\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 Django), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SQLAlchemy \u0438\u043c\u0435\u043d\u043d\u043e \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u0434\u0435\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <s>\u0438 \u0441\u043b\u0438\u0437\u0430\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430<\/s>, \u044f \u0441\u0434\u0435\u043b\u0430\u043b <a href=\"https:\/\/github.com\/nnseva\/djony\">\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<\/a> \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u043a\u0438 Pony ORM \u043a Django ORM, \u043d\u0430\u0437\u0432\u0430\u0432 \u0435\u0435 djony (DJango pONY).<\/p>\n<h4>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u044d\u043a\u0441\u043a\u0443\u0440\u0441<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 djony \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 djony \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>pip install git+git:\/\/github.com\/nnseva\/djony.git@master#egg=djony<\/code>), \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c djony \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 settings.py. \u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e djony <i>\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e<\/i> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c <i>\u0441\u0430\u043c\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c<\/i> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Django (\u0438\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u2014 \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432) \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 `p` (\u043e\u0442 \u0441\u043b\u043e\u0432\u0430 pony). \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c Pony ORM. \u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 <a href=\"http:\/\/doc.ponyorm.com\/\">\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> Pony, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u0412\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0434\u0443\u043b\u044c orm, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f pony (<code>from pony import orm<\/code>). \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c djony.orm, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u044f pony.orm, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u043b\u044f djony \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Pony ORM \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Pony ORM).<\/p>\n<h4>\u0422\u0435\u0441\u0442<\/h4>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0440\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0414\u043b\u044f Django \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e User.has_perm. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043b\u044f Pony ORM \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438::<\/p>\n<p>  def has_perm(user,perm):<br \/>   if not user.is_active:<br \/>   return False<br \/>   app_label,codename = perm.split(&#8216;.&#8217;)<br \/>   for p in orm.select(<br \/>   p for p in Permission.p<br \/>   if<br \/>   (user in p.user_set or user in p.group_set.user_set) and<br \/>   p.codename == codename and<br \/>   p.content_type.app_label == app_label<br \/>   ):<br \/>   return True<br \/>   return False<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u0431\u0430\u0437\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u043e 1000 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0440\u043e\u043b\u044c \u0431\u0430\u043b\u043b\u0430\u0441\u0442\u0430).<\/p>\n<p>  &gt;&gt;&gt; import test_pony<br \/>   &gt;&gt;&gt; import test_django<br \/>   &gt;&gt;&gt; test_django.test_django()<br \/>   check user permissions: django req\/seq: 170.308759221 req time (ms): 5.8716886<br \/>   &gt;&gt;&gt; test_pony.test_pony()<br \/>   check user permissions: pony req\/seq: 729.517146462 req time (ms): 1.3707697<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 4 \u0440\u0430\u0437\u0430. \u041e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e!<\/p>\n<h4>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432.<\/h4>\n<h5>test_django.py<\/h5>\n<pre><code class=\"python\">import datetime  from django.contrib.auth.models import User  def test_django():     t1 = datetime.datetime.now()     for i in range(10000):         test()     t2 = datetime.datetime.now()     print &quot;check user permissions: django req\/seq:&quot;,10000\/(t2-t1).total_seconds(),'req time (ms):',(t2-t1).total_seconds()\/10.  def test():     user = User.objects.get(username='testuser')     return user.has_perm('auth.add_user') <\/code><\/pre>\n<h5>test_pony.py<\/h5>\n<pre><code class=\"python\">import datetime  from django.contrib.auth.models import User, Permission  def test_pony():     t1 = datetime.datetime.now()     for i in range(10000):         test()     t2 = datetime.datetime.now()     print &quot;check user permissions: pony req\/seq:&quot;,10000\/(t2-t1).total_seconds(),'req time (ms):',(t2-t1).total_seconds()\/10.  from djony import orm  @orm.db_session def test():     user = User.p.get(username='testuser')     return has_perm(user,'auth.add_user')  def has_perm(user,perm):     if not user.is_active:         return False     app_label,codename = perm.split('.')     for p in orm.select(             p for p in Permission.p             if                 (user in p.user_set or user in p.group_set.user_set) and                 p.codename == codename and                 p.content_type.app_label == app_label     ):         return True     return False <\/code><\/pre>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197962\/\"> http:\/\/habrahabr.ru\/post\/197962\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/188842\/\">\u043f\u043e\u0441\u0442<\/a> \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b <a href=\"http:\/\/www.ponyorm.com\/\">Pony ORM<\/a>, \u043f\u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0439 \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 Django ORM \u0438 SQLAlchemy.<\/p>\n<p>  \u0412\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u044c \u043d\u0435\u043e\u0440\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0438 \u043e\u0437\u0430\u0431\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c Pony ORM \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0427\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0441\u043c \u043f\u043e\u0434\u043a\u0430\u0442\u043e\u043c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-197962","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=197962"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197962\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=197962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=197962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=197962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}