source: products/qPloneResolveUID/trunk/Extensions/Install.py @ 1

Last change on this file since 1 was 1, checked in by myroslav, 14 years ago

Building directory structure

File size: 2.0 KB
Line 
1# Author: Melnychuk Taras
2# Contact: fenix@quintagroup.com
3# Date: $Date: 2006-08-11
4# Copyright: quintagroup.com
5
6from Products.CMFCore.utils import getToolByName
7from StringIO import StringIO
8from types import InstanceType
9
10from Products.qPloneResolveUID.config import *
11
12def registerTransform(self, out, name, module):
13    transforms = getToolByName(self, 'portal_transforms')
14    transforms.manage_addTransform(name, module)
15    print >> out, "Registered transform", name
16
17def registerTransformPolicy(self, out, output_mimetype, required_transforms):
18    transforms = getToolByName(self, 'portal_transforms')
19    transforms.manage_addPolicy(output_mimetype, required_transforms)
20    print >> out, "Registered policy for %s mimetype" %output_mimetype
21   
22def unregisterTransform(self, out, name):
23    transforms = getToolByName(self, 'portal_transforms')
24    try:
25        transforms.unregisterTransform(name)
26        print >> out, "Removed transform", name
27    except AttributeError:
28        print >> out, "Could not remove transform", name, "(not found)"
29
30def unregisterTransformPolicy(self, out, output_mimetypes):
31    transforms = getToolByName(self, 'portal_transforms')
32    transforms.manage_delPolicies(output_mimetypes)
33    print >> out, "Removed transform policy for %s mimetype" %output_mimetypes
34   
35def install(self):
36
37    out = StringIO()
38
39    print >> out, "Installing ruid_to_url transform"
40    registerTransform(self, out, 'ruid_to_url', 'Products.qPloneResolveUID.transforms.ruid_to_url')
41   
42    print >> out, "Installing transform policy for %s mimetype" %DOCUMENT_DEFAULT_OUTPUT_TYPE
43    registerTransformPolicy(self, out, DOCUMENT_DEFAULT_OUTPUT_TYPE, REQUIRED_TRANSFORM)
44   
45    return out.getvalue()
46
47def uninstall(self):
48
49    out = StringIO()
50   
51    unregisterTransform(self, out, 'ruid_to_url')
52   
53    print >> out, "Removing transform policy for %s mimetype" %DOCUMENT_DEFAULT_OUTPUT_TYPE
54    unregisterTransformPolicy(self, out, [DOCUMENT_DEFAULT_OUTPUT_TYPE,])
55   
56    return out.getvalue()
Note: See TracBrowser for help on using the repository browser.