On Fri, Nov 30, 2001 at 05:21:13PM -0600, Ian Bicking wrote:
> On Fri, 2001-11-30 at 17:19, Mike Orr wrote:
> > The problem is in Python's cgi module that Webware uses. It returns a
> > string if there's one value, or a list if there's more than one.
>
> Well, it's not really the cgi modules *fault*. It's just the way things
> work. One value looks like ?f=a, two look like ?f=a&f=b ... you just
> can't tell the difference. Unless, I suppose, you did the PHP thing
> with []... but that's outside the scope of the cgi module.
It's the module's fault for providing one method rather than two, and
for returning an inconsistent type. Causing thousands of Python
progammers to:
A) have to check the type of every single field returned, even those
which should always be single.
B) not check, resulting in scripts that crash if a value unexpectedly
becomes multiple.
C) constantly reinvent the wheel, writing a function that always returns
a list. This causes bloat in the CGI scripts, or if it's put in a
library, makes the script non-portable unless the library is distributed
with it.
--
-Mike (Iron) Orr, iron@... (if mail problems: mso@...)
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol

On Thursday 29 November 2001 02:09 pm, Ian Bicking wrote:
> There's still something about Netscape 4.x, despite all it's lameness,
> that keeps me coming back from time to time. It's just so much more
> responsive than all the modern browsers, even IE (though Opera could
> probably win me over if I gave it a chance).
I haven't tried their last major release, since it's still alpha. I tried
their previous stable release on Linux and it does a very poor job at
rendering.
On Thursday 29 November 2001 05:03 pm, Ian Bicking wrote:
> No, but this was just when I hit the reload button (on a page from
> POST), so the cache shouldn't be involved... but then, maybe it is even
> though it shouldn't be.
I agree. Reload should mean reload. And with all those no-cache headers I
put in, it should _really_ mean reload. But read on...
On Thursday 29 November 2001 06:25 pm, Tavis Rudd wrote:
> Netscape on Windows used to have an option to explicitly ignore
> cached versions of a page when reloading. You had to hold the shift
> key down while clicking the reload button. That probably went away a
> long time ago ... worth a shot.
Tavis, you are the man! This works in Mozilla 0.9.x.
It's not a perfect world, but if I can hit Shift+click to really reload a
page (instead of just pretending to!), then I can carry on with Linux. I
almost contemplated a return to Windows. I reload all the time as I refine
my web apps. I never realized how much until now.
-Chuck

On Fri, 2001-11-30 at 17:19, Mike Orr wrote:
> The problem is in Python's cgi module that Webware uses. It returns a
> string if there's one value, or a list if there's more than one.
Well, it's not really the cgi modules *fault*. It's just the way things
work. One value looks like ?f=a, two look like ?f=a&f=b ... you just
can't tell the difference. Unless, I suppose, you did the PHP thing
with []... but that's outside the scope of the cgi module.
Ian

On Fri, Nov 30, 2001 at 05:17:20PM -0500, Geoffrey Talvola wrote:
> At 12:22 PM 11/30/01 -0500, Hsueh-ching Yen wrote:
> >Hi, all
> >
> >I just started using webware, and have a question on HTML form submission.
> >I have a
> ><SELECT MULTIPLE name= myselect >
> ><option>AAA</option>
> ><option>BBB</option>
> ><option>CCC</option>
> ><option>DDD</option>
> ></SELECT>
> >If user selects one item, AAA, then submit, in HTTPRequest object
> >req.fields()["myselect"] is AAA (a string).
> >If user selects two item, AAA and BBB, then submit, in HTTPRequest object
> >req.fields()["myselect"] is ['AAA', 'BBB'] (a list).
> >
> >Isn t easier if it is always in a list? Then we don t need to test the
> >type of the objects?
>
> I think it's impossible to tell the difference. The way form fields are
> encoded, a single item selected in a multiple select list is the same as an
> item selected in a single select list.
>
> What I did is to write a method in my SitePage.py:
>
> def listField(self, name):
> values = self.request().field(name, [])
> if not isinstance(values, types.ListType):
> values = [values]
> return values
>
> Then instead of using reg.fields()["myselect"], I use
> self.listField("myselect"). It'll always come back as a list.
The problem is in Python's cgi module that Webware uses. It returns a
string if there's one value, or a list if there's more than one. In my
applications I use a .fieldMulti method like Geoff's, and a
.fieldSingle method that arbitrarily picks the first value if there are
more than one. That way, the application doesn't have to do an if-test
for every single variable, nor run the risk of crashing if the user
submits multiple values to a single-value-only field.
--
-Mike (Iron) Orr, iron@... (if mail problems: mso@...)
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol

