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

markdown_extract only expects strings #2578

Closed
metaodi opened this issue Aug 12, 2015 · 6 comments
Closed

markdown_extract only expects strings #2578

metaodi opened this issue Aug 12, 2015 · 6 comments
Assignees

Comments

@metaodi
Copy link
Member

metaodi commented Aug 12, 2015

When using ckanext-fluent to define a multilingual markdown field, the output currently fails with the following error:

Error - <type 'exceptions.AttributeError'>: 'dict' object has no attribute 'strip'

I could trace this error back to the following line of code:

if (text is None) or (text.strip() == ''):

PR follows to make sure the site doesn't break because of this.

@rossjones
Copy link
Contributor

I haven't checked that overriding helpers is possible, but perhaps it might be better to override markdown_extract in ckanext-fluent instead?

@metaodi
Copy link
Member Author

metaodi commented Aug 13, 2015

@rossjones well monkey patching could work yes. I'll check if this is possible. But maybe it would be good to have a "proper" way of doing this.

@rossjones
Copy link
Contributor

I don't think you need to monkey-patch, you could use ITemplateHelpers - https://github.com/ckan/ckan/blob/master/ckan/plugins/interfaces.py#L888-L910 but it appears that it does stop you overwriting helpers at

raise Exception('overwritting extra helper %s' % helper)
:(

@wardi
Copy link
Contributor

wardi commented Aug 17, 2015

You can use an IPackageController before_show method to replace the any core fluent fields with a single-language version. I'm planning to add one of these to ckanext-fluent when I can make it work well enough to handle fluent with core dataset fields like title and notes.

@metaodi I've tried to pitch the idea of core ckan adopting the ckanext-fluent behaviour for dicts in place of text but haven't been able to sell it to the others yet :-) Maybe move this issue to ckanext-fluent for now.

@metaodi
Copy link
Member Author

metaodi commented Aug 20, 2015

@wardi Okay I'll look into that to replace the dict with a single language version. For now, I'll try to implement that in my own extension, if I can make it work, I'll try to integrate that in fluent as well.

@wardi
Copy link
Contributor

wardi commented May 12, 2016

closing in favour of #2678

@wardi wardi closed this as completed May 12, 2016
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