Re: Using %(here)s in logging config

2009-08-02 Thread Mike Orr

On Fri, Jul 31, 2009 at 12:05 PM, kochharkochhar...@gmail.com wrote:

 Hi all,

 I'm trying to use the %(here)s variable in my logging config but I get the
 following error:

 ConfigParser.InterpolationMissingOptionError: Bad value substitution:
        section: [handler_file]
        option : args
        key    : here
        rawval : ('%(here)s/var/log/krumplez.local.log', 'midnight', 1, 3)

 The corresponding section of my ini file is:

 [handler_file]
 class = handlers.TimedRotatingFileHandler
 args = ('%(here)s/var/log/kurmplez.local.log', 'midnight', 1, 3)
 level = NOTSET
 formatter = generic

 Google wasn't very helpful in figuring out how to configure logging output to 
 a
 directory relative to the config file. Is there some trick to getting the
 interpolation to work? The comment at the top of the file says:
 # The %(here)s variable will be replaced with the parent directory of this 
 file
 #

The file is used in two different ways.  Variables are extracted using
paste.deploy.loadwsgi.NicerConfigParser, which interpolates %(here)s.
Logging configuration is done by logging.config.fileConfig, which
doesn't know about interpolation.  You'll probably have to use
absolute paths.  Or if you're running the application under
Supervisor, you can let it default to stdout and then redirect it to a
file in the Supervisor config.

-- 
Mike Orr sluggos...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



sub domains, routes, redirect_to

2009-08-02 Thread eleith

i've got subdomain support working in routes, but redirect_to did
something i did not expect, and wanted to see if this was a known bug
or a misunderstanding on my part.

here is a short example

map.connect('/{action}', controller='subpage', conditions=
{sub_domain:['sub']})
map.connect('/{controller}/{action}')

the routing will work as expected:

sub.example.com/login - controller='subpage', action='login'
www.example.com/subpage/login - controller='subpage', action='login'

however, when using redirect_to:

redirect_to(controller='subpage', action='login', sub_domain='sub') -
sub.example.com/login (expected)
redirect_to(controller='subpage', action='login') - www.example.com/login
(not expected)
redirect_to(controller='subpage', action='login', sub_domain='www') -
www.example.com/login (not expected)

what i expected was to see was

redirect_to(controller='subpage', action='login') - 
www.example.com/subpage/login
redirect_to(controller='subpage', action='login', sub_domain='www') -
www.example.com/subpage/login

i've reworked my URLs for now, but it would be nice to get this
working the way i expected and have the url generation check that the
conditions of the mappers are met, before using one.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: sub domains, routes, redirect_to

2009-08-02 Thread Mike Orr

On Sun, Aug 2, 2009 at 5:05 PM, eleithele...@gmail.com wrote:

 i've got subdomain support working in routes, but redirect_to did
 something i did not expect, and wanted to see if this was a known bug
 or a misunderstanding on my part.

 here is a short example

 map.connect('/{action}', controller='subpage', conditions=
 {sub_domain:['sub']})
 map.connect('/{controller}/{action}')

 the routing will work as expected:

 sub.example.com/login - controller='subpage', action='login'
 www.example.com/subpage/login - controller='subpage', action='login'

 however, when using redirect_to:

 redirect_to(controller='subpage', action='login', sub_domain='sub') -
 sub.example.com/login (expected)
 redirect_to(controller='subpage', action='login') - www.example.com/login
 (not expected)
 redirect_to(controller='subpage', action='login', sub_domain='www') -
 www.example.com/login (not expected)

 what i expected was to see was

 redirect_to(controller='subpage', action='login') - 
 www.example.com/subpage/login
 redirect_to(controller='subpage', action='login', sub_domain='www') -
 www.example.com/subpage/login

 i've reworked my URLs for now, but it would be nice to get this
 working the way i expected and have the url generation check that the
 conditions of the mappers are met, before using one.

I don't know if it's a bug as much as the ambiguity in generating
unnamed routes.  It can be hard to predict which route will be chosen.
 That;s why there has been a movement toward named routes and
url/redirect instead of url_for/redirect_to .  So if you name the two
routes and then use the name in the generation, you should get what
you expect.

