[albatross-users] Oh, and another tricky one.. :)
Andrew McNamara
andrewm at object-craft.com.au
Fri Nov 8 19:24:25 EST 2002
>I have a UserPage object which has a form for various
>actions etc and also has an image.
>
>If I set the form settings and then hit the 'submit' button,
>it calls the UserPage's page_process and decodes the form
>inputs and then calls it again for the img.
>
>The image doesnt get the form changes, but if I make the
>UserPage set a state variable with the form info, then
>the UserPage/image call has access to the info.
>
>So it all works fine!! :^)
I had a similar problem with a frame based application. I did briefly
try using the RandomPage mixin, but eventually went back to having one
class for all frames (the frame URL simply includes a argument such as
"?detail=1").
The result isn't all it could be. I'm trying to think of a better
alternative.
>Thanks and sorry for the bandwidth.
No problems there.
>(Now, I just need to change the Content-type type... :)
We have a suped-up version of the popview demo application that understands
MIME. It's capable of displaying images inline, and this requires setting
headers. To do this, I added some methods to the Context object:
class PopviewAppContext(AppContext,
NameRecorderMixin,
SessionFileContextMixin,
logMixin.LogMixin):
def __init__(self, app):
AppContext.__init__(self, app)
NameRecorderMixin.__init__(self)
SessionFileContextMixin.__init__(self)
self.set_mimetype()
self.set_mimedisposition()
def write_headers(self):
SessionFileContextMixin.write_headers(self)
self.request.write_header('Pragma', 'no-cache')
self.request.write_header('Content-Type', self.mimetype)
self.request.write_header('Content-Disposition',
self.mimedisposition)
def set_mimetype(self, type = 'text/html'):
self.mimetype = type
def set_mimedisposition(self, disposition = 'inline', filename = None):
if filename:
self.mimedisposition = '%s; filename="%s"' % \
(disposition, filename.replace('_', '-'))
else:
self.mimedisposition = disposition
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
More information about the Albatross-users
mailing list