At 12:22 PM 11/30/01 -0500, Hsueh-ching Yen wrote:
>Hi, all
>
>I just started using webware, and have a question on HTML form submission.
>I have a
><SELECT MULTIPLE name= myselect >
><option>AAA</option>
><option>BBB</option>
><option>CCC</option>
><option>DDD</option>
></SELECT>
>If user selects one item, AAA, then submit, in HTTPRequest object
>req.fields()["myselect"] is AAA (a string).
>If user selects two item, AAA and BBB, then submit, in HTTPRequest object
>req.fields()["myselect"] is ['AAA', 'BBB'] (a list).
>
>Isn t easier if it is always in a list? Then we don t need to test the
>type of the objects?
I think it's impossible to tell the difference. The way form fields are
encoded, a single item selected in a multiple select list is the same as an
item selected in a single select list.
What I did is to write a method in my SitePage.py:
def listField(self, name):
values = self.request().field(name, [])
if not isinstance(values, types.ListType):
values = [values]
return values
Then instead of using reg.fields()["myselect"], I use
self.listField("myselect"). It'll always come back as a list.
--
- Geoff Talvola
gtalvola@...

You do need to still hold down the shift key to force it not to check the
cache. The Web browsers claim they don't cache dynamic pages, but I haven't
found this to be the case. Additionally, telling your browser to always
fetch a fresh copy doesn't seem to work in all cases either, shift + refresh
seems the only reliable method. BTW, there's a page
http://www.bookmarklets.com <http://www.bookmarklets.com&gt; that has a
JavaScript that you can bookmark, select it on any page that you go to and
it will auto fill all of the fields with anonymous (or
anonymous@... <mailto:annonymous@...> for and email
field), pretty handy if you're losing your post vars. Hope that helps.

Hi, all
I just started using webware, and have a question on HTML form
submission.
I have a
<SELECT MULTIPLE name="myselect">
<option>AAA</option>
<option>BBB</option>
<option>CCC</option>
<option>DDD</option>
</SELECT>
If user selects one item, AAA, then submit, in HTTPRequest object
req.fields()["myselect"] is 'AAA' (a string).
If user selects two item, AAA and BBB, then submit, in HTTPRequest
object req.fields()["myselect"] is ['AAA', 'BBB'] (a list).
Isn't easier if it is always in a list? Then we don't need to test the
type of the objects?

The two scripts mentioned in the subject line are identical, except
that the former invokes 'CGIAdapter' and the latter
'OneShotAdapter'. So I would expect them to behave in parallel
ways.
However, the result of the following script (which, I claim, is really
just a pared down version of the other two):
import sys
sys . path . insert ( 1, r'H:\Webware' )
import WebKit.CGIAdapter
print '... CGIAdapter imported'
import WebKit.OneShotAdapter
print '... OneShotAdapter imported'
consists of only
... CGIAdapter imported
which is to say that the second 'import', the one for the
OneShotAdapter, does not return to this script.
Does this seem peculiar to someone who knows this software
system?
Stripped of exception handling logic 'OneShot.cgi' consists of the
following lines:
import os, sys
if WebwareDir:
sys.path.insert(1, WebwareDir)
else:
WebwareDir = os.path.dirname(os.getcwd())
webKitDir = os.path.join(WebwareDir, 'WebKit')
import WebKit.OneShotAdapter
WebKit.OneShotAdapter.main(webKitDir)
Since, in my setup, the 'import' fails the function in the module is
not called.
Incidentally, I'm not trying to dump work onto anybody's plate. I'd
try to suggest a fix for this, if that would be appropriate--but I'm still
a Webware newbie.
Thanks for any comments!
Bill
"It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery

