work in progress: method/view for replacing path to media asset in filesystem
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3467 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
48701178bd
commit
3d4092fe44
2 changed files with 25 additions and 0 deletions
|
@ -27,6 +27,7 @@ $Id$
|
|||
from logging import getLogger
|
||||
import traceback
|
||||
from zope import component
|
||||
from zope.security.proxy import removeSecurityProxy
|
||||
|
||||
from cybertools.media.interfaces import IMediaAsset
|
||||
|
||||
|
@ -56,3 +57,22 @@ class RegenerationView(object):
|
|||
if errors:
|
||||
return 'Done - there were %i errors.' % errors
|
||||
return 'Done.'
|
||||
|
||||
|
||||
class ChangeSubdirectories(object):
|
||||
|
||||
search = '/home/Zope3/ctt'
|
||||
replace = ''
|
||||
|
||||
def __call__(self):
|
||||
found = changed = 0
|
||||
context = removeSecurityProxy(self.context)
|
||||
ma = context['concepts']['media_asset']
|
||||
for obj in ma.getResources():
|
||||
found += 1
|
||||
subdir = obj._storageParams.get('subdirectory', '')
|
||||
print subdir
|
||||
if self.search in subdir:
|
||||
changed += 1
|
||||
obj._storageParams['subdirectory'] = subdir.replace(search, replace)
|
||||
return 'Done, %i media asset objects found, %i changed' % (found, changed)
|
||||
|
|
|
@ -27,4 +27,9 @@
|
|||
class="loops.media.browser.admin.RegenerationView"
|
||||
permission="zope.View" />
|
||||
|
||||
<page for="loops.interfaces.ILoops"
|
||||
name="media_assets_change_subdirectories.html"
|
||||
class="loops.media.browser.admin.ChangeSubdirectories"
|
||||
permission="zope.View" />
|
||||
|
||||
</configure>
|
||||
|
|
Loading…
Add table
Reference in a new issue