Re: [pylons-discuss] Cornice: define CORS policy in configuration?

2018-01-08 Thread Laurent DAVERIO
Hi Jens,

if you want to define the value in INI files, it will need to be read in
a function where either "config" or "settings" is available.

One way to do that would be to define CORS_POLICY as a global variable
in your app and initialize it using a config.include() call in your
__init__.py.

Hope this helps,

Laurent.


Le 08/01/2018 à 12:23, Jens W. Klein a écrit :
> I have a small application where I want to configure `cors_origins`
> different dependent on the server its running on (dev/ staging/ live)
> without allowing access cross those domains.
> 
> At the moment I have a policy defined in Python in a base.py, import it
> and use it in my classes with the enpoint like so:
> 
> CORS_POLICY = {
> 'origins': ('*.dev.myserver'.com,),
> #'origins': ('*.stage.customerserver.com',),
> #'origins': ('*.livedomain.com',),
> ...,
> }
> 
> ---
> 
> @resource(path='/api/menu', cors_policy=CORS_POLICY)
> class Menu(object):
> 
> def get(self):
>   ...
>   return menu_def
> ---
> 
> Question: is there a way to define the `cors_origin` in the INI-files?
> 
> TIA Jens
> 


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/b8f0c497-c8b4-5f02-ab9b-a47a1ed56d80%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Cornice: define CORS policy in configuration?

2018-01-08 Thread Jens W. Klein
I have a small application where I want to configure `cors_origins`
different dependent on the server its running on (dev/ staging/ live)
without allowing access cross those domains.

At the moment I have a policy defined in Python in a base.py, import it
and use it in my classes with the enpoint like so:

CORS_POLICY = {
'origins': ('*.dev.myserver'.com,),
#'origins': ('*.stage.customerserver.com',),
#'origins': ('*.livedomain.com',),
...,
}

---

@resource(path='/api/menu', cors_policy=CORS_POLICY)
class Menu(object):

def get(self):
...
return menu_def
---

Question: is there a way to define the `cors_origin` in the INI-files?

TIA Jens
-- 
Klein & Partner KG, member of BlueDynamics Alliance

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/p2vk75%242bt%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.