|Newbie questions about Pliant
Manipulate db externally from web
While my pliant website is running, I would like
to read/write from db.
|Message posted by maybe Boris Reitman on 2006/12/29 22:01:16
|I need this for testing. I will start the webserver with an empty database,
and the test script will populate it according to a test case scenario.
Then I want to access some URLs and test is that I get reflects what I have put
into the db.
So the test looks somewhat like this:
- init db with few test data records
- call some internal functions and test api on my datastructures
- get url and grep html output
- press some more buttons in the web-interface (with web-robot)
- query db with my api functions and check that db is update accordingly
- repeat these cycles
Here are possibilities that I am thinking.
1. Create file called run_test.page wich accepts as a cgi parameter a name of
a .pli file. It then reads its contents and runtime compiles it, and executes.
This way everything runs in the same process. I am not sure if a .page can
do such thing.
2. Another way: create a release_db.page which when called does a db store and unload.
and a load_db.page which when called loads a db. The test script will call these
urls before and after it wants to mess with the database.
3. Another way: run the server in the test_script process. What are the disadvantages ?
If I do it this way, can I execute a .page without going through TCP/IP communication, and just test
the contents of streams of HttpRequest structure ?
4. Another way: create a db proxy object that represents a db running in
another process. All data will be sent by rpc calls. I have no idea
how to implement this.
Which way would you recommend to minimize script running time ?
Please note that I already have a robot code in perl to automate a pliant site.
It emulates pliant's pliant.js by pre-processing http request before it gets submitted.
Assume that the robot can be used from pliant using pliant-perl binding.
An example of a working test script:
|Message posted by maybe Hubert Tonneau on 2006/12/30 00:55:29
|I don't understand what your problem is.
You can have a thread waiting for external events through something like this
in a .pli
if ... # do we have a new event
... # process it
sleep 1 # wait
Or just use a .page if your other process is abble to do a HTTP request as a
way to notify Pliant that some data must be processed.