[1] | 1 | from cStringIO import StringIO |
---|
| 2 | |
---|
| 3 | from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod |
---|
| 4 | |
---|
| 5 | from Products.CMFCore.utils import getToolByName |
---|
| 6 | |
---|
| 7 | from Products.qMemberdataExport.config import * |
---|
| 8 | |
---|
| 9 | def addExternalMethod(self, out): |
---|
| 10 | """ Add external method to portal root directory """ |
---|
| 11 | |
---|
| 12 | if not hasattr(self, EXTERNAL_METHOD): |
---|
| 13 | manage_addExternalMethod(self, |
---|
| 14 | id=EXTERNAL_METHOD, |
---|
| 15 | title=EXTERNAL_METHOD, |
---|
| 16 | module=PROJECTNAME+'.'+'getMemberData', |
---|
| 17 | function='getMemberData') |
---|
| 18 | method = getattr(self, EXTERNAL_METHOD) |
---|
| 19 | if method: |
---|
| 20 | method.manage_permission('View', ['Manager',], acquire=0) |
---|
| 21 | out.write('%s external method added to portal\n' % EXTERNAL_METHOD) |
---|
| 22 | else: out.write('installation procedure could not create external method\n') |
---|
| 23 | else: out.write('%s external method already exists in portal\n' % EXTERNAL_METHOD) |
---|
| 24 | |
---|
| 25 | def addPythonScript(self, out): |
---|
| 26 | """Add a PythonScript to portal root directory """ |
---|
| 27 | |
---|
| 28 | if not hasattr(self, PYTHON_SCRIPT): |
---|
| 29 | factory = self.manage_addProduct['PythonScripts'] |
---|
| 30 | factory.manage_addPythonScript(PYTHON_SCRIPT) |
---|
| 31 | script = getattr(self, PYTHON_SCRIPT) |
---|
| 32 | if script: |
---|
| 33 | script.ZPythonScript_edit('', 'return context.%s(context)' % EXTERNAL_METHOD) |
---|
| 34 | out.write('%s python script added to portal\n' % PYTHON_SCRIPT) |
---|
| 35 | else: out.write('installation procedure could not create python script\n') |
---|
| 36 | else: out.write('%s python script already exists in portal\n' % PYTHON_SCRIPT) |
---|
| 37 | |
---|
| 38 | def install(self): |
---|
| 39 | """ Product installation """ |
---|
| 40 | |
---|
| 41 | out = StringIO() |
---|
| 42 | |
---|
| 43 | # add external method |
---|
| 44 | addExternalMethod(self, out) |
---|
| 45 | |
---|
| 46 | # add python script |
---|
| 47 | addPythonScript(self, out) |
---|
| 48 | |
---|
| 49 | return out.getvalue() |
---|
| 50 | |
---|
| 51 | def uninstall(self): |
---|
| 52 | """ Product uninstallation """ |
---|
| 53 | |
---|
| 54 | out = StringIO() |
---|
| 55 | |
---|
| 56 | return out.getvalue() |
---|