Accessing objects at runtime.

Gary Duzan mgi820 at motorola.com
Thu Sep 10 12:32:27 EDT 2009


In article <8888228b-379d-4fe4-956b-cf803541acc2 at 37g2000yqm.googlegroups.com>,
jacopo  <jacopo.pecci at gmail.com> wrote:
>I have a  system comprising many objects cooperating with each others.
>(For the time being, everything is running on the same machine, in the
>same process but things might change in the future). The system starts
>a infinite loop which keeps triggering operations from the
>instantiated objects.
>
>I would like to find a way to inspect the objects at run time.  In
>other words I would like to check certain attributes in order to
>understand in which status the object is. This of course without
>having to stop the system and resume it after the checking is
>finished.

   You might consider running a BaseHTTPServer in a separate thread
which has references to your objects of interest and exporting the
data through a web interface. Using a RESTful approach for mapping
URLs to objects within your system, a basic export of the data can
be as simple as printing out HTML strings with interpolated data.
(I recently did this in a couple hundred lines of code for a small
example handling a few resource types.) Fancier solutions could
pull in any of the freely available template engines or other web
framework pieces.  When you move to different processes and/or
machines, the access method can remain the same by varying the port
and/or hostname in the URL.

   Good luck...

					Gary Duzan
					Motorola H&NM





More information about the Python-list mailing list