Hi all,

I've checked in some changes to paste.urlparser to work with Windows but 
I've noticed a problem with certain URLs now redirecting to themselves 
which I'm investigating.

Cheers,

James

programmer.py wrote:
> Oh, I think this is what you really wanted to know about normpath...
> 
> os.path.normpath(r'c:/tmp/pylons-sandbox/helloworld')
> 'c:\\tmp\\pylons-sandbox\\helloworld'
> 
> It does seem to fix the path separator on windows.
> 
> jw
> 
> On Dec 18, 11:51 am, "programmer.py" <[EMAIL PROTECTED]> wrote:
>> fwiw, im on windows ->
>>
>>>>> import os.path
>>>>> os.path.normpath(r'c:\tmp\pylons-sandbox\helloworld')'c:\\tmp\\pylons-sandbox\\helloworld'
>> Also, Ian is right, the problem is in urlparser.py ...  I printed out
>> the `full' and self.root_directory before the check @457 and got ->
>>
>> c:\tmp\pylons-sandbox\helloworld\helloworld\public\index.html
>> c:/tmp/pylons-sandbox/helloworld/helloworld/public
>>
>> ouch.
>>
>> Thanks all!
>> jw
>>
>> On Dec 18, 10:47 am, Ian Bicking <[EMAIL PROTECTED]> wrote:
>>
>>> James Gardner wrote:
>>>> Hi Jose,
>>>> The problem is that StaticURLParser keeps some variables with / path
>>>> separators and \ characters with others if you don't specify the
>>>> root_directory on Windows.
>>>> The solution on Windows is to specify both the directory and the
>>>> root_directory when setting up the static file parser and ensure they
>>>> use Windows \ separators.
>>>> In your Pylons project config/middleware.py change this line:
>>>>      static_app = StaticURLParser(..)
>>>> to this:
>>>>      static_app = StaticURLParser(
>>>>          directory=config.paths['static_files'].replace('/','\\'),
>>>>          root_directory=config.paths['static_files'].replace('/','\\')
>>>>      )I suppose in StaticURLParser we could do:
>>> if os.path.sep != '/':
>>>      directory = directory.replace('/', os.path.sep)
>>> and ditto root_directory.  Would that resolve the problem?  Does
>>> os.path.normpath do this replacement on Windows?  That seems like a more
>>> ideal solution.  I'm guessing the reason it isn't working is when it
>>> tests on urlparser.py:450 "full.startswith(self.root_directory)" that
>>> the backslash/slash confusion causes the problem.  That should probably
>>> be updated to at least give a slightly more useful not found message
>>> (via the optional debug_message argument to not_found).
>>> Since you are on Windows, can you try these things out?
>>> --
>>> Ian Bicking | [EMAIL PROTECTED] |http://blog.ianbicking.org
> 
> 
> > 


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

Reply via email to