[python-win32] Python and ASP - failure on 2nd and subsequent page loads

Mark Hammond skippy.hammond at gmail.com
Thu Oct 15 07:30:39 CEST 2009


On 6/10/2009 6:01 AM, Jon Southard wrote:
> I would be grateful for any advice about a problem which is preventing
> me from using Python for my current project.
>
> I am hoping to use Python 2.6 on the server side with Microsoft ASP [not
> ASP.NET; version details below]. The behavior I see is:
>
> 1. Load very simple page [text below] into browser [Firefox or IE,
> versions below]. Everything displays, fine.
> 2. Exit browser, restart it, and reload the same page; or open a second
> tab and load the same page.
> 3. In either case, page fails to load, with error:
> Python ActiveX Scripting Engine, ASP 0211 (0x80020009)
> A built-in ASP object has been referenced, which is no longer valid.
> If I edit the page in any way, or just ‘touch’ it, and refresh the
> browser, the page will load correctly the first time, and then fail
> again as described.

Sorry for the delay.  The problem seems to be caused by a silly bug in 
the axscript implementation.

To fix the issue locally:

* open 'win32comext/axscript/client/framework.py'

* search for ResetNamesItems - you should find the function def at line 747.

* Replace the implementation of that function with the one below:

	def ResetNamedItems(self):
		# Due to the way we work, we re-create persistent ones.
		existing = self.subItems
		self.subItems = {}
		for name, item in existing.iteritems():
			item.Close()
			if item.flags & axscript.SCRIPTITEM_ISPERSISTENT:
				self.AddNamedItem(item.name, item.flags)

Note that sadly this file uses tabs for indentation, so make sure you 
get that correct.  Also unwrap any long lines which my mailer wrapped.

* Restart IIS.

After that I can successfully reload the Python ASP samples (and before 
that I too saw the symptoms you described).  I will check that into cvs 
so the next pywin32 version will have that fixed.

Cheers,

Mark
>
> The page I am using has no actual Python scripting, just the LANGUAGE
> directive and then the html and body tags with a little plain text. Of
> course, things don’t get any better if I put in some actual Python.
>
> I found a five-year-old newsgroup posting with what seemed to be a
> similar (but not identical) problem. This thread said that the problem
> went away if server-side debugging was turned off. I have it turned off,
> no effect. I also tried adding some Response object settings to disallow
> cacheing, but these did not have any effect.
>
> Version Info:
>
> Python: 2.6.2
> PyWin: pywin32-214 (I ran the client\pyscript.py and server\axsite.py
> scripts for setup)
> Client OS: Windows XP Pro SP2
> Browsers: Firefox 3.0.14, IE 8.0.6 [identical bug]
> Server: IIS 5.1
>
> Note, I also tried using Python 3.1 with corresponding pywin, but I
> could not get that to work with ASP at all; just got server 500 errors.
> I’d prefer to use 2.6 anyway since I am fairly new to Python.
>
> I would be very grateful for any expert pointers on this, since if I
> can’t solve it I will probably have to go use PHP, Javascript, or
> something else. Thank you!
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list