Commit 24865e72 authored by 's avatar

- registerClass now also adds z3 interfaces to 'interfaces' of the meta_type info

- added some comments describing the meta_type info
parent fc78f968
...@@ -15,28 +15,32 @@ ...@@ -15,28 +15,32 @@
$Id$ $Id$
""" """
import os.path, re
import stat
from AccessControl.PermissionRole import PermissionRole from AccessControl.PermissionRole import PermissionRole
import Globals, os, OFS.ObjectManager, OFS.misc_, Products import Globals, os, OFS.ObjectManager, OFS.misc_, Products
import AccessControl.Permission import AccessControl.Permission
from App.Product import doInstall
from HelpSys import HelpTopic, APIHelpTopic from HelpSys import HelpTopic, APIHelpTopic
from HelpSys.HelpSys import ProductHelp from HelpSys.HelpSys import ProductHelp
from FactoryDispatcher import FactoryDispatcher from FactoryDispatcher import FactoryDispatcher
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
import os.path, re
import stat
from DateTime import DateTime from DateTime import DateTime
from Interface.Implements import instancesOfObjectImplements from Interface.Implements import instancesOfObjectImplements
from App.Product import doInstall from zope.interface import implementedBy
import ZClasses # to enable 'PC.registerBaseClass()' import ZClasses # to enable 'PC.registerBaseClass()'
if not hasattr(Products, 'meta_types'): Products.meta_types=() if not hasattr(Products, 'meta_types'):
Products.meta_types=()
if not hasattr(Products, 'meta_classes'): if not hasattr(Products, 'meta_classes'):
Products.meta_classes={} Products.meta_classes={}
Products.meta_class_info={} Products.meta_class_info={}
_marker = [] # Create a new marker object _marker = [] # Create a new marker object
class ProductContext: class ProductContext:
def __init__(self, product, app, package): def __init__(self, product, app, package):
...@@ -100,7 +104,6 @@ class ProductContext: ...@@ -100,7 +104,6 @@ class ProductContext:
before calling an object's constructor. before calling an object's constructor.
""" """
app=self.__app
pack=self.__pack pack=self.__pack
initial=constructors[0] initial=constructors[0]
productObject=self.__prod productObject=self.__prod
...@@ -110,8 +113,6 @@ class ProductContext: ...@@ -110,8 +113,6 @@ class ProductContext:
setattr(instance_class, 'icon', 'misc_/%s/%s' % setattr(instance_class, 'icon', 'misc_/%s/%s' %
(pid, os.path.split(icon)[1])) (pid, os.path.split(icon)[1]))
OM=OFS.ObjectManager.ObjectManager
if permissions: if permissions:
if isinstance(permissions, basestring): # You goofed it! if isinstance(permissions, basestring): # You goofed it!
raise TypeError, ('Product context permissions should be a ' raise TypeError, ('Product context permissions should be a '
...@@ -140,6 +141,8 @@ class ProductContext: ...@@ -140,6 +141,8 @@ class ProductContext:
((permission, (), default),)) ((permission, (), default),))
############################################################ ############################################################
OM=OFS.ObjectManager.ObjectManager
for method in legacy: for method in legacy:
if isinstance(method, tuple): if isinstance(method, tuple):
name, method = method name, method = method
...@@ -178,14 +181,26 @@ class ProductContext: ...@@ -178,14 +181,26 @@ class ProductContext:
if instance_class is None: if instance_class is None:
interfaces = () interfaces = ()
else: else:
interfaces = instancesOfObjectImplements(instance_class) interfaces = tuple(implementedBy(instance_class))
# BBB: Will be removed in Zope 2.11.
interfaces += tuple(instancesOfObjectImplements(instance_class))
Products.meta_types=Products.meta_types+( Products.meta_types=Products.meta_types+(
{ 'name': meta_type or instance_class.meta_type, { 'name': meta_type or instance_class.meta_type,
# 'action': The action in the add drop down in the ZMI. This is
# currently also required by the _verifyObjectPaste
# method of CopyContainers like Folders.
'action': ('manage_addProduct/%s/%s' % (pid, name)), 'action': ('manage_addProduct/%s/%s' % (pid, name)),
# 'product': Used by ProductRegistry for TTW products and by
# OFS.Application for refreshing products.
# This key might not be available.
'product': pid, 'product': pid,
# 'permission': Guards the add action.
'permission': permission, 'permission': permission,
# 'visibility': A silly name. Doesn't have much to do with
# visibility. Allowed values: 'Global', None
'visibility': visibility, 'visibility': visibility,
# 'interfaces': A tuple of oldstyle and/or newstyle interfaces.
'interfaces': interfaces, 'interfaces': interfaces,
'instance': instance_class, 'instance': instance_class,
'container_filter': container_filter 'container_filter': container_filter
...@@ -211,7 +226,6 @@ class ProductContext: ...@@ -211,7 +226,6 @@ class ProductContext:
setattr(OFS.misc_.misc_, pid, OFS.misc_.Misc_(pid, {})) setattr(OFS.misc_.misc_, pid, OFS.misc_.Misc_(pid, {}))
getattr(OFS.misc_.misc_, pid)[name]=icon getattr(OFS.misc_.misc_, pid)[name]=icon
def registerZClass(self, Z, meta_type=None): def registerZClass(self, Z, meta_type=None):
# #
# Convenience method, now deprecated -- clients should # Convenience method, now deprecated -- clients should
...@@ -237,8 +251,6 @@ class ProductContext: ...@@ -237,8 +251,6 @@ class ProductContext:
Products.meta_class_info[key]=info # meta_type Products.meta_class_info[key]=info # meta_type
Products.meta_classes[key]=Z Products.meta_classes[key]=Z
def registerBaseClass(self, base_class, meta_type=None): def registerBaseClass(self, base_class, meta_type=None):
# #
# Convenience method, now deprecated -- clients should # Convenience method, now deprecated -- clients should
...@@ -249,7 +261,6 @@ class ProductContext: ...@@ -249,7 +261,6 @@ class ProductContext:
Z = ZClasses.createZClassForBase( base_class, self.__pack ) Z = ZClasses.createZClassForBase( base_class, self.__pack )
return Z return Z
def getProductHelp(self): def getProductHelp(self):
""" """
Returns the ProductHelp associated with the current Product. Returns the ProductHelp associated with the current Product.
...@@ -348,6 +359,7 @@ class ProductContext: ...@@ -348,6 +359,7 @@ class ProductContext:
ht=APIHelpTopic.APIHelpTopic(file, '', os.path.join(path, file)) ht=APIHelpTopic.APIHelpTopic(file, '', os.path.join(path, file))
self.registerHelpTopic(file, ht) self.registerHelpTopic(file, ht)
class AttrDict: class AttrDict:
def __init__(self, ob): def __init__(self, ob):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment