Caching issue cache.py line 161

2006-08-18 Thread xgdlm

Hello all,

I'm face an issue while using the cache middleware :

[Fri Aug 18 13:00:52 2006] [error] [client 10.0.0.199] PythonHandler
django.core.handlers.modpython:   File
"/usr/lib/python2.4/site-packages/django/utils/cache.py", line 161, in
learn_cache_key\ncache.set(cache_key, headerlist, cache_timeout)

[Fri Aug 18 13:00:52 2006] [error] [client 10.0.0.199] PythonHandler
django.core.handlers.modpython:   File
"/usr/lib/python2.4/site-packages/django/core/cache/backends/filebased.py",
line 48, in set\npickle.dump(now + timeout, f, 2)

[Fri Aug 18 13:00:52 2006] [error] [client 10.0.0.199] PythonHandler
django.core.handlers.modpython: TypeError: unsupported operand type(s)
for +: 'float' and 'str'

Changing /usr/lib/python2.4/site-packages/django/middleware/cache.py
line 161 to

self.cache_timeout = int(settings.CACHE_MIDDLEWARE_SECONDS) solved the
problem.

I'm running :

mod_python 3.1.4-r1
apache 2.0.58-r2
python 2.4.3-r1

Settings :
#CACHE_BACKEND = 'memcached://127.0.0.1:22162/'
CACHE_MIDDLEWARE_SECONDS = '300'
CACHE_MIDDLEWARE_KEY_PREFIX = 'djan_'
CACHE_BACKEND = 'file:///home/django/cache'


I've just svn django source from trunk

Regards,

xav


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



Re: Caching issue cache.py line 161

2006-08-18 Thread xgdlm


Malcolm Tredinnick wrote:
> On Fri, 2006-08-18 at 11:14 +0000, xgdlm wrote:
> So stop passing it as a string. Set CACHE_MIDDLEWARE_SECONDS = 300 (no
> quotes) and you will be fine.

Thanks for your answer Malcom. This was the trick. I was pretty sure to
have done the test before posting, but now I realize that I'm running
on apache2 and not on the dev server (must have forgotten to reload
it).

Of course it's working fine now :)

Sorry for the noise,

xav


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



Re: Potential bug in django.core.handlers.modpython ?

2006-10-16 Thread xgdlm

DavidA wrote:
> But under mod_python, request.META['PATH_INFO'] is '/pos/' while in the
> development server its '/data/pos/' (which I think is right).

I notice the same problem here. Running Apache 2.0.58-r2 and mod_python
3.1.4-r1 on a gentoo box.

for instance :





I'm not using this variable right now in my projects, but I think you
are right there is something weird here .

Regards,

xav


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



CommaSeparatedIntegerField and SelectMultipleField

2006-10-30 Thread xgdlm

Hello all,

I would like to have a Multiple Select box, render the chosen fields of
a
CommaSeparatedIntegerField.

The CommaSeparatedIntegerField stores the ability of a user to move to
a given
area :

--
Mobility =
models.CommaSeparatedIntegerField(maxlength=70,choices=REGION_CHOICES)

- Choices are build using the following statement :

REGION_CHOICES = [(region.id,region.name) for region in
Region.objects.all() ]

- The form manipulator for this field is described as :

 forms.SelectMultipleField(field_name="Mobility",
size=7,is_required=True,choices=REGION_CHOICES),

--

The form is correctly render. Users are able to choose and save there
choices
without problem.

But I have trouble to get choices with value over 10 to be selected
while
editing it !

for exemple if a user select choice number 23. When he comes back to
edit the
form values '2' and '3' will be selected and not '23'.

if the user selectes choices '1' and '23' and save it the database
entry shows
1,23
and the select box will have choices '1' '2' and '3' slected but not
'1' and
'23'

I was wondering how to get to two digits values selected ?

Thanks in advance for your hints 

xav


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



Can't handle newforms

2007-03-30 Thread xgdlm

Hello All,

Django brings me to python ... so I'm not a python specialist. I wish
I could you the newforms library and get rid of the oldforms in my
django projects. But I can't use newforms with French language. I read
a lot of problems with unicode strings and special caracters. But I
couldn't resolve my problem.

Here is my configuration :

* DEFAULT_CHARSET = 'utf-8' in global_settings.py
* sys.setdefaultencoding('utf-8') sitecustomize.py
* DB tables encoded as utf8_general_ci

for exemple if I run :

from django.newforms import *
w = SelectMultiple()
print w.render('beatles', ['J', 'P', 'R'], choices=(('J', 'Johné'),
('P', 'Paulà')))

I got :
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 86: ordinal not in range(128)

I don't know where to look for and how to solve this problem. I'm
wondering if this is a system error due to local settings or if it's a
django problem.

Any help or comments appreciated.

xav


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



Re: Can't handle newforms

2007-03-30 Thread xgdlm

Thanks for your reply Malcolm

> Hmm... this precise example works for me. Are you using a reasonably
> recent release (like 0.96)? I remember there was a unicode fix that went
> in not too long ago to add smart_unicode() calls in various places for
> things just like this.

I'm running 0.96 and my newforms code is including the smart_unicode()
fix posted a month ago.

>
> If you are using a recent release, can you get rid of the call to
> setdefaultencoding() and see if it still fails?

I get rid of this hack but the problem still remain. As you mention
the used codec is now utf8 rather than ascii ;)

here is the complete debug :

# python manage.py shell
Python 2.4.3 (#1, Oct 27 2006, 16:05:30)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.newforms import *
>>> w = SelectMultiple()
>>> print w.render('beatles', ['J', 'P', 'R'], choices=(('J', 'Johné'),('P', 
>>> 'Paulà')))
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/newforms/widgets.py",
line 198, in render
output.append(u'%s' %
(escape(option_value), selected_html,
escape(smart_unicode(option_label
  File "/usr/lib/python2.4/site-packages/django/newforms/util.py",
line 15, in smart_unicode
s = unicode(s, settings.DEFAULT_CHARSET)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 4:
unexpected end of data
>>>


> If it does, then we need
> to try and work out what is different between your system and mine a bit
> more.

So It seems this is a system problem and not django .. I whish I could
find where and what to look for in order to solve this problem.

Thanks

xav


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



Re: Can't handle newforms

2007-03-30 Thread xgdlm

adding
DEFAULT_CHARSET = 'iso8859-15'
to my settings.py solves this issue.

I'm wondering how to have  a complete UTF-8 system :)
anyway thanks all for your investigations.

xav


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



Re: Can't handle newforms

2007-03-30 Thread xgdlm

Hello,

> what is the output of running "locale" in a console?

# locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

You may be right, because I didn't try to use newforms within a
view ... but just within the python shell. I going right a way to give
a try with both settings within a real view :)

xav


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



Re: Can't handle newforms

2007-03-30 Thread xgdlm



On 30 mar, 14:15, Gábor Farkas <[EMAIL PROTECTED]> wrote:
> what is the output of running "locale" in a console?

gabor,

Your are right ! I remaoved my DEFAULT_CHARSET = 'iso8859-15'  from my
settings. Created a view to render a newform created form and
everything is working find. So this is due to the "print" command in a
funky console environement.

Wow I can't belive I didn't use newforms earlier because the print
didn't work in my python shell. As I'm a linux kind of guy, I'm always
trying things first in a shell environement ... :)

Good .. I can now upgrade all the forms I have :)

Thanks all for your investingations :p

xav


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