source: main/waeup.ikoba/trunk/src/waeup/ikoba/documents/container.py @ 12207

Last change on this file since 12207 was 12207, checked in by Henrik Bettermann, 10 years ago

Make necessary changes in root and in customer browser test.

Add plugin to create documents folder.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1## $Id: container.py 12207 2014-12-13 07:30:38Z henrik $
2##
3## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""
19Containers which contain document objects.
20"""
21import grok
22from grok import index
23from waeup.ikoba.interfaces import IIkobaPluggable
24from waeup.ikoba.documents.interfaces import IDocumentsContainer, IDocument
25from waeup.ikoba.utils.helpers import attrs_to_fields
26
27class DocumentsContainer(grok.Container):
28    """This is a container for all kind of documents.
29    """
30    grok.implements(IDocumentsContainer)
31    grok.provides(IDocumentsContainer)
32
33
34    def addDocument(self, document):
35        if not IDocument.providedBy(document):
36            raise TypeError(
37                'DocumentsContainers contain only IDocument instances')
38        self[document.document_id] = document
39        return
40
41DocumentsContainer = attrs_to_fields(DocumentsContainer)
42
43class DocumentsPlugin(grok.GlobalUtility):
44    """A plugin that creates container for documents inside a company.
45    """
46    grok.implements(IIkobaPluggable)
47    grok.name('documents')
48
49    def setup(self, site, name, logger):
50        if 'documents' in site.keys():
51            logger.warn('Could not create container for documents.')
52            return
53        site['documents'] = DocumentsContainer()
54        logger.info('Container for documents created')
55        return
56
57    def update(self, site, name, logger):
58        if not 'documents' in site.keys():
59            self.setup(site, name, logger)
Note: See TracBrowser for help on using the repository browser.