zope.generations and IIntIds issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

zope.generations and IIntIds issue

jmichiel
Hi,

I'm trying to evolve my database using zope.generations, but I'm running into trouble using IIntIds.
Trying to get the Id of an object out of my DB (using getId) raises a KeyError.

While debugging, I found out that the intid utility contains plenty of KeyReferences in its ids attribute, and that creating a KeyReference from the object also works, but apparently the keyreference is not found in the ids list of the utility...

Any ideas why this could be happening?
thx!
Reply | Threaded
Open this post in threaded view
|

Re: zope.generations and IIntIds issue

Christian Klinger
Hi Jeroen,

sorry i don't a answer for your question. I guess this is not a grok
related problem, so i recommend to put this post on

gmane.comp.web.zope.devel

too. You will reach more people there.

Christian

>
> Hi,
>
> I'm trying to evolve my database using zope.generations, but I'm running
> into trouble using IIntIds.
> Trying to get the Id of an object out of my DB (using getId) raises a
> KeyError.
>
> While debugging, I found out that the intid utility contains plenty of
> KeyReferences in its ids attribute, and that creating a KeyReference from
> the object also works, but apparently the keyreference is not found in the
> ids list of the utility...
>
> Any ideas why this could be happening?
> thx!


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: zope.generations and IIntIds issue

jmichiel
I solved the problem using a different approach.
What I was doing was this: in my previous generation I has a class that derived from grok.Model, and in my current generation, I need it to be a grok.Container, so I needed to do some trickery to get the old data from the database to be able to create a new instance. Maybe that confused the KeyReference creation somehow. That's why I put it in grok-dev, but forgot to mention it ;-)

Now that I'm at it: what is the recommended way to do something like that?
I moved the old class definition to my evolveX script, and before loading the old instances from the db, I replaced the new definition in the appropriate module with the old one, and before creating new instances, I switched the definitions back to normal. That seemed to do the trick. However, is there a nicer way to do it, or a way to just upgrade existing instances to the new definition without having the create new ones and copying the old data?

Christian Klinger wrote
Hi Jeroen,

sorry i don't a answer for your question. I guess this is not a grok
related problem, so i recommend to put this post on

gmane.comp.web.zope.devel

too. You will reach more people there.

Christian

_______________________________________________
Grok-dev mailing list
Grok-dev@zope.org
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: zope.generations and IIntIds issue

Christian Klinger
Hi Jeroen,

i am not sure if i understand you correctly. But maybe the
zodbupdate [1], helps you to archive this task.


Christian

[1] http://pypi.python.org/pypi/zodbupdate/0.5

>
> I solved the problem using a different approach.
> What I was doing was this: in my previous generation I has a class that
> derived from grok.Model, and in my current generation, I need it to be a
> grok.Container, so I needed to do some trickery to get the old data from the
> database to be able to create a new instance. Maybe that confused the
> KeyReference creation somehow. That's why I put it in grok-dev, but forgot
> to mention it ;-)
>
> Now that I'm at it: what is the recommended way to do something like that?
> I moved the old class definition to my evolveX script, and before loading
> the old instances from the db, I replaced the new definition in the
> appropriate module with the old one, and before creating new instances, I
> switched the definitions back to normal. That seemed to do the trick.
> However, is there a nicer way to do it, or a way to just upgrade existing
> instances to the new definition without having the create new ones and
> copying the old data?
>
>
> Christian Klinger wrote:
>>
>> Hi Jeroen,
>>
>> sorry i don't a answer for your question. I guess this is not a grok
>> related problem, so i recommend to put this post on
>>
>> gmane.comp.web.zope.devel
>>
>> too. You will reach more people there.
>>
>> Christian
>>
>> _______________________________________________
>> Grok-dev mailing list
>> [hidden email]
>> https://mail.zope.org/mailman/listinfo/grok-dev
>>
>>
>


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: zope.generations and IIntIds issue

jmichiel
I didn't really move or rename classes, I changed a class's baseclass.
I'm not sure zodbupdate will cover that...

Christian Klinger wrote
Hi Jeroen,

i am not sure if i understand you correctly. But maybe the
zodbupdate [1], helps you to archive this task.


Christian

[1] http://pypi.python.org/pypi/zodbupdate/0.5

_______________________________________________
Grok-dev mailing list
Grok-dev@zope.org
https://mail.zope.org/mailman/listinfo/grok-dev