Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Decimal to Decimal nightmare
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Newt  
View profile  
 More options Apr 24 2009, 10:37 am
From: Newt <strejda.n...@gmail.com>
Date: Fri, 24 Apr 2009 07:37:10 -0700 (PDT)
Local: Fri, Apr 24 2009 10:37 am
Subject: Decimal to Decimal nightmare
Hello,

in my latest application I have models with like 15 Decimal fields,
with different decimal places.

when I try to save an object of that model, I get sometimes (often,
but not always) this error:

  File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
item_copy
    object.save()

  File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
in save

  File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
in save_base

  File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 192, in get_db_prep_save

  File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 609, in get_db_prep_value

  File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 583, in to_python

  File "/usr/lib/python2.5/decimal.py", line 650, in __new__
    raise TypeError("Cannot convert %r to Decimal" % value)

TypeError: Cannot convert Decimal("0.0000") to Decimal

It fails on the first decimal field (at it's only one with 4 decimal
places) and it just happens sometimes.
I remember something like that used to happen with psycopg2 some year
ago.

I think it breaks when it tries to get the data ready for the SQL
statement.

In this project I have to use django-pyodbc connector to MSSQL
database.

I have tried both 1.02 and 1.1b branches of the connector with same
errorous results.

It's the most frustrating bug in django so far, as I'm completely
helpless and even google's silent about this.

Please does anyone know what's causing this, or how to get rid of
it...

thanks,

Ales


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
soniiic  
View profile  
 More options Apr 24 2009, 2:45 pm
From: soniiic <soni...@gmail.com>
Date: Fri, 24 Apr 2009 11:45:08 -0700 (PDT)
Local: Fri, Apr 24 2009 2:45 pm
Subject: Re: Decimal to Decimal nightmare
Are you sure you're using it correctly? i googled it and came up with
this which is the exact same position you're in.

This never actually applies a value to be converted but it still tries
and that's what causes the error (i think)

>>> import decimal
>>> d = decimal.Decimal()
>>> reload(decimal)

<module 'decimal' from '/usr/lib/python2.5/decimal.pyc'>
>>> decimal.Decimal(d)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/decimal.py", line 617, in __new__
    raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert Decimal("0") to Decimal

http://mail.python.org/pipermail/python-list/2008-May/665477.html

On Apr 24, 3:37 pm, Newt <strejda.n...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Newt  
View profile  
 More options Apr 25 2009, 6:13 am
From: Newt <strejda.n...@gmail.com>
Date: Sat, 25 Apr 2009 03:13:50 -0700 (PDT)
Local: Sat, Apr 25 2009 6:13 am
Subject: Re: Decimal to Decimal nightmare
Hi,
I'm pretty sure I use it correctly, but don't understand how this
fixes the problem :(.

I looked up the reload in the documentation and all it does a module
reload - where would I place it?
I was thinking i could convert all decimals to strings prior the
saving the new object, but it would not fix updates.

Ales

On Apr 24, 8:45 pm, soniiic <soni...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Dumpleton  
View profile  
 More options Apr 25 2009, 6:40 am
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Sat, 25 Apr 2009 03:40:29 -0700 (PDT)
Local: Sat, Apr 25 2009 6:40 am
Subject: Re: Decimal to Decimal nightmare

On Apr 25, 12:37 am, Newt <strejda.n...@gmail.com> wrote:

The psycopg2 problem was because the C extension module which is a
part of it wasn't implemented correctly so as to work in a Python sub
interpreter. The problems with that would only manifest when using
mod_python or mod_wsgi and application running in sub interpreter and
not main interpreter.

So, to start with, how are you hosting this application?

Graham


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Newt  
View profile  
 More options Apr 25 2009, 7:13 am
From: Newt <strejda.n...@gmail.com>
Date: Sat, 25 Apr 2009 04:13:42 -0700 (PDT)
Local: Sat, Apr 25 2009 7:13 am
Subject: Re: Decimal to Decimal nightmare
I'm running it as mod_python on Ubuntu 8.04 server. I connect to
external MSSQL server thru django-pyodbc, the only thing I had to
install manually was the pyodbc, the rest was installed using package
manager (unix-odbc, freetds). I'm not much a server admin and it was a
few months ago.

Ales

On Apr 25, 12:40 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Dumpleton  
View profile  
 More options Apr 25 2009, 7:17 am
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Sat, 25 Apr 2009 04:17:17 -0700 (PDT)
Local: Sat, Apr 25 2009 7:17 am
Subject: Re: Decimal to Decimal nightmare
Presuming you are only running the one web application on the server,
do things improve it you add directive:

  PythonInterpreter main_interpreter

to Apache configuration.

If it doesn't, not the same issue as pyscopg2.

Graham

On Apr 25, 9:13 pm, Newt <strejda.n...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Newt  
View profile  
 More options Apr 25 2009, 8:06 am
From: Newt <strejda.n...@gmail.com>
Date: Sat, 25 Apr 2009 05:06:45 -0700 (PDT)
Local: Sat, Apr 25 2009 8:06 am
Subject: Re: Decimal to Decimal nightmare
Thank you very much,
yes, it's the only app (well I have a production and development
version of the same application running there).
The production version is dj 1.0.2
The development version is dj 1.1b - with the trunk version of django-
pyodbc - but I switched to this version in desperate response to this
problem. I hope it's no problem.

Also i found this stuff in vhost configs:
    PythonDebug On
    PythonAutoReload On

So I commented these and added the interpreter directive. And now I'll
try it...

Ales

On Apr 25, 1:17 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Dumpleton  
View profile  
 More options Apr 25 2009, 8:37 am
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Sat, 25 Apr 2009 05:37:57 -0700 (PDT)
Local: Sat, Apr 25 2009 8:37 am
Subject: Re: Decimal to Decimal nightmare

On Apr 25, 10:06 pm, Newt <strejda.n...@gmail.com> wrote:

> Thank you very much,
> yes, it's the only app (well I have a production and development
> version of the same application running there).
> The production version is dj 1.0.2
> The development version is dj 1.1b - with the trunk version of django-
> pyodbc - but I switched to this version in desperate response to this
> problem. I hope it's no problem.

> Also i found this stuff in vhost configs:
>     PythonDebug On
>     PythonAutoReload On

Commenting out PythonAutoReload will not make any difference as On is
the default for mod_python anyway. Also, that option has no bearing on
Django use anyway, and only applies to mod_python's own internal
module importer, which doesn't really get used in any way, at least to
load modules, when Django is being run.

Graham


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »