Thanks Ian for the advice but I still can't seem to get the code right. This time I get an "AttributeError: testpage instance has no attribute '_contextPath'" error.
Any other suggestions? In case what I am doing has gotten lost in this entire thread, what I wanted to do was create a sevlet which would read in a conf file. The conf file would have such things in it as what the users wanted to use for page titles and other page specific variables. To do this I was thinking of using configParser to load in a conf file. But I needed the full path to that file prior to loading the rest of my servlet. The goal to make a set of files that users can drop in a folder, edit the conf file and the page would run itself. At the moment I am doing the conf stuff by importing a file called config.py, but as you know once it is read in, if changes are made in it, they really don't show up in the new webpage unless webkit is restarted (also I really don't want users editing the python code directly). I am using the Server version (not the standalone version) on an XP box, and I am using wkcgi with apache 2.0.43. I have tied several of the other Mod files including mod_webkit, but I can't seem to get them to load on my XP box and at least for me wkcgi seems the most stable. Any other thoughts as to what I might be doing wrong, is my approach wrong? or is what I want to do something that just can't be done in webware? -----Original Message----- From: Ian Bicking [mailto:ianb@;colorstudy.com] Sent: Saturday, November 09, 2002 1:52 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Webware discuss Subject: Re: [Webware-discuss] ConfigParser Question I think it would go like (untested): # __init__.py in your context dir... def contextInitialize(appServer, path): from lib import SitePage SitePage.SitePage._contextPath = path # in SitePage.py # [...] class SitePage(Page): # [...] def configPath(self, configName): return os.path.join(self._contextPath, configName) On Fri, 2002-11-08 at 17:54, [EMAIL PROTECTED] wrote:I'm sorry I am really feeling dense, I've looked at the Python 10 paper, and it does mention contextInitialize, I just can't see how to use it, Do you think you could post a short example. thanks Jose -------- Original Message -------- Subject: Re: [Webware-discuss] ConfigParser Question From: Jason Hildebrand <[EMAIL PROTECTED]> Date: Fri, November 8, 2002 1:15 pm To: [EMAIL PROTECTED] Hi Jose, I think Aaron got __init__() and awake() mixed up. self.request() is available once Page.awake() has been called. This means that this doesn't really help you for doing one-time initialization. What you can do is create an __init__.py file in your context directory, and place a contextInitialize() function in it. This function will be called by the application object to initialize your context when the app server is started. A reference to the application object and the path of the context are passed as parameters, so you should have all the info you need. This may not be in the Webware docs (yet), but it's described in Geoff's slides from the Python 10 presentation, available at http://webware.sourceforge.net/Papers/ Hope this helps. On Fri, 2002-11-08 at 11:56, [EMAIL PROTECTED] wrote:Still not working, here is the testcode that currently will not run and the error message. Code: ----------------------------------------------------------------- from WebKit.Page import Page class pathtest(Page): def __init__(self): Page.__init__(self) self.testvar = self.request().serverSidePath() def writeContent(self): #self.write(self.testvar) pass --------------------------------------------------------------------- error: ------------------------------------------------------------------- C:\Program Files\Apache Group\Apache2\htdocs\py\jose\pathtest.py Traceback (most recent call last): File "WebKit\Application.py", line 388, in dispatchRequest self.handleGoodURL(transaction) File "WebKit\Application.py", line 534, in handleGoodURL self.createServletInTransaction(transaction) File "WebKit\Application.py", line 989, in createServletInTransaction inst = self.getServlet(transaction,path,cache) File "WebKit\Application.py", line 916, in getServlet inst = factory.servletForTransaction(transaction) File "WebKit\ServletFactory.py", line 190, in servletForTransaction return theClass() File "C:\Program Files\Apache Group\Apache2\htdocs\py\jose\pathtest.py", line 7, in __init__ File "WebKit\Page.py", line 86, in request return self._request AttributeError: pathtest instance has no attribute '_request' ------------------------------------------------------------------- Again Thanks for any and all help Jose -------- Original Message -------- Subject: Re: [Webware-discuss] ConfigParser Question From: Aaron Held <[EMAIL PROTECTED]> Date: Fri, November 8, 2002 7:38 am To: jose <[EMAIL PROTECTED]> Sorry about the last - I did not read your message completely. In INIT you cannot use self.request() untill the __init__ for the base class has been called. Are you calling self.request() BEFORE you call SitePage.__init__ ?? -Aaron jose wrote: > Hi > > Is there any was to use ConfigParser with Webkit? What I want to do is > load a config file, but I was thinking of doing it in an __init__ > statement so I could set some global variables. The only problem is > that I can't seem to find a way to get the real path of my config file > in the __init__ method, > self.request().serverSidePath('config.ini') does not work. I get an > error saying that _request is not available. Any thoughts how I could > do this. I am currenlty importing a pythong file and using a class for > the config file, but I wanted something a little more easy for other > people to edit without having to know Python. > > Thanks in advance for any help > > Jose > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: See the NEW Palm > Tungsten T handheld. Power & Color in a compact size! > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en > _______________________________________________ > Webware-discuss mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/webware-discuss ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss -- Jason D. Hildebrand [EMAIL PROTECTED] ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
