Comments (4)
I added a function variables_as_json()
that causes an HTTP response to be returned that contains the interview variables in JSON format. This is not a perfect representation of the interview variables because the interview variables can contain objects that are not JSON serializable, like Python sets, datetime.datetime objects, and docassemble objects. The variables_as_json()
function does the best it can, which should be good enough for most simple API applications.
It is probably better to be selective about which variables to make available through an API, though. The documentation for response()
contains an example that uses json.dumps()
to return a JSON representation of particular variables.
I have not created a general-purpose "answer file" system because there are so many things that could go wrong if users could upload arbitrary data into an interview. There are better solutions to the problem of sharing variables between interviews.
For example, if you have a suite of family law interviews, you can package them as a single interview with up-front questions that determine which interview to run. The include
feature facilitates the incorporation of sub-interviews.
Another way to transfer variables from one interview to another is through the interview_url()
and url_args
features. Interview 1 can contain a question with a hyperlink to Interview 2 (using the i
parameter to interview_url()
), where relevant variables are passed as URL parameters to Interview 2. Then both interviews will share the same session key.
Another way for interviews to interact with one another is through the use of write_record()
and read_record()
. Authors can create keys based on the user's e-mail, which can be retrieved with user_info()
. Each interview, when it starts, could use read_record()
to query whether any global information already exists. The advantage of this method is that the data are Python-serialized rather than JSON-serialized, so Python objects can be shared.
from docassemble.
I also added a function all_variables()
that returns the variables as a Python dictionary in a format suitable for JSON serializing.
from docassemble.
Thanks I will try these
from docassemble.
I believe this issue has been addressed, so I am closing it.
from docassemble.
Related Issues (20)
- Variables with datatype: raw causing UnboundLocalError HOT 2
- Main page has link to Slack channel that appears expired HOT 3
- JSON representation of code generated fields containing choices results in error HOT 2
- Upgrade version of pdftk-java in docassemble-os HOT 2
- Warn users when the config has duplicate entries that override each other HOT 1
- show if and disable if on the same field behaves unexpectedly HOT 2
- oauth2client in DAOAuth is deprecated HOT 3
- API resume_url with secret HOT 3
- Packages menu doesn't work as expected when browsing a user's playground HOT 1
- numbers and currency formating decimals HOT 1
- Migration to linux/arm64 (rpi4 / Raspberry Pi 4) HOT 2
- Playground fails to load HOT 5
- On the recipe screen, I think you should add something to the description of idle.js implementation
- 2424 HOT 1
- Update redis-py package requirement to 5.0.2 HOT 1
- Setting new language doesn´t work HOT 4
- Interview datatype date is returning 'Bad date' in the downloded document HOT 4
- Error when configured for Azure Authentication HOT 6
- Error: AttributeError: 'str' object has no attribute 'signature' HOT 3
- Feature Request: seperate out services from Dockerfile HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docassemble.