[Zope-Checkins] CVS: Zope2 - TutorialTopic.py:1.9 tutorial.stx:1.5
Amos Latteier
amos@digicool.com
Tue, 3 Jul 2001 18:20:46 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/Products/ZopeTutorial
In directory korak.digicool.com:/tmp/cvs-serv10439
Modified Files:
TutorialTopic.py tutorial.stx
Log Message:
Made tutorial more robust in terms of checking to see if the examples are installed. Also fixed a bug that appeared due to recent changes in structured text.
--- Updated File TutorialTopic.py in package Zope2 --
--- TutorialTopic.py 2001/06/21 23:14:54 1.8
+++ TutorialTopic.py 2001/07/03 22:20:46 1.9
@@ -106,6 +106,28 @@
self.obj=HTML(pre_pat.sub(clean_pre, text))
index_html=DTMLFile('dtml/lessonView', globals())
+
+ def checkInstallation(self, REQUEST):
+ """
+ Returns false if the tutorial examples are not correctly
+ installed. Also sets the 'hide_next' variable in the request
+ if the examples are not installed.
+ """
+ ok=0
+ if REQUEST.has_key('tutorialExamplesURL'):
+ url=REQUEST['tutorialExamplesURL']
+ base=REQUEST['BASE1']
+ if string.index(url, base) == 0:
+ url=url[len(base):]
+ try:
+ self.getPhysicalRoot().unrestrictedTraverse(url)
+ ok=1
+ except:
+ pass
+
+ if not ok:
+ REQUEST.set('hide_next', 1)
+ return ok
def lessonURL(self, id, REQUEST):
"""
@@ -121,7 +143,8 @@
Navigate management frame to a given lesson's screen.
"""
url=self.lessonURL(id, REQUEST)
- if not url:
+ if not url or not self.checkInstallation(REQUEST):
+ REQUEST.set('hide_next', 0)
return """\
<p class="warning">
Zope cannot find the tutorial examples.
--- Updated File tutorial.stx in package Zope2 --
--- tutorial.stx 2001/06/21 23:14:54 1.4
+++ tutorial.stx 2001/07/03 22:20:46 1.5
@@ -22,8 +22,7 @@
object you created in the Zope management screen, and viewing
its "README" document.
- <dtml-unless tutorialExamplesURL>
- <dtml-call "REQUEST.set('hide_'+'next', 1)">
+ <dtml-unless expr="checkInstallation(REQUEST)">
Install Tutorial Examples