Commit 1b34bece authored by Amos Latteier's avatar Amos Latteier

Fixed a problem with old products that didn't have ProductHelp objects and...

Fixed a problem with old products that didn't have ProductHelp objects and improved the HelpSystem API a little to boot.
parent e801bb62
...@@ -335,6 +335,15 @@ class Product(Folder, PermissionManager): ...@@ -335,6 +335,15 @@ class Product(Folder, PermissionManager):
def zclass_product_name(self): def zclass_product_name(self):
return self.id return self.id
def getProductHelp(self):
"""
Returns the ProductHelp object associated
with the Product.
"""
if not hasattr(self, 'Help'):
self._setObject('Help', ProductHelp('Help', '%s Help' % self.id))
return self.Help
class CompressedOutputFile: class CompressedOutputFile:
def __init__(self, rot): def __init__(self, rot):
self._c=zlib.compressobj() self._c=zlib.compressobj()
......
...@@ -266,12 +266,7 @@ class ProductContext: ...@@ -266,12 +266,7 @@ class ProductContext:
""" """
Register a Help Topic for a product. Register a Help Topic for a product.
""" """
# make sure the product has a ProductHelp self.__prod.__of__(self.__app.Control_Panel.Products).getProductHelp()._setObject(id, topic)
if not hasattr(self.__prod, 'Help'):
self.__prod._setObject('Help',
ProductHelp('Help', '%s Help' % self.__prod.id))
self.__prod.__of__(self.__app.Control_Panel.Products).Help._setObject(id, topic)
def registerHelp(self, directory='help', clear=1): def registerHelp(self, directory='help', clear=1):
""" """
...@@ -287,14 +282,11 @@ class ProductContext: ...@@ -287,14 +282,11 @@ class ProductContext:
.stx .txt -- STXHelpTopic .stx .txt -- STXHelpTopic
.jpg .png .gif -- ImageHelpTopic .jpg .png .gif -- ImageHelpTopic
""" """
# make sure the product has a ProductHelp
if not hasattr(self.__prod, 'Help'):
self.__prod._setObject('Help',
ProductHelp('Help', '%s Help' % self.__prod.id))
if clear: if clear:
help=self.__prod.__of__(self.__app.Control_Panel.Products).Help help=self.__prod.__of__(self.__app.Control_Panel.Products).getProductHelp()
for id in help.objectIds('Help Topic'): for id in help.objectIds('Help Topic'):
help._delObject(id) help._delObject(id)
path=os.path.join(Globals.package_home(self.__pack.__dict__), directory) path=os.path.join(Globals.package_home(self.__pack.__dict__), directory)
for file in os.listdir(path): for file in os.listdir(path):
ext=os.path.splitext(file)[1] ext=os.path.splitext(file)[1]
......
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