1.  Why is this view code in urls.py?

2.  What is the value of subdir_path in the trace back?  (There's a
little arrow you can click to
see the variable values fro the frame.)

2010/4/7 Alexey Vlasov <ren...@renton.name>:
> Hi.
>
> There's a simple code in urls.py:
> ==============
> def ls (request):
>    import os
>
>    out_html = ''
>    home_path = '/home/www/test-django'
>    # subdir_path = request.GET.get ('subdir')
>    subdir_path = 'public_html'
>
>    for root, dirs, files in os.walk (os.path.join (home_path, subdir_path)):
>        out_html += "%s<br/>\n" % root
>
>    return HttpResponse (out_html)
> ==============
>
> There's a catalogue in "home_path/subdir_path" which name
> includes cyrillic symbols (фыва):
> $ pwd
> /home/www/test-django/public_html
> $ ls -la
> drwx---r-x  4 test-django test-django  111 Apr  6 20:26 .
> drwx--x--- 13 test-django test-django 4096 Apr  6 20:26 ..
> -rw-r--r--  1 test-django test-django  201 Apr  6 17:43 .htaccess
> -rwxr-xr-x  1 test-django test-django  911 Apr  6 16:38 index.fcgi
> lrwxrwxrwx  1 test-django test-django   66 Mar 28 17:34 media -> ../
> python/lib64/python2.5/site-packages/django/contrib/admin/media
> drwxr-xr-x  2 test-django test-django    6 Apr  6 15:48 фыва
>
> My code works correct, here's the result:
> $ curl -s http://test-django.example.com/ls/
> /home/www/test-django/public_html <br/>
> /home/www/test-django/public_html/фыва<br/>
>
> But if I change "subdir_path = 'public_html'" to
> "subdir_path = request.GET.get ('subdir')" then the request:
> $ curl -s http://test-django.example.com/ls/\?subdir=public_html
> leads to an error:
>
> Request Method: GET
> Request URL: http:// test-django.example.com/ls/
> Django Version: 1.0.2 final
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "/home/www/test-django/python/lib64/python2.5/
> site-packages/django/core/handlers/base.py" in get_response
>  86.                 response = callback(request, *callback_args, 
> **callback_kwargs)
> File "/home/www/test-django/django/demo/urls.py" in ls
>  40.     for root, dirs, files in os.walk (os.path.join (home_path, 
> subdir_path)):
> File "/usr/lib64/python2.5/os.py" in walk
>  293.         if isdir(join(top, name)):
> File "/usr/lib64/python2.5/posixpath.py" in isdir
>  195.         st = os.stat(path)
>
> Exception Type: UnicodeEncodeError at /ls/
> Exception Value: 'ascii' codec can't encode characters in position
>  45-48: ordinal not in range(128)
>
> I don't understand it why "subdir_path" getting the same very value in one 
> case works perfectly and in the
> +other fails.
>
> Django runs following the instuctions
> +http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-wit
> +h-apache
>
> --
> BRGDS. Alexey Vlasov.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to