• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

how do I instantiate the request class

The Request constructor requires a parameter called environ which I have no clue as to how to code.
0
blueshoes
Asked:
blueshoes
  • 4
  • 4
1 Solution
 
mish33Commented:
You don't need to. GAE will create it for you and you just access request object.
0
 
blueshoesAuthor Commented:
So how do I get a reference to it to access it? Is there something I have to import?

I have a WSGIGateway  app with a  Python module containing methods implementing various services (RPCs).In some of those methods I need the remote_addr property from the Request object. How can I get a reference to the Request object in order to reference that property?  Is there perhaps a way that the Request object can be passed as a parameter to those methods?
0
 
mish33Commented:
If you use weapp framework (http://code.google.com/appengine/docs/python/gettingstarted/usingwebapp.html) it's available as self.request
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
blueshoesAuthor Commented:
I am implementing the client side of my app with Flex. I am not much conversant with Python or Google App Engine and am sort of stumbling through the server side of my app. Here are a couple of facts about my situation. 1) I am using a product called PyAMF that implements the Adobe Action Message Format, and 2) I have been advised by a consultant on this project who set up my Google App Engine framework. Most of the app is coded and running in a test environment. Recently I had a need to get the remote_addr property of the Request object, and that  is where this particular problem came about.

My app.py has the following imports.
import wsgiref.handlers
from pyamf.remoting.gateway.wsgi import WSGIGateway
from models import utils
from services import data_services
So I suppose that PyAMF dictates that I use its WSGIGateway, but I don't know enough about it to know for sure. In any case, referencing self.request gives the following error.
AttributeError: 'DataServices' object has no attribute 'request'
Somebody advised me to use a Python decorator that would pass the Request object to a method as an added first parameter (after self) as follows.
@expose_request
def userSignIn(self, request, sessionKey, userSigninName, clientPasswordHash):
Subsequent reference to request.remote_addr gives an error saying that request is a dictionary and has no attribute remote_addr.

Given all that, do you know how I can get at the remote_addr property?
0
 
mish33Commented:
Try request['remote_addr']

If it fails, print request.keys() and see if it spelled differently.
0
 
blueshoesAuthor Commented:
Re: Try request['remote_addr']

The only thing about that suggestion that was needed was to change the string literal to uppercase: request['REMOTE_ADDR']

Thanks!
0
 
blueshoesAuthor Commented:
Re: If it fails, print request.keys() and see if it spelled differently.

I tried this by literally inserting the statement print request.keys() into my code. I am testing my app with Google App Engine Launcher, and I thought maybe the output of that statement would be directed to the log, but it wasn't. How would I do that? Where would the output appear?
0
 
mish33Commented:
The output should be in the logs. To produce on browser use something like
response.write(request.keys())
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now