[albatross-users] Standalone HTTP Albatross server

Matt Goodall matt at pollenation.net
Mon Jun 30 00:23:24 EST 2003


Great stuff, I'm glad it worked for you too. However, are you sure it's
working when the 'list' attribute is set? I'm quite surprised since the
Request class does:

        def field_value(self, name):
                return self._fields[name][0]
                                        ~~~~~

I don't actually know how the list stuff works though, perhaps the above
does not matter? I'll try to test 'list' explicitly and see what
happens.

I'm fairly sure that I will need file upload support so it should get
fixed. The main issue is finding time to find out how to do it - the cgi
module is not the easiest module in Python's stdlib. I will look at how
the other Request adapters work for guidance.

Do you have any issues with how it is implemented? Are there better ways
of doing this stuff that I don't know about?

Cheers, Matt

On Sun, 2003-06-29 at 12:02, Dave Cole wrote:
> > Attached is the first cut at a simple, standalone HTTP server script
> > for Albatross apps. It's been written for 1.10pre1 although there
> > seems to be a bug in that version which stops it actually
> > working. See my post of 19 Jun 2003 for more on the bug and a
> > possible solution.
> 
> I finally got enough things out of the way to have a bit of a play
> with this stuff.
> 
> > The script is working ok for me but it has only had minimal testing
> > and has some known limitations:
> > 
> >       * No file upload support. I will try to sort that out soon.
> 
> That would be cool but not essential.
> 
> >       * It uses the standard BaseHTTPServer module so it's not much more
> >         that a toy. It's ok for local development and as a very low use
> >         server i.e. for single user, web-based apps.
> 
> That is not big deal.  Greg (one of the programmers here) used
> Albatross in an embedded control system.  This code would have been
> very useful in further reducing the memory footprint.
> 
> > I'm posting this now in the hope that it is useful in its current
> > form (i.e. without file upload) and maybe to get some feedback.
> 
> I did the simplest thing I could think of and copied some of the
> sample code from the manual to test this:
> 
> I saved your code as httpd.py
> 
> It works like a bought one.  Extremely cool.
> 
> Andrew, do you think we should put this into Albatross now?
> 
> - Dave
> 
> - - cheeky.py - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> from albatross import SimpleApp
> import httpd
> 
> class Form:
>     def page_enter(self, ctx):
>         ctx.locals.text = ctx.locals.singleton = ctx.locals.group = \
>                           ctx.locals.radio = ctx.locals.select = None
>         ctx.locals.num = 0
>         ctx.add_session_vars('num')
> 
>     def page_display(self, ctx):
>         ctx.locals.num += 1
>         ctx.run_template('form.html')
> 
> app = SimpleApp(base_url = 'cheeky.py',
>                 template_path = '.',
>                 start_page = 'form',
>                 secret = '-=-secret-=-')
> app.register_page('form', Form())
> 
> server = httpd.HTTPServer(app, 8080)
> server.serve_forever()
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> 
> - - form.html (from albatross documentation) - - - - - - - - - - - - -
> <html>
>  <head>
>   <title>Display Form Input</title>
>  </head>
>  <body>
>   Input some values to the following form and press the submit button.
>   <al-form method="post">
>    Text field: <al-input name="text"><br>
>    Singleton checkbox: <al-input type="checkbox" name="singleton"><br>
>    Checkbox group:
>    <al-input type="checkbox" name="group" list value="check1">
>    <al-input type="checkbox" name="group" list value="check2"><br>
>    Radio buttons:
>    <al-input type="radio" name="radio" value="radio1">
>    <al-input type="radio" name="radio" value="radio2"><br>
>    Option menu:
>    <al-select name="select">
>     <al-option>option1</al-option>
>     <al-option>option2</al-option>
>     <al-option>option3</al-option>
>    </al-select>
>    <al-input type="submit" name="submit" value="submit">
>   </al-form>
>   number of requests: <al-value expr="num"><br>
>   text: <al-value expr="text"><br>
>   singleton: <al-value expr="singleton"><br>
>   group: <al-value expr="group"><br>
>   radio: <al-value expr="radio"><br>
>   select: <al-value expr="select"><br>
>  </body>
> </html>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- 
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt at pollenation.net



More information about the Albatross-users mailing list