Alter DataSource During Request

0 views
Skip to first unread message

Paul Spaulding

unread,
Nov 3, 2009, 12:07:20 PM11/3/09
to Persevere
I would like to know if it is possible to alter the datasource during
a request based on the request object and then allow Persevere to
continue on with its normal processing. This goes back to my
questions about running multiple Persevere apps (
http://groups.google.com/group/persevere-framework/browse_thread/thread/c1f61517979f4982/bc4ba5a2c9eed000?hl=en#bc4ba5a2c9eed000
), but when I think of database engines like MySQL or MS SQL Server, a
single instance of the database can handle requests from multiple
webapps for different catalogs. I would like a single Persevere
application (the distinction between the application and database is
blurred) to be able to connect to any datasource on the fly based on
application logic (inspecting the request or session object), and then
pass the request to the normal Persevere app process for handling.
Callback hooks into different parts of the request lifecycle plus the
ability to manipulate the datasource (or whatever) would be ideal.

I know that there already exists a facility for JSGI HTTP Request
Handling using app and coreApp, but I am not sure how to go about what
I'm after or if it's possible. I've found that running multiple
duplicate Persevere apps is not the answer due to unnecessary resource
consumption. This is fairly straight forward in regular servlets/
PHP/.NET (take your pick), so I'm thinking this shouldn't be difficult.

Paul Spaulding

unread,
Nov 6, 2009, 12:03:41 PM11/6/09
to Persevere
Looking at the source for DataSourceManager, JavaScriptDBSource and
JavaScriptDB, I can see now that there is probably no way of doing
what I'm after without extensive changes to those classes since the
JavaScriptDB is tracked as a single static and is assumed as such
everywhere else. Maybe something for Persevere 2.0?

Kris Zyp

unread,
Nov 8, 2009, 5:25:19 PM11/8/09
to persevere...@googlegroups.com

Yes, that seems like a reasonable enhancement for 2.0. The JavaScriptDB
class itself is designed to support multiple instances/databases, but
the Persevere adapter (JavaScriptDBSource) is what uses a single static
reference to it.
Kris

Reply all
Reply to author
Forward
0 new messages