Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13373 closed (fixed)

IF tag no longer short-circuits

Reported by: anonymous 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: UI/UX:

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.

Attachments (0)

Change History (7)

comment:1 Changed 4 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 4 years ago by Alex

I removed your email Jerry.

comment:3 Changed 4 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 4 years ago by anonymous

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 Changed 4 years ago by Alex

  • Reporter jerry@… deleted

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 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.