Commit 309d6f33 authored by Rocky Burt's avatar Rocky Burt

ProductDispatcher's __bobo_traverse__ now checks all products registered in...

ProductDispatcher's __bobo_traverse__ now checks all products registered in Control_Panel.Products rather than simply checking the python Products namespace package.
parent cbc6e198
...@@ -78,6 +78,7 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)): ...@@ -78,6 +78,7 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)):
if d: raise ValueError, ( if d: raise ValueError, (
'The file name, %s, should be a simple file name' % name) 'The file name, %s, should be a simple file name' % name)
result = None
if checkProduct: if checkProduct:
l = name.find('.') l = name.find('.')
if l > 0: if l > 0:
...@@ -85,14 +86,38 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)): ...@@ -85,14 +86,38 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',)):
n = name[l + 1:] n = name[l + 1:]
for product_dir in Products.__path__: for product_dir in Products.__path__:
r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes) r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes)
if r is not None: return r if r is not None: result = r
import App.config if result is None:
cfg = App.config.getConfiguration() import App.config
sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) cfg = App.config.getConfiguration()
for home in (cfg.instancehome, sw): sw=os.path.dirname(os.path.dirname(cfg.softwarehome))
r=_getPath(home, prefix, name, suffixes) for home in (cfg.instancehome, sw):
if r is not None: return r r=_getPath(home, prefix, name, suffixes)
if r is not None: result = r
if result is None:
try:
l = name.find('.')
if l > 0:
realName = name[l + 1:]
toplevel = name[:l]
m = __import__(toplevel)
d = os.path.join(m.__path__[0], prefix, realName)
for s in suffixes:
if s: s="%s.%s" % (d, s)
else: s=d
if os.path.exists(s):
result = s
break
except:
pass
return result
def getObject(module, name, reload=0, def getObject(module, name, reload=0,
# The use of a mutable default is intentional here, # The use of a mutable default is intentional here,
......
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