On Thursday 29 November 2001 17:03, Ian Bicking wrote:
> On Thu, 2001-11-29 at 16:08, Jack Moffitt wrote:
> > > However, on Linux, both Mozilla and Galeon always give back the
> > > same page when I reload even though they seem to churn through
> > > the CGI script.
> >
> > I suppose you already tried forcing mozilla to not look at it's
> > page cache? You can tell it to always fetch a fresh copy
> > everytime.
>
> No, but this was just when I hit the reload button (on a page from
> POST), so the cache shouldn't be involved... but then, maybe it is
> even though it shouldn't be.
Netscape on Windows used to have an option to explicitly ignore
cached versions of a page when reloading. You had to hold the shift
key down while clicking the reload button. That probably went away a
long time ago ... worth a shot.

On Thu, 2001-11-29 at 16:08, Jack Moffitt wrote:
> > However, on Linux, both Mozilla and Galeon always give back the same page
> > when I reload even though they seem to churn through the CGI script.
>
> I suppose you already tried forcing mozilla to not look at it's page
> cache? You can tell it to always fetch a fresh copy everytime.
No, but this was just when I hit the reload button (on a page from
POST), so the cache shouldn't be involved... but then, maybe it is even
though it shouldn't be.
Though, now that I think about it, I'm not sure I'm having the problems
I was as of a couple of the latest versions of Galeon (and hence the
latest versions of Mozilla). But the memory is vague.
Ian

I've seen that reload problem in other environments, ASP and Cold Fusion for
example. I don't understand it; I've cleaned out caches, adjusted settings -
it's a real pain for developing apps. Being a Linux zealot I'm not happy
when IE is better at something but it is in this case.
I do use OneShot in my experimenting with Webware.
John Holland

At 04:30 PM 11/29/01 +1100, bj wrote:
>What is the best strategy for performing some action when the session
>times out?
>
>I'm in the middle of my first webware app =) and I need to do some
>processing on middlekit objects if the session times out. At the moment,
>I store an object in the session that has my session cleanup code in
>the __del__ method.
>
>thanks,
>later
>BJ
I don't think your current method works properly if you restart the
appserver. I think the __del__ would get called when the appserver shuts
down even though your session hasn't expired.
There's an expiring() method of the Session object which is supposed to get
called when the session times out. So you could somehow replace Session
with a subclass that defines that method to do what you want. I'm not sure
if expiring() gets called in every place it's supposed to be called though.
--
- Geoff Talvola
gtalvola@...

> However, on Linux, both Mozilla and Galeon always give back the same page
> when I reload even though they seem to churn through the CGI script.
I suppose you already tried forcing mozilla to not look at it's page
cache? You can tell it to always fetch a fresh copy everytime.
I haven't really had this problem, and I use mozilla most of the time.
jack.

I haven't quite figured it, but there's something weird with
Mozilla/Galeon and reloading pages created from POST. It just doesn't
seem to do it. I usually go back and resubmit.
There's still something about Netscape 4.x, despite all it's lameness,
that keeps me coming back from time to time. It's just so much more
responsive than all the modern browsers, even IE (though Opera could
probably win me over if I gave it a chance).
On Thu, 2001-11-29 at 15:55, Chuck Esterbrook wrote:
> On Windows, I develop WebKit sites with IE & OneShot.cgi and simply hit
> reload after I make changes. Everything works fine.
>
> However, on Linux, both Mozilla and Galeon always give back the same page
> when I reload even though they seem to churn through the CGI script.
>
> Konqueror gives me back a new page, but loses the last set of POSTed
> variables thereby causing other problems.
>
> In all cases, completely quitting the brower and restarting works, but
> that's obviously painful.
>
> I tried adding this to SitePage, but it didn't help:
>
> def awake(self, trans):
> Page.awake(self, trans)
> setHeader = self.response().setHeader
> setHeader('Cache-Control', 'no-cache')
> setHeader('Expires', '0')
> setHeader('Pragma', 'no-cache')
>
> What browser do you guys use for developing WebKit sites on Linux? Do you
> have this reload problem? Do you use OneShot?
>
>
> -Chuck
>
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@...
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
>

On Windows, I develop WebKit sites with IE & OneShot.cgi and simply hit
reload after I make changes. Everything works fine.
However, on Linux, both Mozilla and Galeon always give back the same page
when I reload even though they seem to churn through the CGI script.
Konqueror gives me back a new page, but loses the last set of POSTed
variables thereby causing other problems.
In all cases, completely quitting the brower and restarting works, but
that's obviously painful.
I tried adding this to SitePage, but it didn't help:
def awake(self, trans):
Page.awake(self, trans)
setHeader = self.response().setHeader
setHeader('Cache-Control', 'no-cache')
setHeader('Expires', '0')
setHeader('Pragma', 'no-cache')
What browser do you guys use for developing WebKit sites on Linux? Do you
have this reload problem? Do you use OneShot?
-Chuck

At 12:07 PM 11/29/01 -0500, Jeff Johnson wrote:
> > What do you think of the option we sort of outlined yesterday:
> >
> > - Software or hardware load balancer distributes incoming
> > requests randomly
> > to a pool of machines running Apache (call them APACHE1,
> > APACHE2, etc).
> > - APACHE1, APACHE2, etc have a modified version of the WebKit adapter
> > running on them. The modification is: if no session ID is
> > found in the
> > request, it sends the request to a random machine, otherwise
> > it parses the
> > session ID to find which particular machine to send the
> > request to, from a
> > pool of available WebKit machines (WEBKIT1, WEBKIT2, etc).
> > The pool of
> > machines would be configurable in the adapter's config file.
> > - WEBKIT1, WEBKIT2, etc have a modified version of Session.py
> > that encodes
> > the machine name into the session key. This would be configured in
> > Application.config. The session key would be something like
> > "WEBKIT1_237480927".
> >
> > The idea being to keep requests for the same session on the same
> > machine. Would this work for you? I'm interested in helping
> > to write the
> > WebKit modifications needed.
>
>I'm a fan of cookies (or too lazy to do it the other way) but some
>people have said they can't count on them. Would this support those
>folks too?
It could be made to support them -- you just have to make sure the the
logic in the adapter knows how to find the session ID, whatever method is
being used to encode it.
>One of the suggestions for multi-domains bothers me, not only would
>bookmarks be server specific but SSL certs would have to exist for each
>domain.
But wouldn't the hardware load balancer make it look to the user like
there's only a single box, even though it's actually distributing the
requests to multiple back ends machines running Apache? I don't know about
the multiple SSL certs; could you just use a single cert and place it onto
all of your boxes?
> >
> > The other option is, as you said, to write a
> > SessionSQLStore.py to store
> > sessions in a database. You have to be a little bit careful
> > about locking
> > here, since multiple requests for the same session may be coming from
> > different appservers at the same time. I'm not sure how to
> > avoid wiping
> > out one appserver's changes with another appserver's changes
> > in that case.
>
>I started thinking about those issues and no longer think it's trivial
>:). All reads and writes would probably have to go through a method
>that locked the SQL table. Luckily I've never had to lock tables. I
>try to avoid db vendor specific code but I think you'd have to do it for
>this.
--
- Geoff Talvola
gtalvola@...

> What do you think of the option we sort of outlined yesterday:
>=20
> - Software or hardware load balancer distributes incoming=20
> requests randomly=20
> to a pool of machines running Apache (call them APACHE1,=20
> APACHE2, etc).
> - APACHE1, APACHE2, etc have a modified version of the WebKit adapter=20
> running on them. The modification is: if no session ID is=20
> found in the=20
> request, it sends the request to a random machine, otherwise=20
> it parses the=20
> session ID to find which particular machine to send the=20
> request to, from a=20
> pool of available WebKit machines (WEBKIT1, WEBKIT2, etc). =20
> The pool of=20
> machines would be configurable in the adapter's config file.
> - WEBKIT1, WEBKIT2, etc have a modified version of Session.py=20
> that encodes=20
> the machine name into the session key. This would be configured in=20
> Application.config. The session key would be something like=20
> "WEBKIT1_237480927".
>=20
> The idea being to keep requests for the same session on the same=20
> machine. Would this work for you? I'm interested in helping=20
> to write the=20
> WebKit modifications needed.
I'm a fan of cookies (or too lazy to do it the other way) but some
people have said they can't count on them. Would this support those
folks too?
One of the suggestions for multi-domains bothers me, not only would
bookmarks be server specific but SSL certs would have to exist for each
domain.
>=20
> The other option is, as you said, to write a=20
> SessionSQLStore.py to store=20
> sessions in a database. You have to be a little bit careful=20
> about locking=20
> here, since multiple requests for the same session may be coming from=20
> different appservers at the same time. I'm not sure how to=20
> avoid wiping=20
> out one appserver's changes with another appserver's changes=20
> in that case.
I started thinking about those issues and no longer think it's trivial
:). All reads and writes would probably have to go through a method
that locked the SQL table. Luckily I've never had to lock tables. I
try to avoid db vendor specific code but I think you'd have to do it for
this.

