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 @@
$Id$
"""
import os.path, re
import stat
from AccessControl.PermissionRole import PermissionRole
import Globals, os, OFS.ObjectManager, OFS.misc_, Products
import AccessControl.Permission
from App.Product import doInstall
from HelpSys import HelpTopic, APIHelpTopic
from HelpSys.HelpSys import ProductHelp
from FactoryDispatcher import FactoryDispatcher
from zLOG import LOG, WARNING
import os.path, re
import stat
from DateTime import DateTime
from Interface.Implements import instancesOfObjectImplements
from App.Product import doInstall
from zope.interface import implementedBy
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'):
Products.meta_classes={}
Products.meta_class_info={}
_marker = [] # Create a new marker object
class ProductContext:
def __init__(self, product, app, package):
......@@ -100,7 +104,6 @@ class ProductContext:
before calling an object's constructor.
"""
app=self.__app
pack=self.__pack
initial=constructors[0]
productObject=self.__prod
......@@ -110,8 +113,6 @@ class ProductContext:
setattr(instance_class, 'icon', 'misc_/%s/%s' %
(pid, os.path.split(icon)[1]))
OM=OFS.ObjectManager.ObjectManager
if permissions:
if isinstance(permissions, basestring): # You goofed it!
raise TypeError, ('Product context permissions should be a '
......@@ -140,6 +141,8 @@ class ProductContext:
((permission, (), default),))
############################################################
OM=OFS.ObjectManager.ObjectManager
for method in legacy:
if isinstance(method, tuple):
name, method = method
......@@ -178,14 +181,26 @@ class ProductContext:
if instance_class is None:
interfaces = ()
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+(
{ '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)),
# 'product': Used by ProductRegistry for TTW products and by
# OFS.Application for refreshing products.
# This key might not be available.
'product': pid,
# 'permission': Guards the add action.
'permission': permission,
# 'visibility': A silly name. Doesn't have much to do with
# visibility. Allowed values: 'Global', None
'visibility': visibility,
# 'interfaces': A tuple of oldstyle and/or newstyle interfaces.
'interfaces': interfaces,
'instance': instance_class,
'container_filter': container_filter
......@@ -211,7 +226,6 @@ class ProductContext:
setattr(OFS.misc_.misc_, pid, OFS.misc_.Misc_(pid, {}))
getattr(OFS.misc_.misc_, pid)[name]=icon
def registerZClass(self, Z, meta_type=None):
#
# Convenience method, now deprecated -- clients should
......@@ -237,8 +251,6 @@ class ProductContext:
Products.meta_class_info[key]=info # meta_type
Products.meta_classes[key]=Z
def registerBaseClass(self, base_class, meta_type=None):
#
# Convenience method, now deprecated -- clients should
......@@ -249,7 +261,6 @@ class ProductContext:
Z = ZClasses.createZClassForBase( base_class, self.__pack )
return Z
def getProductHelp(self):
"""
Returns the ProductHelp associated with the current Product.
......@@ -348,6 +359,7 @@ class ProductContext:
ht=APIHelpTopic.APIHelpTopic(file, '', os.path.join(path, file))
self.registerHelpTopic(file, ht)
class AttrDict:
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