How to set created or modified date of a dexterity content type instance?

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

How to set created or modified date of a dexterity content type instance?

Hi, there
        Nowadays I migrate a Plone2.5 site to Plone4.1. I create a Dexterity content type called 'Web page', then I write a migration product to export all old data and import them as 'Web page' instances, all works OK except I can't find a way to reset created and modified date to an old date, I used the following code to do this job, works well for old Archtype content type but not Dexterity, whats the secret?

instance.setCreationDate(date)
instance.setModificationDate(date)
instance.reindexObject()

best regards
jiangdongjin


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|

Re: How to set created or modified date of a dexterity content type instance?

On 5/27/12 10:13 PM, eastxing wrote:

> Hi, there
>         Nowadays I migrate a Plone2.5 site to Plone4.1. I create a
> Dexterity content type called 'Web page', then I write a migration
> product to export all old data and import them as 'Web page'
> instances, all works OK except I can't find a way to reset created and
> modified date to an old date, I used the following code to do this
> job, works well for old Archtype content type but not Dexterity, whats
> the secret?
>
> instance.setCreationDate(date)
> instance.setModificationDate(date)
> instance.reindexObject()
>
The Dublin core metadata fields are implemented in
Products.Archetypes.ExtensibleMetadata for Archetypes content, but for
Dexterity we used the implementation in Products.CMFDefault.DublinCore.
There are some slight differences and it looks like you found one here.
setModificationDate is there for Dexterity content, but there's no
setCreationDate. Instead, you could set the creation_date attribute of
the item directly.

At some point I intend to move the implementations for these fields
inline into plone.dexterity, and at that point I'll add the missing
setCreationDate method.

David


----------
David Glick
 Web Developer
 [hidden email]
 206.286.1235x32

Are you engaging? Find out! Use our free engagement benchmarking tool.

http://groundwire.org/labs/engagement-strategy/diy-benchmarking-survey



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
anzsoft anzsoft
Reply | Threaded
Open this post in threaded view
|

Re: How to set created or modified date of a dexterity content type instance?

Thanks for the answer and sorry for not return for a long time.
At last I found the solution at this blog, use the following code to set created and modified date:

date = DateTime('an old date')
#instance.setCreationDate(date)
instance.creation_date = date
instance.setModificationDate(date)
instance.reindexObject(idxs=['created', 'modified'])

Best regards

2012/5/31 David Glick <[hidden email]>
On 5/27/12 10:13 PM, eastxing wrote:
Hi, there
        Nowadays I migrate a Plone2.5 site to Plone4.1. I create a Dexterity content type called 'Web page', then I write a migration product to export all old data and import them as 'Web page' instances, all works OK except I can't find a way to reset created and modified date to an old date, I used the following code to do this job, works well for old Archtype content type but not Dexterity, whats the secret?

instance.setCreationDate(date)
instance.setModificationDate(date)
instance.reindexObject()

The Dublin core metadata fields are implemented in Products.Archetypes.ExtensibleMetadata for Archetypes content, but for Dexterity we used the implementation in Products.CMFDefault.DublinCore. There are some slight differences and it looks like you found one here. setModificationDate is there for Dexterity content, but there's no setCreationDate. Instead, you could set the creation_date attribute of the item directly.

At some point I intend to move the implementations for these fields inline into plone.dexterity, and at that point I'll add the missing setCreationDate method.

David


----------              
David Glick
Web Developer
[hidden email]
206.286.1235x32

Are you engaging? Find out! Use our free engagement benchmarking tool.

http://groundwire.org/labs/engagement-strategy/diy-benchmarking-survey




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Peter Fraterdeus Peter Fraterdeus
Reply | Threaded
Open this post in threaded view
|

Re: How to set created or modified date of a dexterity content type instance?

Hello Eastxing!
I'd love to see your migration product if you're able to share.
Will it work on any 2.5 site?
I'm struggling to find the time to attempt a migration from 2.5 to 4.x, have nearly given up and thinking of moving to WordPress. :/

Many thanks!

•=^=•=^=•=^=•=^=•=^=•=^=
Peter Fraterdeus

On Jul 6, 2012, at 1:23 AM, eastxing <[hidden email]> wrote:

Thanks for the answer and sorry for not return for a long time.
At last I found the solution at this blog, use the following code to set created and modified date:

date = DateTime('an old date')
#instance.setCreationDate(date)
instance.creation_date = date
instance.setModificationDate(date)
instance.reindexObject(idxs=['created', 'modified'])

Best regards

2012/5/31 David Glick <[hidden email]>
On 5/27/12 10:13 PM, eastxing wrote:
Hi, there
        Nowadays I migrate a Plone2.5 site to Plone4.1. I create a Dexterity content type called 'Web page', then I write a migration product to export all old data and import them as 'Web page' instances, all works OK except I can't find a way to reset created and modified date to an old date, I used the following code to do this job, works well for old Archtype content type but not Dexterity, whats the secret?

instance.setCreationDate(date)
instance.setModificationDate(date)
instance.reindexObject()

The Dublin core metadata fields are implemented in Products.Archetypes.ExtensibleMetadata for Archetypes content, but for Dexterity we used the implementation in Products.CMFDefault.DublinCore. There are some slight differences and it looks like you found one here. setModificationDate is there for Dexterity content, but there's no setCreationDate. Instead, you could set the creation_date attribute of the item directly.

At some point I intend to move the implementations for these fields inline into plone.dexterity, and at that point I'll add the missing setCreationDate method.

David


----------              
David Glick
Web Developer
[hidden email]
206.286.1235x32

Are you engaging? Find out! Use our free engagement benchmarking tool.

http://groundwire.org/labs/engagement-strategy/diy-benchmarking-survey



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
anzsoft anzsoft
Reply | Threaded
Open this post in threaded view
|

Re: How to set created or modified date of a dexterity content type instance?

Hi there,
    Its not a common used migration product, but some export/import script suit my project. The following are my migration process, hope it can help.

1. Export data from Plone2.5;
I write a browser view to export data.

Exported data include:

- metadata
id, title, description, creator, created, modified, workflow info, path, ...
saved into a file named meta.ini

- body content
html format content
saved into a file named body.html

- attachments
binary files
saved as original binary file

then zip all those files into a single zip file.

2. Import data into Plone4.1;
I Write a browser view to import data:
copy all zip files into file system where Plone4.1 installed;
read zip files one by one, parse meta.ini file;
create new content type instance(dexterity based new content type);
set attributes and attachments and other data;
at last reset created and modified date.

If you have source code of  old Product, I suggest you write your own migration scripts to do the job, not necessary to use Plone's migration framework.

Best regards
eastxing

2012/7/6 Peter Fraterdeus <[hidden email]>
Hello Eastxing!
I'd love to see your migration product if you're able to share.
Will it work on any 2.5 site?
I'm struggling to find the time to attempt a migration from 2.5 to 4.x, have nearly given up and thinking of moving to WordPress. :/

Many thanks!

•=^=•=^=•=^=•=^=•=^=•=^=
Peter Fraterdeus

On Jul 6, 2012, at 1:23 AM, eastxing <[hidden email]> wrote:

Thanks for the answer and sorry for not return for a long time.
At last I found the solution at this blog, use the following code to set created and modified date:

date = DateTime('an old date')
#instance.setCreationDate(date)
instance.creation_date = date
instance.setModificationDate(date)
instance.reindexObject(idxs=['created', 'modified'])

Best regards

2012/5/31 David Glick <[hidden email]>
On 5/27/12 10:13 PM, eastxing wrote:
Hi, there
        Nowadays I migrate a Plone2.5 site to Plone4.1. I create a Dexterity content type called 'Web page', then I write a migration product to export all old data and import them as 'Web page' instances, all works OK except I can't find a way to reset created and modified date to an old date, I used the following code to do this job, works well for old Archtype content type but not Dexterity, whats the secret?

instance.setCreationDate(date)
instance.setModificationDate(date)
instance.reindexObject()

The Dublin core metadata fields are implemented in Products.Archetypes.ExtensibleMetadata for Archetypes content, but for Dexterity we used the implementation in Products.CMFDefault.DublinCore. There are some slight differences and it looks like you found one here. setModificationDate is there for Dexterity content, but there's no setCreationDate. Instead, you could set the creation_date attribute of the item directly.

At some point I intend to move the implementations for these fields inline into plone.dexterity, and at that point I'll add the missing setCreationDate method.

David


----------              
David Glick
Web Developer
[hidden email]
206.286.1235x32

Are you engaging? Find out! Use our free engagement benchmarking tool.

http://groundwire.org/labs/engagement-strategy/diy-benchmarking-survey



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users