python - Pylons: free module-level variables? -
It is also not certain that the module-level is right here, but ...
I have Within a project and model component, I have a global variable, doctor, in which I have to use different query objects in __ init __.py
. (The doctor has a document handle on an XML file that I am using as a fake DB.) My question is, when __init __ Is the term of Py
end? Currently I am not releasing the document with Doc.Nelilk () and I am not sure where to place it.
Alternative design I was thinking that consumer object (questions) level of this doctor (i.e., make it a singleton). But it appears that the life of my query object is such that the doctor is always redistributed to a new document handle.
class query (object): doc = none def __init __ (self, content = none): self.content = content if self.doc == none: self.doc = parse (Os.path.join (config ['app_conf'] ['xmldb'], "sample_search_result.xml"))
I can tell because the elements of the document are changed .
Does anyone want to exclude Noobi?
objects only prevent existing ones when 1) they have no reference, or 2) interpreter ends A module / package holds the context of its module-level names in its own words; All references to the module have to be released in all other modules as well as modules in sys.modules, and in the context of any object.
Comments
Post a Comment