[Zope-Checkins] CVS: Zope2 - Application.py:1.143.26.1

Michel Pelletier michel@digicool.com
Thu, 17 May 2001 12:09:52 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/OFS
In directory korak.digicool.com:/tmp/cvs-serv10590

Modified Files:
      Tag: APIDocs-branch
	Application.py 
Log Message:
post-import framework doc hooks


--- Updated File Application.py in package Zope2 --
--- Application.py	2001/04/07 16:37:07	1.143
+++ Application.py	2001/05/17 16:09:50	1.143.26.1
@@ -437,6 +437,7 @@
             get_transaction().commit()
 
     install_products(app)
+    install_core_help(app)
 
     # Note that the code from here on only runs if we are not a ZEO
     # client, or if we are a ZEO client and we've specified by way
@@ -681,6 +682,62 @@
     Products.meta_types=Products.meta_types+tuple(meta_types)
 
     Globals.default__class_init__(Folder)
+
+def install_core_help(app):
+    # Install a list of products into the basic folder class, so
+    # that all folders know about top-level objects, aka products
+
+    path_join=os.path.join
+    isdir=os.path.isdir
+    exists=os.path.exists
+    DictType=type({})
+
+    global_dict=globals()
+    silly=('__doc__',)
+
+    done={}
+
+    get_transaction().note('Prior to core help installs')
+    get_transaction().commit()
+
+    from HelpSys import HelpContext
+
+#    import pdb
+#    pdb.set_trace()
+    for help_dir in HelpContext._registry:
+        help_dir = os.path.join('lib/python', help_dir)
+        # For each help dir, we will import it and try to call the
+        # intialize() method in the product __init__ module. If
+        # the method doesnt exist, we put the old-style information
+        # together and do a default initialization.
+        if done.has_key(help_dir):
+            continue
+        done[help_dir]=1
+
+        __traceback_info__=help_dir
+        if not isdir(help_dir): continue
+        if not exists(path_join(help_dir, '__init__.py')):
+            if not exists(path_join(help_dir, '__init__.pyc')):
+                continue
+        try:
+            help=__import__(help_dir, global_dict, global_dict, silly)
+            initmethod=getattr(help, 'initialize')
+            if initmethod is not None:
+                initmethod(app.HelpSys)                    
+
+            if (os.environ.get('ZEO_CLIENT') and
+                not os.environ.get('FORCE_HELP_LOAD')):
+                # we don't want to install helps from clients
+                # (unless FORCE_HELP_LOAD is defined).
+                get_transaction().abort()
+            else:
+                get_transaction().note('Installed help '+help_dir)
+                get_transaction().commit()
+
+        except:
+            LOG('Zope',ERROR,'Couldn\'t install %s' % help_dir,
+                error=sys.exc_info())
+            get_transaction().abort()
 
 
 def pgetattr(product, name, default=install_products, __init__=0):