You can use environment variables. In WSGI script file add: import os os.environ[‘SOMEVALUE’] = ‘string value’
In another module then use: import os value = os.environ[‘SOMEVALUE’] Graham > On 3 Aug 2016, at 9:39 PM, [email protected] wrote: > > I can, but how can I reach them in my .py file? not only within a request > (since I want to initialize my cache once in the .py file) > > On Wednesday, August 3, 2016 at 2:33:23 PM UTC+3, Graham Dumpleton wrote: > Is there are reason you can’t just set them in the WSGI script file? > > Graham > >> On 3 Aug 2016, at 9:31 PM, sor...@ <>gmail.com <http://gmail.com/> wrote: >> >> what if my WSGI application needs to know about them also outside of a >> request handler? >> >> Thanks a lot! >> >> On Wednesday, August 3, 2016 at 9:45:06 AM UTC+3, Graham Dumpleton wrote: >> If your WSGI application only needs to know about them within a request >> handler, use the Apache SetEnv directive and then access the values form the >> WSGI environ dictionary passed to the WSGI request handler. Otherwise just >> set them in the WSGI script file. >> >> The WSGIScriptAlias directive is a command line where you can pass extra >> arguments. >> >> Graham >> >>> On 3 Aug 2016, at 4:40 PM, sor...@ <>gmail.com <http://gmail.com/> wrote: >>> >>> I'm listening on specific IP and PORT, >>> but my python script takes IP and PORT of the cache he registered to. >>> so my goal is to transfer these arguments from httpd.conf all the way to >>> the application >>> >>> On Wednesday, August 3, 2016 at 9:29:10 AM UTC+3, Graham Dumpleton wrote: >>> The WSGIScriptAlias directive doesn’t take such arguments for IP and port. >>> Where did you see that you needed to do that. >>> >>> If you need to override the port, you need use a Listen directive and/or a >>> VirtualHost directive. You should be trying to restrict what IP addresses >>> the server listens on unless you have a specific need to and understand the >>> implications of doing that. >>> >>> So try with just: >>> >>> WSGIScriptAlias / “C:/Program Files/ofer/test/testService.wsgi" >>> >>> Graham >>> >>>> On 3 Aug 2016, at 4:25 PM, sor...@ <>gmail.com <http://gmail.com/> wrote: >>>> >>>> it works fine when no arguments passed in WSGIScriptAlias in httpd.conf >>>> >>>> the problem is when I'm trying to pass IP and PORT as arguments >>>> WSGIScriptAlias / "C:\Program Files\ofer\test\testService.wsgi" >>>> 10.20.10.36 8080 >>>> >>>> On Wednesday, August 3, 2016 at 9:21:19 AM UTC+3, Graham Dumpleton wrote: >>>> Try using forward slashes and not back slashes. >>>> >>>> Python will interpret a backslash before certain characters as a special >>>> control character. Eg \t gets replaced with a tab. Thus use: >>>> >>>> import sys >>>> sys.path.insert(0, “C:/Program Files/ofer/testService”) >>>> >>>> The same goes when defining paths in the Apache configuration. Although >>>> Apache is slightly tolerant to Windows type paths, it is better to use >>>> POSIX style paths. >>>> >>>> Graham >>>> >>>>> On 3 Aug 2016, at 4:14 PM, sor...@ <>gmail.com <http://gmail.com/> wrote: >>>>> >>>>> I meant EDIT, and not FIX. >>>>> >>>>> it still doesn't work >>>>> >>>>> On Tuesday, August 2, 2016 at 5:42:41 PM UTC+3, [email protected] >>>>> <http://gmail.com/> wrote: >>>>> FIX: >>>>> >>>>> ... >>>>> testService.wsgi: >>>>> >>>>> import sys >>>>> sys.path.insert(0, "C:\Program Files\ofer\testService") >>>>> >>>>> .... >>>>> >>>>> On Tuesday, August 2, 2016 at 5:35:41 PM UTC+3, [email protected] <> wrote: >>>>> hey all, >>>>> >>>>> I'm running Apache 2.4 on Windows. >>>>> >>>>> In httpd.conf I trying to run: >>>>> >>>>> WSGIScriptAlias / "C:\Program Files\ofer\test\testService.wsgi" >>>>> 10.20.10.36 8080 >>>>> >>>>> testService.wsgi: >>>>> >>>>> import sys >>>>> sys.path.insert(0, "C:\Program Files\ofer\test") >>>>> >>>>> from testService import app as application >>>>> application.cache_host = sys.argv[1] >>>>> application.cache_port = sys.argv[2] >>>>> >>>>> >>>>> testService.py gets the IP and PORT from the user. >>>>> I'm trying to pass arguments from httpd.conf all the way to >>>>> testService.py through the testService.wsgi, >>>>> and I'm getting this Error: >>>>> [wsgi:error] [pid 4772:tid 936] [client 10.3.101.31:2419 >>>>> <http://10.3.101.31:2419/>] Target WSGI script not found or unable to >>>>> stat: C:/Program Files/ofer/test/testService.wsgi 10.20.10.36 8080 >>>>> >>>>> how can I do it? >>>>> >>>>> Thanks a lot, >>>>> Ofer >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google Groups >>>>> "modwsgi" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send an >>>>> email to modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>. >>>>> To post to this group, send email to mod...@ <>googlegroups.com >>>>> <http://googlegroups.com/>. >>>>> Visit this group at https://groups.google.com/group/modwsgi >>>>> <https://groups.google.com/group/modwsgi>. >>>>> For more options, visit https://groups.google.com/d/optout >>>>> <https://groups.google.com/d/optout>. >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "modwsgi" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to [email protected] <>. >>>> To post to this group, send email to [email protected] <>. >>>> Visit this group at https://groups.google.com/group/modwsgi >>>> <https://groups.google.com/group/modwsgi>. >>>> For more options, visit https://groups.google.com/d/optout >>>> <https://groups.google.com/d/optout>. >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "modwsgi" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected] <>. >>> To post to this group, send email to [email protected] <>. >>> Visit this group at https://groups.google.com/group/modwsgi >>> <https://groups.google.com/group/modwsgi>. >>> For more options, visit https://groups.google.com/d/optout >>> <https://groups.google.com/d/optout>. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "modwsgi" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <>. >> To post to this group, send email to [email protected] <>. >> Visit this group at https://groups.google.com/group/modwsgi >> <https://groups.google.com/group/modwsgi>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/modwsgi > <https://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