Also, my understanding of the 'sub_domain' argument in generation is
that it changes the domain of the URL, and is not involved in route
selection (i.e., the condition is ignored when generating).  I could
be wrong about that, but it looks consistent with what you're
experiencing.

-- 
Mike Orr sluggos...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread hekevintran

I have deployed a Pylons application on WebFaction and I am trying to
use redirect_to in my controller.  My page is using HTTPS.  For some
reason redirect_to is generating urls that are using HTTP for the
protocol.  I am currently getting around this problem by using the
redirect function which allows you to supply a url as a string and
hardcoding my urls.  This works and is okay for now as my application
is small, but it is very inelegant.  Does anyone know why redirect_to
is making urls that have HTTP and not HTTPS?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread Graham Dumpleton



On Aug 3, 12:13 pm, hekevintran hekevint...@gmail.com wrote:
 I have deployed a Pylons application on WebFaction and I am trying to
 use redirect_to in my controller.  My page is using HTTPS.  For some
 reason redirect_to is generating urls that are using HTTP for the
 protocol.  I am currently getting around this problem by using the
 redirect function which allows you to supply a url as a string and
 hardcoding my urls.  This works and is okay for now as my application
 is small, but it is very inelegant.  Does anyone know why redirect_to
 is making urls that have HTTP and not HTTPS?

Using WebFaction you would be sitting behind nginx and it would be
nginx which is handling HTTPS. As a result your application is
receiving HTTP only. Thus, wsgi.url_scheme wouldn't be set correctly
for when connection to nginx was actually HTTPS. WebFaction do set a
custom request header which is passed through to your application to
indicate whether connection to nginx was HTTPS or not. You will need
some sort of WSGI middleware which looks for that special request
header and fixes up wsgi.url_scheme appropriately. As long as that is
done, any conforming WSGI application should then do correct thing.

Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread hekevintran

Thanks Graham for the informative answer.  What is the recommended
solution to this situation?

On Aug 2, 7:43 pm, Graham Dumpleton graham.dumple...@gmail.com
wrote:
 On Aug 3, 12:13 pm, hekevintran hekevint...@gmail.com wrote:

  I have deployed a Pylons application on WebFaction and I am trying to
  use redirect_to in my controller.  My page is using HTTPS.  For some
  reason redirect_to is generating urls that are using HTTP for the
  protocol.  I am currently getting around this problem by using the
  redirect function which allows you to supply a url as a string and
  hardcoding my urls.  This works and is okay for now as my application
  is small, but it is very inelegant.  Does anyone know why redirect_to
  is making urls that have HTTP and not HTTPS?

 Using WebFaction you would be sitting behind nginx and it would be
 nginx which is handling HTTPS. As a result your application is
 receiving HTTP only. Thus, wsgi.url_scheme wouldn't be set correctly
 for when connection to nginx was actually HTTPS. WebFaction do set a
 custom request header which is passed through to your application to
 indicate whether connection to nginx was HTTPS or not. You will need
 some sort of WSGI middleware which looks for that special request
 header and fixes up wsgi.url_scheme appropriately. As long as that is
 done, any conforming WSGI application should then do correct thing.

 Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread Graham Dumpleton



On Aug 3, 1:11 pm, hekevintran hekevint...@gmail.com wrote:
 Thanks Graham for the informative answer.  What is the recommended
 solution to this situation?

Effectively what I already said. I don't remember the name of the
special header that WebFaction passes through and I don't know enough
Pylons to say how you would integrate WSGI middleware wrapper to fix
it up.

Do a search on WebFaction's own forums as this issue has been
discussed there before.

