Re: Self-contained test setup and ports

On 23/09/13 15:54, Wang, Jing J wrote:
>>> The way I am thinking of dealing with the unknown-ports situation
>>> is to provide the current settings as a module or dict or
>>> something in python and have a pipe that you can use to do
>>> textual replacements in static files. So if you have a file
>>> foo.html with content like
>>>
>>> <script> var port = %(http_port_2)s [...]
>>>
>>> and load the file as foo.html?pipe=config
>>>
>>> It will end up as
>>>
>>> <script> var port = 43525 [...]
>
> I don't quite follow what' the magic to load foo.html?pipe=config,
> which make port=%(http_port_2)
>
> end up as
>
> var port = 43525.
>
> From your description, sounds config is a python module/dict, right?
> The port replacement is in the runtime or staticly?

I don't know exactly what you mean. However, let me try to explain.

The server reserves the "pipe" query parameter for its own use. The 
value of this parameter specifies, in effect, a server internal function 
that the response will be passed through. In this case I am suggesting 
that the "config" function be defined as something like:

def config(request, response):
     response.content = response.content % config_dict

This means that the replacement will be transparent to the browser; it 
will just see static files with the correct values for each parameter in.

Received on Monday, 23 September 2013 15:43:34 UTC