how do I instantiate the request class

Posted on 2010-11-21
Last Modified: 2012-05-10
The Request constructor requires a parameter called environ which I have no clue as to how to code.
Question by:blueshoes
  • 4
  • 4
LVL 15

Expert Comment

ID: 34185377
You don't need to. GAE will create it for you and you just access request object.

Author Comment

ID: 34185573
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?
LVL 15

Expert Comment

ID: 34185622
If you use weapp framework ( it's available as self.request
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Author Comment

ID: 34187458
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 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.
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?
LVL 15

Accepted Solution

mish33 earned 500 total points
ID: 34201354
Try request['remote_addr']

If it fails, print request.keys() and see if it spelled differently.

Author Comment

ID: 34215482
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']


Author Comment

ID: 34215520
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?
LVL 15

Expert Comment

ID: 34218592
The output should be in the logs. To produce on browser use something like

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pyhon with Oracle encoding issue 8 96
Can't install scipy on Python 2.7 in Win7 2 219
Python Install On Mac Yosemite 8 149
Difference of import usage in Python 1 68
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question