alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

Cann't create language file in windows platform(patch supplied) #4

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From limo...@gmail.com on March 01, 2008 23:04:29

What steps will reproduce the problem? 1. Creating new languages file What is the expected output? What do you see instead? I want it can create new language file successful, but there is and error "Cann't create file xx" What version of the product are you using? On what operating system? svn trunk. Windows platform. Please provide any additional information below. I checked, it's because the os.sep is different from different platform, in windows platform it's '\'. But in admin/controllers/default.py(create_file method), it's use '/' to find the app name:

app=path.split('/')[-3]

so, above code will not correct in windows platform, because the path maybe:

D:\project\svn\web2py\applications\admin/..\cookbook/languages/

so the value of app will be:

'..\cookbook'

And I change the apath function to fix this bug:

def apath(path=''): return os.path.join(request.folder,'..',path).replace('\', '/')

I replace all '\' with '/'.

And maybe you need to think about it carefully, and consider maybe you should use: os.path.normcase and os.sep to do these things, just a suggestion.

Attachment: fixcreatelanguage.diff

Original issue: http://code.google.com/p/web2py/issues/detail?id=4

alfonsodg commented 10 years ago

From massimod...@gmail.com on March 02, 2008 19:32:11

Status: Fixed