Chuck Esterbrook <ChuckEsterbrook@...> wrote:
> At 02:52 PM 10/5/2001 -0400, Matt Feifarek wrote:
> >Is there some way to do this in webkit? I see that the Page.application()
> >doesn't have any value-oriented methods.
>
> We certainly intended to make it easy to subclass Application, but haven't
> quite achieved that yet.
I also agree that this can be more easily done with module globals.
But I also think it would be nice to have a global Session, which used
all of Session's features (mostly just moving data to disk when the
application stops), but wasn't tied to a user/browser. A poor-man's
ZODB.
Ian

At 02:52 PM 10/5/2001 -0400, Matt Feifarek wrote:
>Is there some way to do this in webkit? I see that the Page.application()
>doesn't have any value-oriented methods.
We certainly intended to make it easy to subclass Application, but haven't
quite achieved that yet.
One easy option would be to make a mix-in:
class AppExtra:
def foo(self):
pass
def bar(self):
pass
from MiscUtils.MixIn import MixIn
from WebKit.Application import Application
MixIn(Application, AppExtras)
To get this going, I guess you could import this module from your Context's
__init__.py
Now you have just added foo() and bar() to the existing Application class.
The single application instance persists for the lifetime of your app
server's lifetime. However, there is only one application total, not one
per context.
Previously, I was Application oriented as well, coming from an environment
that was. However, I have found that I can just as well put my "application
level" data/functions/methods/classes in modules and use those. The benefit
is that each such module stands on its own.
With the application approach you often end up with one class that does 5
separate things, which points you to something monolithic (which makes
reused, debugging, etc. more difficult). On the other hand, you could use
multiple mix-ins like the above and still retain some modularity.
I can certainly see the advantage of having a well known place to grab
commonly used data and services.
Hope that helps.
-Chuck

"Aaron Held" <aaron@...> wrote:
> Right now I am converting a project that I started w/ DODS into webware and that is the feature that I miss most. I can build a
> query in DODS by calling methods such as
>
> callLogQuery.addWhereClause( callLogTable.State, "NJ", QueryBuilder.EQUALS)
> callLogQuery.addWhereClause( "extention", "1111", QueryBuilder.EQUALS)
> callLogQuery.addWhereClause( "duration", "60", QueryBuilder.GREATER_THAN)
I have considered making something like this, except with more
pleasant expressions. Maybe something like:
query = AND(VAR.callLogTable.State == "NJ", VAR.extension == 1111,
VAR.duration > 60)
With later Python versions (2.0, 2.1?) you can overload ==, <, >,
etc. fairly well. You cannot meaningfully overload and, or, or not
(though you could overload &, |, and ~). You also will probably get
bad results if you did "NJ" == VAR.callLogTable.State, since "NJ" gets
the first chance to test equality, and it'll just return False instead
of a fancy where-clause object.
I don't know if this would work with DDOS anyway, but it could work
well for programmers.
Ian

"Matt Feifarek" <mjf@...> wrote:
> Of course, Geoff recommended just looking in the servlet's headers store to
> see if one called "Location" was there, but setting an actual english-like
> boolean flag makes the code easier to read for folks like me that don't have
> an intimate understanding of the webkit internals.
I think this is the sort of place that an exception would be perfect
for -- you want to jump out of the current execution to do something
different. You'd have to find the write place to catch that
exception, but in the end you wouldn't have to have those big, ugly if
statements.
Ian

Hi folks.
One feature that we used often in our old days of ASP/IIS was the
Application() object.
For those of you not familiar, it's basically a session-type storage object
that persists through the life of the running application, and is available
to all scripts... as if all scripts had a shared session() that never
expired.
Is there some way to do this in webkit? I see that the Page.application()
doesn't have any value-oriented methods.
Thanks.

