Edgewall Software

Changes between Version 7 and Version 8 of GSoC2008


Ignore:
Timestamp:
Jun 30, 2008, 4:21:54 PM (16 years ago)
Author:
mkurczych
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GSoC2008

    v7 v8  
    2222
    2323{{{
    24 <a href="/edit/1" py:if="user.autorized()">[edit]</a>
     24<a href="/edit/1" py:if="user.authorized()">[edit]</a>
    2525<p>1111 11 11</p>
    26 <a href="/edit/2" py:if="user.autorized()">[edit]</a>
     26<a href="/edit/2" py:if="user.authorized()">[edit]</a>
    2727<p>222 22 22 2</p>
    28 <a href="/edit/3" py:if="user.autorized()">[edit]</a>
     28<a href="/edit/3" py:if="user.authorized()">[edit]</a>
    2929<p>333 33333 33 333</p>
    3030}}}
     
    4141}}}
    4242Now fragment depends only on variable "a", which can be only True or False, which gives optimization possibilities.
     43
     44Or it should be even vars = "a = bool(user.authorized())" to avoid things like that:
     45
     46{{{
     47>>> class Foo(object):
     48...     def __len__(self):
     49...             print "Sideeffect"
     50...             return 1
     51...
     52>>> f = Foo()
     53>>> if f:
     54...     print "Something"
     55...
     56Sideeffect
     57Something
     58}}}
     59
     60Foo can also change its internal state, and return different values in different ifs, which is not good. Only when variable is pure bool (a.__class__ is bool) we are safe. :-)