Graham

 On Aug 2, 7:43 pm, Graham Dumpleton graham.dumple...@gmail.com
 wrote:



  On Aug 3, 12:13 pm, hekevintran hekevint...@gmail.com wrote:

   I have deployed a Pylons application on WebFaction and I am trying to
   use redirect_to in my controller.  My page is using HTTPS.  For some
   reason redirect_to is generating urls that are using HTTP for the
   protocol.  I am currently getting around this problem by using the
   redirect function which allows you to supply a url as a string and
   hardcoding my urls.  This works and is okay for now as my application
   is small, but it is very inelegant.  Does anyone know why redirect_to
   is making urls that have HTTP and not HTTPS?

  Using WebFaction you would be sitting behind nginx and it would be
  nginx which is handling HTTPS. As a result your application is
  receiving HTTP only. Thus, wsgi.url_scheme wouldn't be set correctly
  for when connection to nginx was actually HTTPS. WebFaction do set a
  custom request header which is passed through to your application to
  indicate whether connection to nginx was HTTPS or not. You will need
  some sort of WSGI middleware which looks for that special request
  header and fixes up wsgi.url_scheme appropriately. As long as that is
  done, any conforming WSGI application should then do correct thing.

  Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread hekevintran

I found a good solution.  It will know which protocol to use if you
specify it in the function call to redirect_to:

return redirect_to(protocol='https', controller='myController',
action='index')

On Aug 2, 8:23 pm, Graham Dumpleton graham.dumple...@gmail.com
wrote:
 On Aug 3, 1:11 pm, hekevintran hekevint...@gmail.com wrote:

  Thanks Graham for the informative answer.  What is the recommended
  solution to this situation?

 Effectively what I already said. I don't remember the name of the
 special header that WebFaction passes through and I don't know enough
 Pylons to say how you would integrate WSGI middleware wrapper to fix
 it up.

 Do a search on WebFaction's own forums as this issue has been
 discussed there before.

 Graham



  On Aug 2, 7:43 pm, Graham Dumpleton graham.dumple...@gmail.com
  wrote:

   On Aug 3, 12:13 pm, hekevintran hekevint...@gmail.com wrote:

I have deployed a Pylons application on WebFaction and I am trying to
use redirect_to in my controller.  My page is using HTTPS.  For some
reason redirect_to is generating urls that are using HTTP for the
protocol.  I am currently getting around this problem by using the
redirect function which allows you to supply a url as a string and
hardcoding my urls.  This works and is okay for now as my application
is small, but it is very inelegant.  Does anyone know why redirect_to
is making urls that have HTTP and not HTTPS?

   Using WebFaction you would be sitting behind nginx and it would be
   nginx which is handling HTTPS. As a result your application is
   receiving HTTP only. Thus, wsgi.url_scheme wouldn't be set correctly
   for when connection to nginx was actually HTTPS. WebFaction do set a
   custom request header which is passed through to your application to
   indicate whether connection to nginx was HTTPS or not. You will need
   some sort of WSGI middleware which looks for that special request
   header and fixes up wsgi.url_scheme appropriately. As long as that is
   done, any conforming WSGI application should then do correct thing.

   Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread Mike Orr

On Sun, Aug 2, 2009 at 9:03 PM, hekevintranhekevint...@gmail.com wrote:

 I found a good solution.  It will know which protocol to use if you
 specify it in the function call to redirect_to:

 return redirect_to(protocol='https', controller='myController',
 action='index')

That's a workaround, yes.  Is WebFaction doing proxying?  Because my
HTTPS application uses ProxyPass and the URLs are generated correctly
even without the protocol option.

-- 
Mike Orr sluggos...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons' redirect_to function does not work with HTTPS

2009-08-02 Thread Graham Dumpleton



On Aug 3, 3:28 pm, Mike Orr sluggos...@gmail.com wrote:
 On Sun, Aug 2, 2009 at 9:03 PM, hekevintranhekevint...@gmail.com wrote:

  I found a good solution.  It will know which protocol to use if you
  specify it in the function call to redirect_to:

  return redirect_to(protocol='https', controller='myController',
  action='index')

 That's a workaround, yes.  Is WebFaction doing proxying?  Because my
 HTTPS application uses ProxyPass and the URLs are generated correctly
 even without the protocol option.

Yes, WebFaction uses nginx in front. The nginx does:

  RequestHeader set Http-X-Forwarded-Proto https

for HTTPS connection.

There appears to be stuff in Paste to handle it. Just needs to be
configured to use it I guess.

http://trac.pythonpaste.org/pythonpaste/changeset/7458

Graham

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---