Re: error psycopg in Django/MacOSX

Daniel França <[email protected]> Mon, 9 Aug 2010 09:54:36 -0300
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
--===============6481229816849172417==
Content-Type: multipart/alternative; boundary=0015175cddd8fe7da0048d638574

--0015175cddd8fe7da0048d638574
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

here:
def create_account(sender, instance=3DNone, **kwargs):
    if instance is None:
        return
    account, created =3D Account.objects.get_or_create(user=3Dinstance)

post_save.connect(create_account, sender=3DUser)

If I comment the *post_save.connect*, there's no exception =3D) but, of cou=
rse
the code doesn't do what it should do.

so, the error is here, but I don't know how to solve, anyone?

2010/8/7 Daniel Fran=E7a <[email protected]>

> I think we are almost there :P
> because there's a timezone field in my account model:
>
> class Account(models.Model):
>
>     user =3D models.ForeignKey(User, unique=3DTrue, verbose_name=3D_('use=
r'))
>
>     timezone =3D TimeZoneField(_('timezone'))
>     language =3D models.CharField(_('language'), max_length=3D10,
> choices=3Dsettings.LANGUAGES, default=3Dsettings.LANGUAGE_CODE)
>
>     def __unicode__(self):
>         return self.user.username
> maybe the error has something to do with it?
>
> 2010/8/5 Daniel Fran=E7a <[email protected]>
>
>> =3D/
>> thanks Daniele, I'll see here what I ca do from now
>>
>> 2010/8/5 Daniele Varrazzo <[email protected]>
>>
>> 2010/8/5 Daniel Fran=E7a <[email protected]>:
>>> > I think I found exactly where the error happens and I reproduced it i=
n
>>> the
>>> > shell:
>>> >>>> from django.contrib.auth.models import User
>>> >>>> new_user =3D User.objects.create_user("daniel", "
>>> [email protected]",
>>> >>>> "daniel")
>>> > Traceback (most recent call last):
>>> ...
>>> > DatabaseError: can't adapt type 'US/Eastern'
>>> > it's when I try to create a new user, maybe it has nothing to do with
>>> > psycopg, right?
>>>
>>> The error is raised by psycopg, but it is due to some external cause.
>>> I've installed Python 2.7 and easy_installed django 1.2.1 and psycopg
>>> 2.2.2: With this setup on Linux I can't reproduce your bug (the user
>>> is created correctly). So the problem seems related to osx or to the
>>> way you have put together your packages.
>>>
>>> I can't be more helpful, sorry: I am not an osx user.
>>>
>>> -- Daniele
>>>
>>
>>
>

--0015175cddd8fe7da0048d638574
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; f=
ont-size: 13px; border-collapse: collapse; "><div>here:</div><div><div><fon=
t color=3D"#CC0000">def create_account(sender, instance=3DNone, **kwargs):<=
/font></div>

<div><font color=3D"#CC0000">=A0=A0 =A0if instance is None:</font></div><di=
v><font color=3D"#CC0000">=A0=A0 =A0 =A0 =A0return</font></div><div class=
=3D"im" style=3D"color: rgb(80, 0, 80); "><div><font color=3D"#CC0000">=A0=
=A0 =A0account, created =3D Account.objects.get_or_create(user=3Dinstance)<=
/font></div>

<div><font color=3D"#CC0000"><br></font></div></div><div><font color=3D"#CC=
0000">post_save.connect(create_account, sender=3DUser)</font></div><div><br=
></div><div>If I comment the=A0<i><b>post_save.connect</b></i>, there&#39;s=
 no exception =3D) but, of course the code doesn&#39;t do what it should do=
.</div>

<div><br></div><div>so, the error is here, but I don&#39;t know how to solv=
e, anyone?</div><div><br></div><div><span class=3D"Apple-style-span" style=
=3D"border-collapse: separate; font-family: arial; font-size: small; ">2010=
/8/7 Daniel Fran=E7a <span dir=3D"ltr">&lt;<a href=3D"mailto:daniel.franca@=
gmail.com">[email protected]</a>&gt;</span></span></div>