At 02:23 PM 10/5/2001 -0400, Aaron Held wrote:
>For now though I just need a way to pull a resultset and make an html
>table or excel sheet based on it. Since I don't need caching
>or updating are there any other advantages to MiddleKit that I am
>missing. Instead of MiddleKit I was thinking about using dtuple
>with a regular DB call.
You can do things with the MiddleKit object model like examine the types of
attributes in order to format your tables or generator forms. However, this
doesn't come with MK out of the box and the code I have written for various
projects to do this is currently proprietary.
-Chuck

I noticed that method in middlekit, but I am building a query that can have a number of completely different WHERE clauses. Calling
one method per clause is easier to understand in my situation.
I have a simple loop for each parameter
Validate input ->determine field and data type (date, string, integer) -> call addWhereClause
Doing is as one SQL statement means I still have to build the logic somewhere to create a legal where clause. I was thinking about a
little utility class that would let me generate this clause.
like ->
cBuilder.db=(cBuilder.PostGres)
cBuilder.addWhere("date","10/01/01",cBuilder.Greater_Than)
cBuilder.addOrderBy("date",cBuilder.DESC)
store.fetchObjectsOfClass('CallLog', clauses=cBuilder.clause)
For now though I just need a way to pull a resultset and make an html table or excel sheet based on it. Since I don't need caching
or updating are there any other advantages to MiddleKit that I am missing. Instead of MiddleKit I was thinking about using dtuple
with a regular DB call.
MiddleKit is great for the user admin though.
Thanks,
-Aaron
http://www.lyra.org/greg/python/dtuple.py
----- Original Message -----
From: "Chuck Esterbrook" <ChuckEsterbrook@...>
To: "Aaron Held" <aaron@...>; "tom smith" <tom@...>; <webware-discuss@...>
Sent: Friday, October 05, 2001 10:41 AM
Subject: Re: [Webware-discuss] MiddleKit Problems
> At 10:08 AM 10/5/2001 -0400, Aaron Held wrote:
> >callLogQuery.addWhereClause( callLogTable.State, "NJ", QueryBuilder.EQUALS)
> >callLogQuery.addWhereClause( "extention", "1111", QueryBuilder.EQUALS)
> >callLogQuery.addWhereClause( "duration", "60", QueryBuilder.GREATER_THAN)
> >
> >I'm actually trying to figure out the best way to handle this type of
> >query builder in webware/python today. I'm building a
> >reporting engine and I want a clean set of classes to handle the query.
>
> Here is how you do server side queries in MiddleKit:
>
> store.fetchObjectsOfClass('CallLog', clauses='where state="NJ" and
> extension="1111" and duration="60"')
>
> I think the clauses= approach is a lot easier to read and write than the
> multiple calls to create WHERE clauses. The potential downside is that this
> is direct SQL code, however this kind of simple SQL code is highly portable.
>
> Note that the above call will also pick up subclasses of CallLog if there
> are any. If for some reason you didn't want that, you could add isDeep=1 to
> the call.
>
>
> -Chuck
>
>
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@...
> https://lists.sourceforge.net/lists/listinfo/webware-discuss

We seem to have solved this little problem.
Thanks to Geoff, who set us on the right path.
The critical piece of information that we didn't really grok is that the
redirect is simply an HTTP header that is accumulated, much like the html is
accumulated via all of the self.writeln() commands. Therefore, just calling
the redirect doesn't actually change execution, it just changes the eventual
browser output.
It seems logical now, but looking back, we sort of thought of the
response.sendRedirect() similarly to a break in a for loop.
To emulate that sort of behavior, I suppose we could flush() the response at
that point, but that seems kinda ugly and unpredictable... here's what we
came up with:
Basically, we conditionalized the whole writeHTML block of the servlet. We
have a subclass of Page() that looks something like this:
class Subclass(Page):
def awake(self):
do some other stuff that builds state, including:
- get some user messages out of session for display
- check security clearance
- stuff like that...
- call super class awake()
-- this eventually executes submit
def submit(self,fields):
- this eats the form that was posted (led to the original diagnosis)
- makes some user messages
- sets a FLAG : self.pendingRedirect = 1
def writeHTML(self):
if not self.pendingRedirect:
Page.writeHTML(self)
else:
#possible alternative output here
pass
def sleep(self):
- sync() session, including storing those user messages we had
- do application specific config setting saves
- look for flag self.pendingRedirect,
- if it's there, do actual self.response().sendRedirect('url')
- call super class sleep()
Of course, Geoff recommended just looking in the servlet's headers store to
see if one called "Location" was there, but setting an actual english-like
boolean flag makes the code easier to read for folks like me that don't have
an intimate understanding of the webkit internals.
It seems pretty simple to look at it now, but it was difficult to arrive at.
Coming from the IIS/ASP totally-linear execution world, we expected that
when a redirect() happened, all action would stop and the next servlet would
start... but, the "hidden" servlet used up some input that we expected to
see on the next page.
Again, I think that if we had a better understanding of the flow of a
servlet process, we'd have been able to arrive at this conclusion ourselves.
I am going to read over Ian's "anatomy" document, and re-read the Python-9
paper, and see if I can use the results to make a flow diagram illustration.
If I get it right, we can add it to the communal documentation.
Thanks everyone; it's amazing how good the level of support is in this list.
- Matt

At 07:41 AM 10/5/2001 -0700, Chuck Esterbrook wrote:
>Note that the above call will also pick up subclasses of CallLog if there
>are any. If for some reason you didn't want that, you could add isDeep=1
>to the call.
Woops. isDeep=0 would prevent it from picking up subclasses.
-Chuck

At 10:08 AM 10/5/2001 -0400, Aaron Held wrote:
>callLogQuery.addWhereClause( callLogTable.State, "NJ", QueryBuilder.EQUALS)
>callLogQuery.addWhereClause( "extention", "1111", QueryBuilder.EQUALS)
>callLogQuery.addWhereClause( "duration", "60", QueryBuilder.GREATER_THAN)
>
>I'm actually trying to figure out the best way to handle this type of
>query builder in webware/python today. I'm building a
>reporting engine and I want a clean set of classes to handle the query.
Here is how you do server side queries in MiddleKit:
store.fetchObjectsOfClass('CallLog', clauses='where state="NJ" and
extension="1111" and duration="60"')
I think the clauses= approach is a lot easier to read and write than the
multiple calls to create WHERE clauses. The potential downside is that this
is direct SQL code, however this kind of simple SQL code is highly portable.
Note that the above call will also pick up subclasses of CallLog if there
are any. If for some reason you didn't want that, you could add isDeep=1 to
the call.
-Chuck

Check out DODS - a Java visual tool for generating an object mapping (in Java)
http://dods.enhydra.org/
It has a great GUI and is fairly easy to use and create the objects.
I've used it and can send some screenshots if your interested.
I'd rather see a robust query interface into MiddleKit first though.
Right now I am converting a project that I started w/ DODS into webware and that is the feature that I miss most. I can build a
query in DODS by calling methods such as
callLogQuery.addWhereClause( callLogTable.State, "NJ", QueryBuilder.EQUALS)
callLogQuery.addWhereClause( "extention", "1111", QueryBuilder.EQUALS)
callLogQuery.addWhereClause( "duration", "60", QueryBuilder.GREATER_THAN)
I'm actually trying to figure out the best way to handle this type of query builder in webware/python today. I'm building a
reporting engine and I want a clean set of classes to handle the query.
On the other hand I'll never need to cache the result, or even view the records as objects - so I'm not sure if I should try to
integrate this into MiddleKit or now.
Thanks,
-Aaron Held
http://www.metrony.com/
===================================================================
As Isaac Newton would say now:
If I see further than others, it is because I stand on
the shoulders of giants too dumb to patent their discoveries.
(Gregory Palast, http://www.observer.co.uk/ )
-Aaron
----- Original Message -----
From: "tom smith" <tom@...>
To: <webware-discuss@...>
Sent: Friday, October 05, 2001 5:11 AM
Subject: Re: [Webware-discuss] MiddleKit Problems
>
> On Thursday, October 4, 2001, at 10:14 PM, iron@... wrote:
>
> >> BTW If you are new to this kind of programming, MiddleKit _may_ be a
> >> big
> >> pill to swallow right off the bat. Are you already familiar with
> >> WebKit?
> >> Not that it's a prerequisite, but I suspect it is easier to learn and
> >> get
> >> some satisfaction out of early on.
> >
> > The other question is, how much do you need MiddleKit? I think you said
> > you have a working Python/MySQLdb version already. (Or was that
> > somebody
> > else?)
>
> I think that was me.
>
> I was intending to write a layer between my WebKit stuff and MySQL, but
> whilst poking around I read MiddleKit and was REALLY impressed, enough
> to want to evaluate it.
>
> Now if the Classes.csv could be made into a visual tool, which "know"
> about FormKit (something else that's caught my eye) and we wire it
> together with UIML (user interface), then I may never have to write a
> line of code again.... :-)
>
> tom
>
>
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@...
> https://lists.sourceforge.net/lists/listinfo/webware-discuss

Hi all
Apologies if this has been covered on the list, but I have been unable to
find anything in the archives ...
One of Chuck's recent postings that recommended using ThreadedAppServer over
AsyncThreadedAppServer got me to thinking about Monitor.py and what it uses.
On checking, I realised that its hard-coded to use AsyncThreadedAppServer.
Quick as a flash, I changed this to use ThreadedAppServer and recieved the
following stream of output when running "./Monitor.py start daemon":
<usual startup verbose stuff>
...
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
No Response from AppServer
Waiting for start
Couldn't start AppServer
Killing AppServer
...
It seems to behave like this regardless of if I run as 'daemon' or not.
Given that ThreadedAppServer is more stable, I'd rather be using this if at
all possible - is there perhaps a fix for this in CVS (or a few quick
changes I can make ... ?). I am using 0.5.1rc3.
Thanks,
Mark

On Thursday, October 4, 2001, at 10:14 PM, iron@... wrote:
>> BTW If you are new to this kind of programming, MiddleKit _may_ be a
>> big
>> pill to swallow right off the bat. Are you already familiar with
>> WebKit?
>> Not that it's a prerequisite, but I suspect it is easier to learn and
>> get
>> some satisfaction out of early on.
>
> The other question is, how much do you need MiddleKit? I think you said
> you have a working Python/MySQLdb version already. (Or was that
> somebody
> else?)
I think that was me.
I was intending to write a layer between my WebKit stuff and MySQL, but
whilst poking around I read MiddleKit and was REALLY impressed, enough
to want to evaluate it.
Now if the Classes.csv could be made into a visual tool, which "know"
about FormKit (something else that's caught my eye) and we wire it
together with UIML (user interface), then I may never have to write a
line of code again.... :-)
tom

> The other thing to consider is using self.application().forwardRequest()
> instead of sendRedirect(). This causes the forwarding to happen entirely
> inside of the server instead of bouncing the redirect back to the
> application. The advantage is that forwarding is very fast. The
> disadvantage is that the URL that the user sees in their browser is the
> original URL, not the one that you forwarded to.
I moved a bunch of code to redirect internally and caused some pretty obvious usability errors.
I added a record based on GET parameters and then internally redirected to a page that showed the update table.
If the user hits refresh ANOTHER record gets added (as it should), also if the users goes past the page and then hits the BACK
button he adds another duplicate record.
I like the internal redirect, but this was a bad use of it.
And I just finished fixing the problem about 10 minutes ago.
-Aaron
===================================================================
As Isaac Newton would say now:
If I see further than others, it is because I stand on
the shoulders of giants too dumb to patent their discoveries.
(Gregory Palast, http://www.observer.co.uk/ )