I'm using webpy 0.3 in a Windows XP box, with this sample code:
import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:
    def GET(self, name):
        if not name:
            name = 'world'
        return 'Hello, ' + name + '!'

print app.request('/test')


The result is:
<Storage {'status': '200 OK', 'headers': {}, 'data': 'Hello, test!'}>
Traceback (most recent call last):
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 201, in process
    web.ctx.app_stack.append(self)
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 830, in __getattr__
    return getattr(self._getd(), key)
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 64, in __getattr__
    raise AttributeError, k
AttributeError: 'app_stack'

Traceback (most recent call last):
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 204, in process
    return p(lambda: process(processors))
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 529, in processor
    return handler()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 204, in <lambda>
    return p(lambda: process(processors))
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 211, in process
    raise self.internalerror()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 436, in internalerror
    parent = self.get_parent_app()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 421, in get_parent_app
    if self in web.ctx.app_stack:
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 830, in __getattr__
    return getattr(self._getd(), key)
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 64, in __getattr__
    raise AttributeError, k
AttributeError: 'app_stack'

Traceback (most recent call last):
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 204, in process
    return p(lambda: process(processors))
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 529, in processor
    return handler()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 204, in <lambda>
    return p(lambda: process(processors))
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 211, in process
    raise self.internalerror()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 436, in internalerror
    parent = self.get_parent_app()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 421, in get_parent_app
    if self in web.ctx.app_stack:
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 830, in __getattr__
    return getattr(self._getd(), key)
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 64, in __getattr__
    raise AttributeError, k
AttributeError: 'app_stack'

Traceback (most recent call last):
  File "code.py", line 14, in <module>
    print app.request('/test')
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 191, in request
    response.data = "".join(self.wsgifunc()(env, start_response))
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 245, in wsgi
    result = self.handle_with_processors()
  File "G:\Documents and Settings\Leojay\Desktop\web\web
\application.py", line 217, in handle_with_processors
    web.ctx.app_stack = web.ctx.app_stack[:-1]
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 830, in __getattr__
    return getattr(self._getd(), key)
  File "G:\Documents and Settings\Leojay\Desktop\web\web\utils.py",
line 64, in __getattr__
    raise AttributeError, k
AttributeError: 'app_stack'

But if I change the last line of code into:
if __name__ == '__main__':
    print app.request('/test')

then everything is fine, I get:
<Storage {'status': '200 OK', 'headers': {}, 'data': 'Hello, test!'}>

What's wrong with my code?
Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to