source: products/quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier/utilities.py @ 1604

Last change on this file since 1604 was 1604, checked in by mylan, 14 years ago

Updated constructor section for possibility to construct not only CMF objects, registered in fti

File size: 1.3 KB
Line 
1from zope.interface import implements
2
3class ImageFTI(object):
4    def _constructInstance(self, container, id, *args, **kw):
5        """Build a bare instance of the appropriate type.
6        Does not do any security checks.
7        Returns the object without calling _finishConstruction().
8        """
9        file, title = None, ''
10        id = container.manage_addProduct['OFSP'].manage_addImage(id, file, title)
11        return container.get(id, None)
12
13    def _finishConstruction(self, obj):
14        """Finish the construction of a content object.
15        Set its portal_type, insert it into the workflows.
16        """
17        return obj
18
19ImageFTIUtility = ImageFTI()
20
21class FileFTI(object):
22    def _constructInstance(self, container, id, *args, **kw):
23        """Build a bare instance of the appropriate type.
24        Does not do any security checks.
25        Returns the object without calling _finishConstruction().
26        """
27        file, title = None, ''
28        id = container.manage_addProduct['OFSP'].manage_addFile(id, file, title)
29        return container.get(id, None)
30
31    def _finishConstruction(self, obj):
32        """Finish the construction of a content object.
33        Set its portal_type, insert it into the workflows.
34        """
35        return obj
36
37FileFTIUtility = FileFTI()
Note: See TracBrowser for help on using the repository browser.