Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -N -r2ce111327be44689929ce2c6d0e0f466497616f8 -r1debd517562c09bed5a9c9b22030f67b78f3fa13 --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 2ce111327be44689929ce2c6d0e0f466497616f8) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 1debd517562c09bed5a9c9b22030f67b78f3fa13) @@ -858,6 +858,21 @@ } # + # Manage lifecycle concerns for NaviServer/AOLserver: at the end + # of every request, all global variables are deleted. We can use + # this to destroy as well volatile mongoDB objects via Tcl + # variable traces. + # + :public method destroy_on_cleanup {} { + set name ::__volatile_mongo_objects([self]) + set $name 1 + trace add variable $name unset [list [self] __cleanup] + } + :public method __cleanup {args} { + :destroy + } + + # # _id is the special property maintained by mongoDB # :property -accessor public -class ::nx::mongo::Attribute _id {