×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    request handler interactive?

    not sure if i've posted at the right board (python), so i post my question here too, pardon...


    hello,
    i've a little application served by mobile web server on my n95:

    ...
    def handler(req):
    r=""
    req.content_type = 'text/plain'
    r = doSomething()
    req.write(s)
    return apache.OK

    is there a way to catch an incoming request and ask for confirmation, as i would do in a phone application, e.g.

    if appuifw.query(u"exec script?","query") == True
    ...

    any other idea how to confirm incoming requests?
    is it possible at all?

    thanks + best, uno

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: request handler interactive?

    Quote Originally Posted by unoll View Post
    ...
    any other idea how to confirm incoming requests?
    Do mean to confirm all incoming requests or to confirm some particular request of your own?

    Johan

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Re: request handler interactive?

    Quote Originally Posted by jhnwkmn View Post
    Do mean to confirm all incoming requests or to confirm some particular request of your own?

    Johan
    hello johan,

    only particular requests, to a simple py-script that starts a audio recording and takes a snapshot. the script works fine already, but what i would like to achive is a popup on my phone that somebody wants to execute the script. i've seen this on the preinstalled example portal app that comes with MWS, e.g. when you request a picture from the camera. but i can't figure out how this is done... not very familiar (yet...) with python server pages etc.
    also, i wonder if there's maybe a configuration directive in httpd.conf like it seemed to exist in raccoon, where one could set camera mode to interactive.
    anyway, my basic goal is to control (confirm, deny) special incoming http-request to a script that triggers certain functions of the mobile phone, esp. camera and sound.
    any ideas & help appreciated,
    thanks, uno

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: request handler interactive?

    Quote Originally Posted by unoll View Post
    ...
    any ideas & help appreciated,
    Since you can't use appuifw from a web-server script and need to use it in order to ask the owner for confirmation, you simply have to move that part of the request processing to some other application.

    It's not as complex as it may sound. Just create an other application that the request handler contacts using some IPC mechanism, and have that other application display the confirmation question and then return the answer to the request handler. You probably can even have the request handler invoke the other application, so that it does not need to be running up front.

    You can easily make this general purpose as well, so that the request handler can pass along the text and softkeys to display, and what result to return when a softkey is chosen.

    Conceptually it's a bit problematic to involve a human in the request processing (although I fully agree that it is a quite natural and obvious step), since when a human is involved, the request processing can take an unbounded amount of time, without it actually being an error. The owner may, for instance, be a sleep. From a practical perspective the problem is real. Namely, since the web-server currently is single threaded, without timeouts the system hangs if the owner does not notice the question.

    In the Raccoon demos, where owner interaction is used, this is handled so that instant messages (that must be clicked away) are queued and shown by a separate thread so that the request handler can return immediately. The take picture demo has a built-in timer that fires after 10 seconds if the user does not react. Displaying confirmation and other messages was directly possible since the demos were implemented as native apache modules.

    Johan
    Last edited by jhnwkmn; 2008-04-01 at 10:05.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Re: request handler interactive?

    Quote Originally Posted by jhnwkmn View Post
    Since you can't use appuifw from a web-server script and need to use it in order to ask the owner for confirmation, you simply have to move that part of the request processing to some other application.
    Johan
    thanks a lot,
    that makes things clear, seems it's like in any other web environment, where i can call external programs with a system call, exec etc.
    please excuse the newbie question (and just ignore it if it's to lame...): what would be an appropriate way to call another py-script from within the request handler script? subproces module / popen? will read the docs, but a hint would be helpful.
    thanks + best,
    uno

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    457

    Re: request handler interactive?

    Quote Originally Posted by unoll View Post
    ...
    what would be an appropriate way to call another py-script from within the request handler script? subproces module / popen?
    Actually, I haven't done that so I can't provide instructions based on experience

    However, I talked with Jukka Laurila (Mr. PyS60) and currently there is no straightforward way to run, from one Python script, another Python script in another process context.

    The way to do that now, is to create a so-called stand alone Python application, that is, a Python script that is packaged into an exe that can have capabilities of its own.

    Johan

Similar Threads

  1. interactive request handler?
    By unoll in forum Python
    Replies: 4
    Last Post: 2008-04-06, 19:36
  2. Custom request fields with http get/post
    By browndrf in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-11-08, 19:57
  3. HTTP Request Pipelining
    By shashishaw in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-08-25, 16:24
  4. How can i solve this error?
    By symbian-newbie in forum Symbian C++
    Replies: 6
    Last Post: 2006-05-23, 05:33
  5. Getting started with Carbide.vs -- running the app
    By ET3D in forum Symbian Tools & SDKs
    Replies: 6
    Last Post: 2005-11-23, 17:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •