Switching content-types from dexterity.Item to dexterity.Container

99 views
Skip to first unread message

Noe Nieto

unread,
Jan 22, 2012, 1:15:16 AM1/22/12
to dexterity-...@googlegroups.com
I ran into a situation where some custom content tyes (which were created in the ZODB as a subclass of dexterity.Item) now need to be containters.

I'm planning to do the conversion using transmogrifier, but I was wondering if someone has run into similar situation and if so, which tool or technique has used?

--
---
Noe Nieto
NNieto Consulting Services
M: nni...@noenieto.com
W: http://noenieto.com
T:  @tzicatl
Li: Perfil en LinkedIn

Martin Aspeli

unread,
Jan 22, 2012, 4:54:36 AM1/22/12
to dexterity-...@googlegroups.com
On 22 January 2012 06:15, Noe Nieto <nni...@noenieto.com> wrote:
> I ran into a situation where some custom content tyes (which were created in
> the ZODB as a subclass of dexterity.Item) now need to be containters.
>
> I'm planning to do the conversion using transmogrifier, but I was wondering
> if someone has run into similar situation and if so, which tool or technique
> has used?

If the types are otherwise compatible, you can probably write a
migration script that just switches the __class__ of every instance in
the ZODB.

Martin

David Glick

unread,
Jan 22, 2012, 12:22:49 PM1/22/12
to dexterity-...@googlegroups.com, Martin Aspeli
I doubt that will be sufficient, since containers have internal data
structures that would need to get set up in order for the object to
function as a container. (See the migration to BTree-based folders in
plone.app.folder for some hints about what those are.)

This question has come up a few times, so I would like to provide a
utility to assist with making this change in Dexterity. But I haven't
had a chance to write it yet. Anyone else want to have a go at it?

cheers,
David

Sean Upton

unread,
Jan 22, 2012, 2:23:58 PM1/22/12
to dexterity-...@googlegroups.com, Martin Aspeli
On Sun, Jan 22, 2012 at 10:22 AM, David Glick <dgl...@gmail.com> wrote:
> On 1/22/12 1:54 AM, Martin Aspeli wrote:
>>
>> On 22 January 2012 06:15, Noe Nieto<nni...@noenieto.com>  wrote:
>>>
>>> I ran into a situation where some custom content tyes (which were created
>>> in
>>> the ZODB as a subclass of dexterity.Item) now need to be containters.
>>>
>>> I'm planning to do the conversion using transmogrifier, but I was
>>> wondering
>>> if someone has run into similar situation and if so, which tool or
>>> technique
>>> has used?
>>
>> If the types are otherwise compatible, you can probably write a
>> migration script that just switches the __class__ of every instance in
>> the ZODB.

I think I ran into ZODB-related limitations of this for which anything
other than an offline approach like zodbupdate would not work. I
cannot remember what they are at the moment, though.


> I doubt that will be sufficient, since containers have internal data
> structures that would need to get set up in order for the object to function
> as a container. (See the migration to BTree-based folders in
> plone.app.folder for some hints about what those are.)
>
> This question has come up a few times, so I would like to provide a utility
> to assist with making this change in Dexterity. But I haven't had a chance
> to write it yet. Anyone else want to have a go at it?

I might be willing to take a look at this again.

I punted on this problem, but when I was looking into it for myself,
as an alternative, I tried replacing the state of a newly constructed
Container with the state of an item, but this would fail for the
reasons you have documented. Below is a not-yet-working example of
what I was attempting many months back:

https://teamspace.upiq.org/trac/wiki/DexterityClassMigration

I think there may be some way to selectively copy parts of the state
of the old object to a new container and then finally replace the item
with a new container with copied/merged state of the Item it is
replacing.

Sean

Noe Nieto

unread,
Jan 27, 2012, 11:21:00 PM1/27/12
to dexterity-...@googlegroups.com
Just to let you know, I wrote an upgrade step for my product to first rename the content-types and then create a new one with the original id and the rest of the fields (since they did't change).

---
Noe

2012/1/22 David Glick <dgl...@gmail.com>


--
You received this message because you are subscribed to the Google Groups "Dexterity development" group.
To post to this group, send email to dexterity-development@googlegroups.com.
To unsubscribe from this group, send email to dexterity-development+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dexterity-development?hl=en.

Reply all
Reply to author
Forward
0 new messages