django - simplelazyobject breaks template filter -


Here is a template filter that is working without problems recently, before I update the Django source Before:

Import from pm_core.models PMUser @ register.philter def can_manage_market (user, market): if not (user, PMUser): return wrong return user.can_manage_market (market)

The filter has always begun to return to false. The problem is that instead of PUuser (a sub-class of the user), 'user' instance is 'Simal Lasji Object'. It was discovered on the Internet and brought to me on ticket # 12049, which indicates that it can be a similar bug (though, patches have been provided, unfortunately there is no way out).

I appreciate any information on this simplelazyobject that I do not know about the first

ps I posted this question also on the Digengo-User Group, but right now No answer has been received till As Peter says, this change is 11626 because of

. The reason is that now you are giving a cover instead of the object, because that cover is laziness. It is designed that if you do not actually do anything with it, it never receives the underlying user object - this cache is for optimization reasons since you are doing all kinds of investigation. , And does not evaluate the object, it is a lazy object and fails in your exam.

Rather than checking that the object is of a particular type, which is not pythonic anyway, you should check that your object has the methods or properties that you want to call. The cover should be crossed transparently, and your test will now be successful. Try

 : Return the user can_manage_market (market) except AttributeError: incorrect return  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -