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

Reply via email to