Hello Michael On Wed, 17 Jul 2002, Michael Bub wrote: > First, I had some problems with my singletons. Sometimes, the singleton > instance was just forgotten about and a new one was created. No good. > I then found out that this was due to a re-import of the class, i. e. > Webware behaves as if the class was never imported before, imports it > again, and consequently also creates a new instance. > After further testing, I learnt that every file gets re-imported every > once in a while.
It may be or not that you encounter problems with differently specified import statements. (A similar problem, see below, happened to me also, and it took me a while to find it.) Consider, the directory /somewhere/webware as well as /somewhere/webware/WebKit are in your $PYTHONPATH. Then import Page and from WebKit import Page will lead to different module objects though in each case they stem from the same file: Python 2.2.1 (#1, Jul 4 2002, 13:43:12) [GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4 Type "help", "copyright", "credits" or "license" for more information. >>> from WebKit import Page >>> Page <module 'WebKit.Page' from '/usr/local/share/webware/WebKit/Page.pyc'> >>> id(Page) 135848460 >>> import Page >>> Page <module 'Page' from '/usr/local/share/webware/WebKit/Page.pyc'> >>> id(Page) 135926892 Notice that the id's are different. Along the same lines: svss@purpurea:~$ cd /usr/local/share/webware/WebKit svss@purpurea:/usr/local/share/webware/WebKit$ export PYTHONPATH=/usr/local/share/webware svss@purpurea:/usr/local/share/webware/WebKit$ python Python 2.2.1 (#1, Jul 4 2002, 13:43:12) [GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4 Type "help", "copyright", "credits" or "license" for more information. >>> from WebKit import Page >>> p1 = Page.Page() >>> import Page >>> isinstance(p1, Page.Page) 0 As you can see, this can cause subtle bugs. I recommend to always be consistent in your $PYTHONPATH and import statements; use from package import module even if your current working directory contains the module. Stefan ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
