[albatross-users] Form Field Value Storage Changed?

Michael Barrett mike at daboyz.org
Sat Jan 11 19:28:18 EST 2003


Ok, here's a minimal application that doens't work the way I'd expect it to on
my system.  There are four parts.  The template, the script, my RandomSessionFileApp mixin (I think thats the proper term?) and the index.py.

index.py:

#!/usr/local/bin/python
from albatross import SessionFileAppContext
from albatross.cgiapp import Request
import sys, md5
sys.path.append('.')
from albext import RandomModularSessionFileApp



class AppContext(SessionFileAppContext):
    def __init__(self, app):
        SessionFileAppContext.__init__(self, app)

        self.log = open('/tmp/ocd.log','a',0)


class App(RandomModularSessionFileApp):
    def __init__(self):
        RandomModularSessionFileApp.__init__(self,
                                             base_url = 'index.py',
                                             module_path = './lib',
                                             template_path = './templates',
                                             start_page = 'test',
                                             secret = '-=-secret-=-',
                                             session_appid = 'alb',
                                             session_dir = './session')

        # Configuration data
        self.Config = {}
        self.Config['smtpHost'] = '127.0.0.1'
        self.Config['smtpPort'] = 25
        self.Config['siteurl'] = 'http://home.daboyz.org/ocd/alb'

    def create_context(self):
        return AppContext(self)


if __name__ == '__main__':
    app = App()
    app.run(Request())

======
lib/test.py:

def page_enter(ctx):
    ctx.locals.submitted = 0

def page_display(ctx):
    ctx.run_template('test.xml')

======
templates/test.xml:

<html>
    <body>
        <al-form method="post">
            <input class="button" type="submit" name="submitted" value=1>
        </al-form>
        Submitted? - <al-value expr="submitted"> -
    </body>
</html>

======
albext.py:


from albatross.context import CachingTemplateLoaderMixin, PickleSignMixin, _caller_globals
from albatross.app import Application, PageModuleMixin
from albatross.sessionfile import SessionFileAppMixin, SessionFileAppContext

from albatross.randompage import RandomPageModuleMixin

class RandomModularSessionFileApp(PickleSignMixin,
                                  Application,
                                  CachingTemplateLoaderMixin,
                                  RandomPageModuleMixin,
                                  SessionFileAppMixin):

    def __init__(self, base_url, module_path, template_path, start_page, secret,
                 session_appid, session_dir):
        PickleSignMixin.__init__(self, secret)
        Application.__init__(self, base_url)
        CachingTemplateLoaderMixin.__init__(self, template_path)
        RandomPageModuleMixin.__init__(self, module_path, start_page)
        SessionFileAppMixin.__init__(self, session_appid, session_dir)

    def create_context(self):
        return SessionFileAppContext(self)

======

    Anyways, you can see this running @ http://home.daboyz.org/alb/

    As you'll see, no matter if you click on the button or not, submitted is
    still set to '0'.  Did page_enter and page_display change possibly?

    I'm at a loss so far, and I thought maybe it was something simple that I
    just wasn't aware of in the change of versions that someone who's been
    more active with albatross over the past couple months might be able to
    pick up right away.

    Again, thanks for all your help.

On Mon, Jan 06, 2003 at 01:00:54PM +1100, Andrew McNamara wrote:
> The merging of fields back into the local context was tightened slightly
> in the name of security, although I'm not sure how this would be effecting
> your application.
> 
> Are you able to post a minimal application that demonstrates the problem
> you are seeing?



More information about the Albatross-users mailing list