use_unicode and convert_unicode should not be used together.
use_unicode makes MySQLdb convert the database values to Unicode.
convert_unicode does the same thing in SQLAlchemy..  encoding twice
will lead to exceptions or wrong values if there are any non-ASCII
characters. If users paste text into forms from Word, they'll contain
curly quotes, bullet characters, 1/2 ligatures, degree symbols,
accented letters, etc.

But you are getting errors that don't make any sense, so who knows
what's happening on your server.  There should be no relationship
between SQLAlchemy settings and url_for.

On 10/31/07, SamDonaldson <[EMAIL PROTECTED]> wrote:
>
> On my dev machine running pastehttpserver, I noticed that it only
> works if I use the use_unicode=1 param on my db uri, even after
> passing in the convert_unicode and encoding params to create_engine
> (note that I'm calling my own create_engine).
>
> Thanks,
>
> Saureen
>
> On Oct 30, 10:25 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote:
> > On 10/30/07, SamDonaldson <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > Hello,
> >
> > > I ran into another problem on production, where, if I add the
> > > use_unicode parameter on the mysql:// URI, I get back unicode but I
> > > see that I get a crash in a particular case with the following stack:
> >
> > > Module pylons.helpers:65 in redirect_to
> > > <<      and cookies extracted from it and added into the redirect
> > > issued.    and cookies extracted from it and added into the redirect
> > > issued."""
> > >         response = kargs.pop('_response', None)
> > >         found = httpexceptions.HTTPFound(url_for(*args, **kargs))
> > >         if response:
> > >             if str(response.status_code).startswith('3'):>>  found =
> > > httpexceptions.HTTPFound(url_for(*args, **kargs))
> > > Module routes.util:200 in url_for
> > > <<
> > >         if not isinstance(url, str) and url is not None:
> > >             raise Exception("url_for can only return a string or None,
> > > got "
> > >                             " unicode instead: %s" % url)>>  raise
> > > Exception("url_for can only return a string or None, got "
> > > Exception: url_for can only return a string or None, got unicode
> > > instead:
> >
> > > There's an explicity check on 'str' to see if it's an instance even
> > > thought it's a unicode object.  How do I get this to work with
> > > Unicode? Note, I don't get this problem on my dev environment.  On
> > > production I'm running SCGI + Lighthttpd.
> >
> > That's really strange, both this and your other error.  Of course, any
> > time str and unicode are used together in an expression, the str gets
> > promoted to unicode. So one place to start would be to look back ward
> > thorough the code and look at the intermediate variables: where was a
> > unicode value first introduced? In your routes definitions? Do they
> > show up in the route map result? What does url_for return in "paster
> > shell"?
> >
> > scgi is of course a different environment than pastehttpserver.
> > Perhaps pastehttpserver is more forgiving about converting unicode to
> > str while scgi just raises an exception.  'use_unicode' is
> > disrecommended now; the engine option 'convert_unicode' is recommended
> > instead.
> >
> > --
> > Mike Orr <[EMAIL PROTECTED]>
>
>
> >
>


-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to