Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New branch to fix TAL default handling #853

Merged
merged 11 commits into from
Jun 26, 2020
Merged

New branch to fix TAL default handling #853

merged 11 commits into from
Jun 26, 2020

Conversation

dataflake
Copy link
Member

Branch off of 4.x that now pins Chameleon version 3.7.4 as the starting point for a final default keyword handling fix.

@d-maurer
Copy link
Contributor

@malthe This chameleon version does not work: it puts the correct __default definition into the render functions __globals__ but inside the functions code, it does not use this global object but the string '__default'. Here is an extract of the disassembly:

140         346 LOAD_CONST              18 ('__default')
            349 STORE_FAST              18 (__value)

141         352 LOAD_FAST               22 (__expression)
            355 LOAD_FAST               18 (__value)
            358 COMPARE_OP               8 (is)
            361 STORE_FAST              23 (__condition)

The LOAD_CONST 18 ('__default') should be LOAD_GLOBAL (__default).

@malthe
Copy link
Contributor

malthe commented Jun 18, 2020

Let me review some of the test cases.

@d-maurer
Copy link
Contributor

d-maurer commented Jun 18, 2020 via email

@dataflake
Copy link
Member Author

@d-maurer In malthe/chameleon#317 (comment) you said that all tests for Products.PageTemplates are passing now. In a local sandbox on this branch issue_846_2 that pulls in Chameleon 3.8.0 I am still seeing failures. Do you work off a branch with unmerged local changes? Examples:

<p tal:define="foo string:"
   tal:content="python: foo or default">Default in Python expression</p>
<p tal:content="context/I_Fail|default">Default in Path expression</p>

is turned into this:

<p>__default__</p>
<p>__default__</p>

Also, <p tal:attributes="disabled python:True and default or 'disabled'"></p> results in <p disabled="disabled"></p> instead of <p></p>.

@d-maurer
Copy link
Contributor

d-maurer commented Jun 26, 2020 via email

@dataflake dataflake marked this pull request as ready for review June 26, 2020 08:36
@dataflake
Copy link
Member Author

With one linting fix and an added test after seeing malthe/chameleon#318 this looks ready for merging once Travis CI has run though. @d-maurer Do you agree?

@d-maurer
Copy link
Contributor

d-maurer commented Jun 26, 2020 via email

@dataflake dataflake merged commit c36defd into 4.x Jun 26, 2020
@dataflake dataflake deleted the issue_846_2 branch June 26, 2020 10:18
@dataflake
Copy link
Member Author

Thanks Dieter!

dataflake added a commit that referenced this pull request Jun 26, 2020
* - new branch to fix TAL default handling

* adapt to changed default handling of `chameleon==3.7.4` (does not yet work

* Python 3 compatibility

* - use Chameleon 3.8

* Adaptations for `chameleon>=3.8`

* - fix lint issue

* - add test for straight boolean after seeing malthe/chameleon#318

* - comment change [ci skip]

Co-authored-by: dieter <dieter@handshake.de>
@malthe
Copy link
Contributor

malthe commented Jun 26, 2020

Thanks for the patience guys – this was a difficult one to crack.

@dataflake
Copy link
Member Author

Thanks for all the help @malthe. There wasn't much pressure from others in the community to fix it, surprisingly. I guess not many people use the default keyword. I only noticed it because an application I help maintain misbehaved.

@mauritsvanrees
Copy link
Member

For the record, I did not see much code in core Plone that uses the default keyword. I did not even know this option existed. I think I saw one or two in Products.Archetypes, but I could not trigger an error with that, using versions where it was apparently broken.
But I am happy and relieved that it got resolved, and everything released. Thanks @malthe @d-maurer and @dataflake !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants