I'm no expert on encodings so I can only suggest some alternatives that
might get around the issue:

First, maybe you can find something here:
http://docs.python.org/howto/unicode

You could try the literal method of generating a unicode string:

path = u'%s%s' % (ROOT, name)

Where exactly do you get the UnicodeEncodeError exception when you remove
the unicode calls?

On Wed, Aug 4, 2010 at 11:00 AM, sohesado <gnubun...@gmail.com> wrote:

> Well your example clarifies the problem. I removed the unicode calls.
>
> The initial problem was an  UnicodeEncodeError exception. I tried to
> solve it by encoding the strings to utf-8. It seems that's not the
> case.
> So i'm at square one.
>
> Note that..
> -with python manage.py runserver the app runs flawlessly.
> -With apache+mod-python i get an UnicodeEncodeError.
>
> So , it is an apache localization issue?
>
> My /etc/apache2/envvars contains
>
>
> ------------------------------------------------------------------------------------------------
> export APACHE_RUN_USER=www-data
> export APACHE_RUN_GROUP=www-data
> export APACHE_PID_FILE=/var/run/apache2.pid
>
> ## The locale used by some modules like mod_dav
> export LANG='el_GR.UTF8'    <- also tried el_GR.UTF-8 variation
> export LC_ALL='el_GR.UTF8'
> ## Uncomment the following line to use the system default locale
> instead:
> #. /etc/default/locale
>
> export LANG
>
> ---------------------------------------------------------------------------------------------------------
>
> Have you got any clues what may cause the problem?
>
> Thank you for your help.
>
> On Aug 3, 11:31 pm, Alec Shaner <asha...@chumpland.org> wrote:
> > unicode gives me nightmares.
> >
> > Taking django out of the picture for a moment:>>> unicode('foo', 'utf-8')
> > u'foo'
> > >>> unicode(u'foo', 'utf-8')
> >
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > TypeError: decoding Unicode is not supported
> >
> > So I would assume when you run it inside django you're already using a
> > unicode string. Do you need to pass the encoding argument ('utf-8') to
> > unicode?
> >
> > On Tue, Aug 3, 2010 at 3:30 PM, sohesado <gnubun...@gmail.com> wrote:
> > > Hi
> >
> > > I'm currently developing a django project and i've encountered a
> > > problem regarding Unicode string manipulation.
> >
> > > There is a backend python module in my project that perform's mainly
> > > shutil (shell utilities) tasks.
> >
> > > I get an TypeError: "decoding Unicode is not supported" exception
> > > while running the following method
> >
> > >
> ---------------------------------------------------------------------------------------------------------
> > > def create_base(name, reg):
> > >    path = unicode(ROOT + name, 'utf-8') <<<< error at this line
> > >    shutil.copytree(ROOT + 'matrix', path)
> > >    shutil.copystat(ROOT + 'matrix', path)
> >
> > >    f = codecs.open(path + '/conf/local.php', "w", "UTF-8")
> > >    tmp = unicode("<?php\n$conf['title'] = " + name + ";\n", 'utf-8')
> > >    f.write(tmp)
> > >    if not reg:
> > >        f.write("$conf['disableactions'] = 'register';\n")
> >
> > >
> -------------------------------------------------------------------------------------------------------
> >
> > > The weird thing that puzzles me is that when i test the module in a
> > > python shell , the method runs flawlessly which yields me to the
> > > assumption that it's a django thing.
> > > By the way i use apache+mod-python as a web-server
> >
> > > I can't get adequate information regarding this type of exception. I'm
> > > stuck , please help.
> >
> > > --
> > > 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<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@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<django-users%2bunsubscr...@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