At 10:23 AM 11/29/01 -0500, Jeff Johnson wrote:
>We actually have a hardware load balancer that is collecting dust
>because I had already written oodles of cold fusion using sessions and
>getting primary keys from MS SQL Server by "select max(primaryKey) + 1".
>
>The load balancer doesn't have the option to use cookies to keep users
>on the same server. That option cost $4,000 :). Cold Fusion does
>support database storage of session variables, called client variables.
>That would solve the session problem.
What do you think of the option we sort of outlined yesterday:
- Software or hardware load balancer distributes incoming requests randomly
to a pool of machines running Apache (call them APACHE1, APACHE2, etc).
- APACHE1, APACHE2, etc have a modified version of the WebKit adapter
running on them. The modification is: if no session ID is found in the
request, it sends the request to a random machine, otherwise it parses the
session ID to find which particular machine to send the request to, from a
pool of available WebKit machines (WEBKIT1, WEBKIT2, etc). The pool of
machines would be configurable in the adapter's config file.
- WEBKIT1, WEBKIT2, etc have a modified version of Session.py that encodes
the machine name into the session key. This would be configured in
Application.config. The session key would be something like
"WEBKIT1_237480927".
The idea being to keep requests for the same session on the same
machine. Would this work for you? I'm interested in helping to write the
WebKit modifications needed.
The other option is, as you said, to write a SessionSQLStore.py to store
sessions in a database. You have to be a little bit careful about locking
here, since multiple requests for the same session may be coming from
different appservers at the same time. I'm not sure how to avoid wiping
out one appserver's changes with another appserver's changes in that case.
--
- Geoff Talvola
gtalvola@...

At 10:23 AM 11/29/01 -0500, Jeff Johnson wrote:
>The other problem is that SQL Server doesn't have Sequences. Hal Helms,
>a CF guru, writes that to overcome this, just use GetUUID() to create
>primary keys that are almost guaranteed to be unique across the entire
>world. The downside is that those primary keys are 35 bytes long.
>Yuck. I'm curious how others simulate sequences on MS SQL Server and
>similar databases. Server side locking of tables during inserts?
I'm not sure what Sequences are, but SQL Server most definitely does
support unique primary keys -- just make sure Identity is turned on for the
primary key column. Then you can insert a new row and retrieve its
auto-generated unique primary key with something like this:
SET NOCOUNT ON
INSERT INTO MyTable (MyValue1, MyValue2) VALUES ('foo', 'bar')
SELECT @@IDENTITY AS NewPrimaryKey
SET NOCOUNT OFF
In other words, @@IDENTITY is the last Identity value that was
auto-generated on the given connection.
The business with "SET NOCOUNT ON" and "SET NOCOUNT OFF" is needed due to a
bug that I read about in the Microsoft Knowledge Base.
--
- Geoff Talvola
gtalvola@...

We actually have a hardware load balancer that is collecting dust
because I had already written oodles of cold fusion using sessions and
getting primary keys from MS SQL Server by "select max(primaryKey) + 1".
The load balancer doesn't have the option to use cookies to keep users
on the same server. That option cost $4,000 :). Cold Fusion does
support database storage of session variables, called client variables.
That would solve the session problem. =20
The other problem is that SQL Server doesn't have Sequences. Hal Helms,
a CF guru, writes that to overcome this, just use GetUUID() to create
primary keys that are almost guaranteed to be unique across the entire
world. The downside is that those primary keys are 35 bytes long.
Yuck. I'm curious how others simulate sequences on MS SQL Server and
similar databases. Server side locking of tables during inserts?
I'm still reading that etoys clustering article. Good stuff!
-Jeff