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

Fava Investor Won't Load (Windows-only issue?) #51

Open
floatingheads opened this issue Oct 1, 2020 · 9 comments
Open

Fava Investor Won't Load (Windows-only issue?) #51

floatingheads opened this issue Oct 1, 2020 · 9 comments

Comments

@floatingheads
Copy link

When I click the Investor link (using the included huge-example) in Fava I get a loading failed error, similar to issue #47 . I get a slew of flask and jinja errors, but the trigger is:

File "<unknown>", line 45, in template jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got '_'

@floatingheads
Copy link
Author

floatingheads commented Oct 1, 2020

I looked further into this. It appears to be something with the investor.html file. I can delete out the tax loss harvester module (narrowed it down to deleting out lines 43 through 56) and the asset_tree macro (just the print statements in the very first <ol>) and it will load up just fine. I'm not savvy in jinja2 though, so I'm not sure what is going on in the chunks of code in those 2 sections.

@floatingheads
Copy link
Author

In response to my last comment, after updating fava_investor and fiddling a little bit more, I only need to delete out a portion of the tax loss harvester, then everything works. I no longer need to mess with the asset_tree macro. Here is the portion of code that is causing the issue (lines 44-56):

<tr> <th data-sort="string">{{ _('Summary') }}</th> <th data-sort="string">{{ _('Val') }}</th> </tr> </thead> <tbody> {% for key, value in harvests[1].items() %} <tr> <td>{{ key }}</td> <td align="right">{{ value }}</td> </tr> {% endfor %} </tbody>

Here is the code after I deleted the problem portions, which allowed everything to work (albeit missing those pieces of the table):

<tr> </tr> </thead> <tbody> </tbody>

@redstreet
Copy link
Owner

Awesome, thanks for debugging this far. I'll look into this later in the week.

@redstreet
Copy link
Owner

I'm having trouble reproducing this. Would you mind sharing your software versions? I'm using:
beancount 2.3.2
fava 1.15
fava-investor 0.2.0
jinja2 2.11.2
debian 10.4

Thanks.

@floatingheads
Copy link
Author

floatingheads commented Oct 5, 2020

beancount 2.3.2
fava 1.15
fava-investor 0.2.0
flask 1.1.2 (I get flask errors also, so figured I'd include that as well)
jinja2 2.11.2
Windows 10

Also, I do have 95% functionality and just want to see this is great work. Thanks for putting it together. Definitely see myself using this a lot in the future.

@bradyemerson
Copy link

Can confirm this is a Windows issue. Same code works fine when I run in Docker Linux container

@floatingheads
Copy link
Author

Managed to figure a portion of this out. I guess for some reason (maybe Windows only as suggested by bradyemerson) jinja doesn't like reusing variable names. For lines 50-53, use new variable names (I used summary_title and summary_value) in lieu of key, value and that works. They only things which still throw it for a loop are lines 45-46, which call _('Summary') and _('Val'). I'm not sure if maybe something needs to be imported or installed for the _() function to work or if an alternate function can be used. I tried gettext() with no luck.

@redstreet
Copy link
Owner

@floatingheads, thanks a bunch for root causing and sharing! If you're up for submitting a PR, I'd gladly review it. If not, I'll put one in soon myself. Will leave this ticket open until the fix is in.

@floatingheads
Copy link
Author

@redstreet I still can't figure out why the _() function is keeping it from working. It works elsewhere in the template, just not on those lines.

@redstreet redstreet changed the title Fava Investor Won't Load Fava Investor Won't Load (Windows-only issue?) Apr 13, 2022
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

No branches or pull requests

3 participants