Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#13373 closed (fixed)

IF tag no longer short-circuits

Reported by: (none) Owned by: nobody
Component: Template system Version: 1.2-beta
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It looks like {% if %} with OR or AND no longer short circuits under 1.2-beta-1.

class Page(models.Model):

...
def beTrue(self):

print "BEING TRUE"
return True

def beFalse(self):

print "BEING FALSE"
return False

{% if page.beTrue or page.beFalse %}

HELLO

{% endif %}

Under 1.1.1, using manage.py runserver, I will only see "BEING TRUE" printed for the above snippet. Under 1.2-beta-1, I see both BEING TRUE and BEING FALSE.

Similarly,

{% if page.beFalse and page.beTrue %}

HELLO

{% endif %}

will produce only "BEING FALSE" under 1.1.1, but both BEING FALSE and BEING TRUE under 1.2-beta-1.

Change History (7)

comment:1 by anonymous, 15 years ago

I didn't realize that the e-mail address it requests is displayed publicly. How can I remove that?

comment:2 by Alex Gaynor, 15 years ago

I removed your email Jerry.

comment:3 by Russell Keith-Magee, 15 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:4 by anonymous, 15 years ago

Thanks, Alex, but the problem has become recursive--my address now appears in your change history, where it's still public. How can I get rid of it completely?

comment:5 by Alex Gaynor, 15 years ago

Reporter: jerry@… removed

Unfortunately if I remove the change in the admin it restores the original field. Sorry this is beyond my knowledge at this point.

comment:6 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [13001]) Fixed #13373 -- Ensured that {% if %} statements will short circuit template logic and not evaluate clauses that don't require evaluation. Thanks to Jerry Stratton for the report.

comment:7 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top