Here's my problem. I want to redirect my urls by the name of its
model, like this:
urls.py:


    (r'^(?P<model>\w+)/$',         'urlCatcher'),
    (r'^(?P<model>\w+)/(?P<action>\w+)/$',         'urlCatcher'),
    (r'^(?P<model>\w+)/(?P<action>\w+)/(?P<code>\w+)/$',
'urlCatcher'),

here's the function in the views.py:

    def urlCatcher(request, model='', action='', code=''):
...
# the action and the name are stick together and use to redirect to
their own template.

    locals_dict.update({ 'model':model, 'action':action })
    key = '%s%s' % (action, model.capitalize())

   try:
        if not code:
            if key != '':
            # I use a callback to take the locals from the functions
(all return a dict with template, lists,...)
                locals_dict.update({

                  'Account':userProfile,
                  'deletedRss':userProfile,
                  'addedRss':userProfile,
                  'changedRss':userProfile,
                  'listenRss':userProfile,
                  'deletedUsers':userProfile,
                  ...
                  'deletedQuotes':userProfile,
                  'deletedWeather':userProfile,
                  'getWeather':userProfile,
                  'listenWeather':userProfile,
                  'getQuotes':userProfile,

                  }[key](request))

...

userProfile, the function:

    locals_dict.update({ 'templateName':"user_account.html",
                         'user_list':user_list,
                         'weather_list':weather_list,
                         ...

                        })
    return locals_dict

Here's the redirection to the target anchor:

    try:
        # hack
        # if locals_dict['redir'] exists, is true
        print "ooo    %s - message : %s  oo" % (locals_dict['redir'],
locals_dict.get('message'))
        if model:
            #print "ooo    %s  ooo" % model
            if model == 'users' or model == 'im':
                model = 'contacts'
            elif model == 'quotes':
                model = 'markets'

            return HttpResponseRedirect("/account/#%s" % (model))


All is fine,except a reload from the page when it goes to the anchor.
But this is not my big problem.
My problem is when I press the button to send a message with a
character like 'ç':

 * Erreur : 'ascii' codec can't encode character u'\xe7' in position
0: ordinal not in range(128)

I have on top of all my files:
     # -*- coding: utf-8 -*-

and in my settings:
    DEFAULT_CONTENT_TYPE = 'text/html; charset=utf-8'

and in my form:
    <form action="/mdfihm/im/sent/" accept-charset="utf-8"
method="post">

I also have problem with path_info:
path_url = request.META['PATH_INFO']

    #in dev
    URL = "/mysite"

    # server apache in production
    URL = ""

I have an apache2 server with ubuntu 8.04 in production.










--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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