Posts

How can a unique Rserve connection be stored per session?

Image
3 2 I'm writing a small Flask application and am having it connect to Rserve using pyRserve. I want every session to initiate and then maintain its own Rserve connection. Something like this: session['my_connection'] = pyRserve.connect() doesn't work because the connection object is not JSON serializable. On the other hand, something like this: flask.g.my_connection = pyRserve.connect() doesn't work because it does not persist between requests. To add to the difficulty, it doesn't seem as though pyRserve provides any identifier for a connection, so I can't store a connection ID in the session and use that to retrieve the right connection before each request. Is there a way to accomplish having a unique connection per session? python r flask rserve pyrserve share | improve this question edited Feb 10 '15 at 8:16 davidism 64.9k 12 172 188 asked Feb 10 '15 at 2:27 izyda izyda 405 2 15 W...

How to use WTForms-Dynamic-fields Module (Flask/Python)

Image
2 I guess this question can be interpreted more generally with help on how to implement custom Python Modules. I am building a Flask Web App and trying to create a reasonably complex form that basically allows a user to add more fields on button click but still retaining the benefits of WTForms. I have come across this module online: https://pypi.org/project/WTForms-Dynamic-Fields/ I am confused as to how I am supposed to implement the module. It says to create an instance of the module before using the add_field() and add_validator() methods. Before then binding the form variable to the 'process()' method. I guess I am meant to include a JavaScript button but getting very confused as to how to do this. As a simple example I am trying to implement it on this simple WTForm: class LoginForm(FlaskForm): username = StringField('username', validators=[InputRequired()]) password = PasswordField('password', validators=[InputRequired()]) dynamic = WTFormsD...