</div></span><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><sp=
an style=3D"font-family:arial, sans-serif;font-size:13px;border-collapse:co=
llapse">I think we are almost there :P<div>

because there&#39;s a timezone field in my account model:</div>
<div><br></div><div><div><font color=3D"#CC0000">class Account(models.Model=
):</font></div><div><font color=3D"#CC0000">=A0=A0 =A0</font></div><div><fo=
nt color=3D"#CC0000">=A0=A0 =A0user =3D models.ForeignKey(User, unique=3DTr=
ue, verbose_name=3D_(&#39;user&#39;))</font></div>


<div><font color=3D"#CC0000">=A0=A0 =A0 =A0 =A0</font></div><div><font colo=
r=3D"#CC0000">=A0=A0 =A0timezone =3D TimeZoneField(_(&#39;timezone&#39;))</=
font></div><div><font color=3D"#CC0000">=A0=A0 =A0language =3D models.CharF=
ield(_(&#39;language&#39;), max_length=3D10, choices=3Dsettings.LANGUAGES, =
default=3Dsettings.LANGUAGE_CODE)</font></div>


<div><font color=3D"#CC0000">=A0=A0 =A0</font></div><div><font color=3D"#CC=
0000">=A0=A0 =A0def __unicode__(self):</font></div><div><font color=3D"#CC0=
000">=A0=A0 =A0 =A0 =A0return self.user.username</font></div></div></span><=
div>maybe the error has something to do with it?</div>

<div><div></div><div class=3D"h5">
<br><div class=3D"gmail_quote">2010/8/5 Daniel Fran=E7a <span dir=3D"ltr">&=
lt;<a href=3D"mailto:[email protected]" target=3D"_blank">daniel.fran=
[email protected]</a>&gt;</span><br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>=3D/</div>thanks Daniele, I&#39;ll see here what I ca do from now<div>=
<br><div class=3D"gmail_quote">2010/8/5 Daniele Varrazzo <span dir=3D"ltr">=
&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">daniele=
[email protected]</a>&gt;</span><div>


<div></div><div><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">2010/8/5 Daniel Fran=E7a &lt;<a href=3D"mail=
to:[email protected]" target=3D"_blank">[email protected]</a>&g=
t;:<br>



<div>&gt; I think I found exactly where the error happens and I reproduced =
it in the<br>
&gt; shell:<br>
&gt;&gt;&gt;&gt; from django.contrib.auth.models import User<br>
&gt;&gt;&gt;&gt; new_user =3D User.objects.create_user(&quot;daniel&quot;, =
&quot;<a href=3D"mailto:[email protected]" target=3D"_blank">daniel.f=
[email protected]</a>&quot;,<br>
&gt;&gt;&gt;&gt; &quot;daniel&quot;)<br>
&gt; Traceback (most recent call last):<br>
</div>...<br>
<div>&gt; DatabaseError: can&#39;t adapt type &#39;US/Eastern&#39;<br>
&gt; it&#39;s when I try to create a new user, maybe it has nothing to do w=
ith<br>
&gt; psycopg, right?<br>
<br>
</div>The error is raised by psycopg, but it is due to some external cause.=
<br>
I&#39;ve installed Python 2.7 and easy_installed django 1.2.1 and psycopg<b=
r>
2.2.2: With this setup on Linux I can&#39;t reproduce your bug (the user<br=
>
is created correctly). So the problem seems related to osx or to the<br>
way you have put together your packages.<br>
<br>
I can&#39;t be more helpful, sorry: I am not an osx user.<br>
<font color=3D"#888888"><br>
-- Daniele<br>
</font></blockquote></div></div></div><br></div>
</blockquote></div><br>
</div></div></blockquote></div><br>

--0015175cddd8fe7da0048d638574--

--===============6481229816849172417==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg

--===============6481229816849172417==--