Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 # 
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE
00011 # 
00012 ##############################################################################
00013 
00014 __version__='$Revision: 1.4 $'[11:-2]
00015 
00016 import ZopeRepository, OFS, App, Globals
00017 
00018 
00019 def initialize(context):
00020 
00021     context.registerClass(
00022         instance_class = ZopeRepository.ZopeRepository,
00023         meta_type      = 'Repository',
00024         permission     = 'Add Repositories',
00025         constructors   = ZopeRepository.constructors,
00026         icon           = 'www/Repository.gif'
00027       )
00028 
00029     context.registerHelp()
00030     context.registerHelpTitle('Zope Help')
00031 
00032     registerIcon('VersionHistory.gif')
00033     registerIcon('Version.gif')
00034 
00035 
00036 def install_hack():
00037     # Hackery - don't try this at home, kids. :) This is temporary for
00038     # testing purposes only.
00039     from VersionSupport import VersionSupport
00040     import OFS.SimpleItem, App.Management
00041 
00042     method = App.Management.Tabs.filtered_manage_options
00043     def filtered_manage_options(self, REQUEST=None, method = method,
00044                                 options = VersionSupport.manage_options):
00045         result = method(self, REQUEST)
00046         for item in result:
00047             if item.get('label') == 'Version Control':
00048                 return result
00049         for option in options:
00050             result.append(option)
00051         return result
00052     App.Management.Tabs.filtered_manage_options = filtered_manage_options
00053 
00054     for _class in (OFS.SimpleItem.Item, OFS.SimpleItem.Item_w__name__):
00055         dict = _class.__dict__
00056         if not hasattr(dict, '__setitem__'):
00057             # new-style classes don't need this [>=2.8]
00058             continue
00059 
00060         for name, value in VersionSupport.__dict__.items():
00061             if name != 'manage_options':
00062                 dict[name] = value
00063 
00064         Globals.InitializeClass(_class)
00065 
00066 
00067 def registerIcon(filename):
00068     setattr(OFS.misc_.misc_.ZopeVersionControl, filename, 
00069             App.ImageFile.ImageFile('www/%s' % filename, globals())
00070             )