Going beyond what Simon did..
I typically make make a table like `user_transaction`, which has all of the
relevant information for the transaction:
* User ID
* Timestamp
* Remote IP
Using the sqlalchemy hooks, I'll then do something like:
* update the object table with the user_transaction id
Ohhh, that sounds perfect !
And since I already make use of class based views, that should be dead
simple to put in place.
Thanks for the support, guys
Cheers,
JP
On Mon, 15 Mar 2021 at 06:46, Simon King wrote:
> I use pyramid as a web framework, and when I create the DB session for
> each
you no longer have to use DeclarativeMeta at all, you can use a class decorator:
https://docs.sqlalchemy.org/en/14/orm/mapping_styles.html#declarative-mapping-using-a-decorator-no-declarative-base
if you are on 1.3, there's a way to get the same effect in 1.3 using the
instrument_declarative
I use pyramid as a web framework, and when I create the DB session for
each request, I add a reference to the current request object to the
DB session. The session object has an "info" attribute which is
intended for application-specific things like this:
I haven't followed your code in detail, but I think the problem might be here:
clazz = school.Class('12', 'A')
students = [
Student("Name1", "Sname1", clazz=clazz, code='aa7'),
Student("Name2", "Sname2", clazz=clazz, code='bb7'),
Student("Name3", "Sname3",
I suggest you set up an event listener for the "after_attach" event on
your session:
https://docs.sqlalchemy.org/en/13/orm/events.html#sqlalchemy.orm.events.SessionEvents.after_attach
Then you can set a breakpoint in the listener (or raise an exception,
or use the traceback module to print a