Commit 872a59c9 authored by 's avatar

Restructuring to avoid name-hiding problems

parent 5ca75ac9
"""Help system and documentation support"""
"""Help system implementation"""
__version__='$Revision: 1.2 $'[11:-2]
__version__='$Revision: 1.3 $'[11:-2]
import sys, os, string, ts_regex
import Globals, Acquisition, StructuredText
from HelpUtil import classobject, is_class, is_module
import sys, os, string, Globals, Acquisition
from HelpUtil import HelpBase
from ObjectRef import ObjectRef
from ImageFile import ImageFile
from Globals import HTMLFile
......@@ -13,118 +13,33 @@ from Globals import HTMLFile
class ObjectItem(classobject):
"""Object type wrapper"""
index_html=HTMLFile('objectitem_index', globals())
__roles__=None
def __getattr__(self, name):
if name in ('isDocTemp', '__call__'):
raise AttributeError, name
return getattr(self.__dict__['_obj_'], name)
def get_method_list(self):
rdict=classobject.get_method_dict(self)
perms=self.__ac_permissions__
mdict={}
mlist=[]
for p in self.__ac_permissions__:
pname=p[0]
fnames=p[1]
for fname in fnames:
if rdict.has_key(fname):
fn=rdict[fname]
fn.permission=pname
mdict[fname]=fn
keys=mdict.keys()
keys.sort()
for key in keys:
fn=mdict[key]
if not hasattr(fn._obj_, '__doc__'):
continue
doc=fn._obj_.__doc__
if hasattr(fn._obj_, '__class__') and \
fn._obj_.__class__.__doc__ is doc:
continue
mlist.append(mdict[key])
del rdict
del mdict
return mlist
class ObjectRef(Acquisition.Implicit):
"""Object reference"""
class HelpSys(HelpBase):
""" """
__names__=None
__roles__=None
index_html=HTMLFile('objectref_index', globals())
def deferred__init__(self):
# This is necessary because we want to wait until all
# products have been installed (imported).
dict={}
for k, v in sys.modules.items():
if v is not None and k != '__builtins__':
dict=self.search_mod(v, dict)
keys=dict.keys()
keys.sort()
for key in keys:
setattr(self, key, dict[key])
self.__names__=keys
objectValues__roles__=None
def objectValues(self):
if self.__names__ is None:
self.deferred__init__()
items=[]
for id in self.__names__:
items.append(getattr(self, id))
return items
def search_mod(self, mod, dict):
hidden=('Control Panel', 'Principia Draft', 'simple item')
for k, v in mod.__dict__.items():
if is_class(v) and hasattr(v, 'meta_type') and \
hasattr(v, '__ac_permissions__') and \
(v.meta_type not in hidden):
dict[v.meta_type]=ObjectItem(k, v)
if is_module(v) and hasattr(v, '__path__'):
dict=self.search_mod(v, dict)
return dict
def __getitem__(self, key):
return self.__dict__[key].__of__(self)
def tpId(self):
return 'ObjectRef'
tpURL=tpId
def tpValues(self):
return self.objectValues()
def __len__(self):
return 1
hs_index=HTMLFile('helpsys', globals())
class HelpSys(Acquisition.Implicit):
"""Help system root"""
__roles__=None
hs_cicon='HelpSys/hs_cbook'
hs_eicon='HelpSys/hs_obook'
index_html=HTMLFile('helpsys_index', globals())
u_arrow=ImageFile('u_arrow.gif', globals())
d_arrow=ImageFile('d_arrow.gif', globals())
r_arrow=ImageFile('r_arrow.gif', globals())
l_arrow=ImageFile('l_arrow.gif', globals())
# Images used by the help system
hs_uarrow=ImageFile('images/hs_uarrow.gif', globals())
hs_darrow=ImageFile('images/hs_darrow.gif', globals())
hs_rarrow=ImageFile('images/hs_rarrow.gif', globals())
hs_larrow=ImageFile('images/hs_larrow.gif', globals())
hs_dnode=ImageFile('images/hs_dnode.gif', globals())
hs_obook=ImageFile('images/hs_obook.gif', globals())
hs_cbook=ImageFile('images/hs_cbook.gif', globals())
hs_id='HelpSys'
hs_title='Help System'
ObjectRef=ObjectRef()
hs_objectvalues__roles__=None
def hs_objectvalues(self):
return [self.ObjectRef]
def __len__(self):
return 1
......
"""Help system and documentation support"""
"""Help system support module"""
__version__='$Revision: 1.2 $'[11:-2]
__version__='$Revision: 1.3 $'[11:-2]
import Globals, Acquisition
......@@ -11,6 +11,20 @@ import sys, os, string, ts_regex
stx_class=StructuredText.StructuredText.HTML
class HelpBase(Acquisition.Implicit):
""" """
def __bobo_traverse__(self, REQUEST, name=None):
# A sneaky trick - we cant really _have_ an index_html
# because that would often hide the index_html of a
# wrapped object ;(
if name=='index_html':
return self.hs_index
return getattr(self, name)
def __len__(self):
return 1
class object(Acquisition.Implicit):
def __init__(self, name, ob, op=None):
self._name=name
......
"""Object Reference implementation"""
__version__='$Revision: 1.1 $'[11:-2]
import sys, os, string, Globals, Acquisition
from HelpUtil import HelpBase, classobject
from HelpUtil import is_class, is_module
from Globals import HTMLFile
from urllib import quote
class ObjectItem(HelpBase, classobject):
""" """
__roles__=None
hs_index=HTMLFile('objectitem', globals())
hs_cicon='HelpSys/hs_dnode'
hs_eicon='HelpSys/hs_dnode'
def hs_id(self):
return self._obj_.meta_type
def hs_url(self):
return quote(self._obj_.meta_type)
hs_title=hs_id
def __getattr__(self, name):
if name in ('isDocTemp', '__call__'):
raise AttributeError, name
return getattr(self.__dict__['_obj_'], name)
def get_method_list(self):
rdict=classobject.get_method_dict(self)
perms=self.__ac_permissions__
mdict={}
mlist=[]
for p in self.__ac_permissions__:
pname=p[0]
fnames=p[1]
for fname in fnames:
if rdict.has_key(fname):
fn=rdict[fname]
fn.permission=pname
mdict[fname]=fn
keys=mdict.keys()
keys.sort()
for key in keys:
fn=mdict[key]
if not hasattr(fn._obj_, '__doc__'):
continue
doc=fn._obj_.__doc__
if hasattr(fn._obj_, '__class__') and \
fn._obj_.__class__.__doc__ is doc:
continue
mlist.append(mdict[key])
del rdict
del mdict
return mlist
hs_objectvalues__roles__=None
def hs_objectvalues(self):
return []
class ObjectRef(HelpBase):
""" """
__names__=None
__roles__=None
hs_index=HTMLFile('objectref', globals())
hs_cicon='HelpSys/hs_cbook'
hs_eicon='HelpSys/hs_obook'
hs_id ='ObjectRef'
hs_title='Object Reference'
hs_url =hs_id
def hs_deferred__init__(self):
# This is necessary because we want to wait until all
# products have been installed (imported).
dict={}
for k, v in sys.modules.items():
if v is not None and k != '__builtins__':
dict=self.hs_search_mod(v, dict)
keys=dict.keys()
keys.sort()
for key in keys:
setattr(self, key, dict[key])
self.__names__=keys
def hs_search_mod(self, mod, dict):
# Root through a module for things that look like
# createable object classes.
hidden=('Control Panel', 'Principia Draft', 'simple item')
for k, v in mod.__dict__.items():
if is_class(v) and hasattr(v, 'meta_type') and \
hasattr(v, '__ac_permissions__') and \
(v.meta_type not in hidden):
dict[v.meta_type]=ObjectItem(k, v)
if is_module(v) and hasattr(v, '__path__'):
dict=self.hs_search_mod(v, dict)
return dict
hs_objectvalues__roles__=None
def hs_objectvalues(self):
if self.__names__ is None:
self.hs_deferred__init__()
items=[]
for id in self.__names__:
items.append(getattr(self, id))
return items
def __getitem__(self, key):
return self.__dict__[key].__of__(self)
......@@ -29,7 +29,7 @@ services provided by high-level objects such as Documents
and Folders. Other references will be added soon.
</p>
<ul>
<li> <a href="<!--#var BASE1-->/HelpSys/ObjectRef/index_html">
<li> <a href="<!--#var BASE1-->/HelpSys/ObjectRef/hs_index">
Object Reference
</a>
......
......@@ -8,7 +8,7 @@ Object Reference
<a name="top">
<h2><a href="../index_html">Object Reference</a></h2>
<h2><a href="../hs_index">Object Reference</a></h2>
......@@ -64,15 +64,15 @@ Object Reference
<!--#else-->
<p>No documentation for this method</p>
<!--#endif-->
<a href="#top"><img src="<!--#var SCRIPT_NAME-->/HelpSys/u_arrow" height="9" width="9" border="0" valign="bottom" alt=""> top</a><br><br>
<a href="#top"><img src="<!--#var SCRIPT_NAME-->/HelpSys/hs_uarrow" height="9" width="9" border="0" valign="bottom" alt=""> top</a><br><br>
</code>
</dd>
<!--#endin-->
</dl>
<p>
<a href="../index_html">
<img src="<!--#var SCRIPT_NAME-->/HelpSys/l_arrow" height="9" width="9" border="0" valign="bottom" alt=""> Back to Object Reference</a>
<a href="../hs_index">
<img src="<!--#var SCRIPT_NAME-->/HelpSys/hs_larrow" height="9" width="9" border="0" valign="bottom" alt=""> Back to Object Reference</a>
</p>
</body>
</html>
......@@ -17,18 +17,18 @@ focuses on those object services useful in
<ul>
<!--#in objectValues-->
<!--#in hs_objectvalues-->
<!--#with sequence-item-->
<li> <a href="<!--#var BASE1-->/HelpSys/ObjectRef/<!--#var
meta_type fmt=url-quote-->/index_html"><!--#var meta_type--></a>
meta_type fmt=url-quote-->/hs_index"><!--#var meta_type--></a>
<!--#endwith-->
</li>
<!--#endin-->
</ul>
<p>
<a href="../index_html">
<img src="<!--#var SCRIPT_NAME-->/HelpSys/l_arrow" height="9" width="9" border="0" valign="bottom" alt=""> Back to Help</a>
<a href="../hs_index">
<img src="<!--#var SCRIPT_NAME-->/HelpSys/hs_larrow" height="9" width="9" border="0" valign="bottom" alt=""> Back to Help</a>
</p>
</body>
......
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