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

AutocompleteInputWidget - more powerful configuration for typeahead.js #413

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Jun 24, 2020

This is a redo of PR #185, rebased onto the current master branch.

This parameter provides an alternative, more powerful (though hairy)
means of configuring typeahead.js, providing access to the
complete feature set of the plugin.
@dairiki
Copy link
Contributor Author

dairiki commented Jun 24, 2020

Some comments extracted/duplicated from PR #185

Problem: I had been relying on a hack to support JSON-esque serialization of values containing literal javascript using json.JSONEncoder from python’s standard library. It seems that my hack is not feasible in any version of python after 2.6 (). (My hack involved overriding JSONEncoder._iterencode, which does not exist in python >= 2.7.)

My hacked up version of JSONEncoder is JSONConfigSerializer in widget.py, which works with the new literal_js marker class which is defined just above it. The two unit tests which are currently failing are a result of these hacks not working in recent versions of python.

I see two ways forward:

  1. Implement our own serializer (more or less from scratch.)
  2. Find some other external JSON/javascript-serializer that will work for us. (I’m not sure that such a thing exists.)
    I’m not sure that either is worth the effort.

@stevepiercy responded:

Does this thread describe the same issue https://stackoverflow.com/a/53848267/2214933?

Does jsons do what is needed?

No, I think this is a different problem. At the root is the fact that we want to be able to serialize python data structures to javascript expressions which are not necessarily valid JSON. E.g. one would like to be able to include javascript function expressions, as well as function and variable names in the serialized result.

@stevepiercy stevepiercy added this to the 3.0.0 milestone Aug 23, 2020
Base automatically changed from master to main January 19, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants