Modify

Ticket #214 (closed task: fixed)

Opened 5 years ago

Last modified 5 years ago

Migration script for Plone 2.5/Plumi 0.2.x sites to Plone 3.x/Plumi 0.3.x sites

Reported by: anna Owned by: andycat
Priority: major Milestone: 3.0-beta
Component: PlumiVideoProduct Severity:
Keywords: Cc:
Who will test this:

Description


Attachments

Change History

comment:1 Changed 5 years ago by andycat

  • Component changed from ATEngageVideo to PlumiVideoProduct

comment:2 Changed 5 years ago by vik

Here is a sample script to send a file from the filesystem in blob storage - can use any other reader for the file data (e.g. URL or pipe)

import os import transaction

username = 'foo' file = 'file/to/upload.mp4' memtool = getToolByName(portal, 'portal_membership')

memfolder = getattr(memtool.getMembersFolder(), username) ext = os.path.splitext(file)[1][1:] title = os.path.basename(file) memfolder.videos.invokeFactory('PlumiVideo?',title) vid = getattr(memfolder.videos, title) vid.video_file.setContentType('video/%s' % (ext)) vid.video_file.setFilename(title)

#copy the file blobfile = vid.video_file.blob.open('w') vidfile = open(file, 'rb') buffer_size = 1024*1024*16 # 16M buffer - adjust to your system while 1:

copy_buffer = vidfile.read(buffer_size) if copy_buffer:

blobfile.write(copy_buffer)

else:

break

blobfile.close() vidfile.close() transaction.commit()

comment:3 Changed 5 years ago by vik

D'arghhh..

import os 
import transaction 

username = 'foo'
file = 'file/to/upload.mp4' 
memtool = getToolByName(portal, 'portal_membership')

memfolder = getattr(memtool.getMembersFolder(), username) 
ext = os.path.splitext(file)[1][1:] 
title = os.path.basename(file) 
memfolder.videos.invokeFactory('PlumiVideo',title) 
vid = getattr(memfolder.videos, title) 
vid.video_file.setContentType('video/%s' % (ext)) 
vid.video_file.setFilename(title)

#copy the file
blobfile = vid.video_file.blob.open('w')
vidfile = open(file, 'rb')
buffer_size = 1024*1024*16 # 16M buffer - adjust to your system
while 1:
    copy_buffer = vidfile.read(buffer_size)
    if copy_buffer:
        blobfile.write(copy_buffer)
    else:
        break
blobfile.close()
vidfile.close()
transaction.commit() 

comment:4 Changed 5 years ago by andycat

The future is outlined here :  https://dev.plone.org/old/plone/ticket/9328

and here :  https://dev.plone.org/old/plone/wiki/PlipContentImExport

We are using a basic approach however.

a Members script which exports a 16 field CSV file, one line per member.

And json_migrator, which writes out content objects to disk as JSON formatted objects.

see  http://dev.plone.org/old/collective/browser/Plumi/branches/plumi-0.2.x/IMPORT-EXPORT.txt

and  http://dev.plone.org/old/collective/log/json_migrator/branches/plumi-0.2.2 [ log view of the branch of the product 'json_migrator' adapted for plumi 0.2.x usage ]

The branch name is annoying , I think i will copy over to a new one 'plumi-0.2.x'

comment:5 Changed 5 years ago by andycat

  • Status changed from new to closed
  • Resolution set to fixed

this general task is done. there are more specific tickets lodged about the migration process opened now.

The above branch renaming has been done. The plumi 3.0 / plumi 0.2.x migration scripts are now here:  http://dev.plone.org/old/collective/browser/json_migrator/branches/plumi-0.2.x

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.