Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
You can subscribe to this list here.
Showing
3
results of 3
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@...]
Sent: Saturday, November 09, 2002 1:52 PM
To: jose@...
Cc: jason@...; 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, jose@... 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 <jason@...>
Date: Fri, November 8, 2002 1:15 pm
To: jose@...
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
Hope this helps.
On Fri, 2002-11-08 at 11:56, jose@... wrote:Still not
working, here is the testcode that currently will not run and the error
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 <aaron@...>
Date: Fri, November 8, 2002 7:38 am
To: jose <jose@...>
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
>
> J@...
--
Jason D. Hildebrand
jason@...
------------------------------------------------------- This sf.net
email is sponsored by: See the NEW Palm Tungsten T handheld. Power &
Color in a compact size!
_______________________________________________ Webware-discuss mailing
list Webware-discuss@...
MiscUtils and everywhere:
* Rename SubclassResponsibilityError to the more reasonable
AbstractError. The former is still available as a deprecated name for
projects that might use it. Also, pass self.__class__ as in:
raise AbstractError, self.__class__
which makes the resulting exception much more informative. See
MiscUtils.__init__.py for the full doc string if you like.
WebKit:
* Profiling the entire app server is now fairly easy to do. Read the
doc string of the new Profiler.py for more details.
* Added Page.py util method:
def sendRedirectAndEnd(self, url):
"""
Sends a redirect back to the client and ends the response. This
is a very popular pattern.
"""
self.response().sendRedirect(self)
self.endResponse()
* The singleton <span class=name>Tombstone</span> has been deprecated
in favor of <span class=name>MiscUtils.NoDefault</span>.
MiddleKit:
* The Classes.csv text file is now cached as a binary pickle file named
Classes.csv.pickle.cache. This reduces subsequent load times by about
40%. The cache will be ignored if it can't be read, is older than the
CSV file, has a different Python version, etc. You don't normally even
need to think about this, but if for some reason you would like to turn
off the use of the cache, you can do so via the new
UsePickledClassesCache setting.
Hi,
Michael Montagne hat gesagt: // Michael Montagne wrote:
> The application is an office manual. About half the pages are free form
> text I'd like to be served by moinmoin to be easily updateable and
> easy to add more pages. But the other half will be served from a
> database using MiddleKit(things like checklists and layer lists).
> The whole thing needs to be able to be printed or selected chapters
> printed. And searched.
Did you consider developing all your needs inside Webware? There
already are two Wikis for WW available, Ian's Wiki and my PyDiddy.
Ian's code is much more modular than mine, which could be a blessing
or a curse, depending on what you want to do. I think, mine is easier
to grok, but, well, I'm biased... PyDiddy is easier to set up though...
> I'm really not sure if this is the right approach cause it's not clear to
> me that the db served pages will be searched by moinmoin like I need
> (full text search).
I think, moinmoin just 'greps' through the Page files, so you'd need
to add SQL/MiddleKit-code to your search function anyways. This also
might be easier, if the search function would be inside one of your
servlets.
ciao
--
Frank Barknecht _ ______footils.org__