[albatross-users] New tag reference
Michael C. Neel
neel at mediapulse.com
Fri Jun 6 08:44:13 EST 2003
> Michael> Looks like I missed this post too, but this looks really
> Michael> great. The one part I would add is an example
> of each tag on
> Michael> the form side being parsed on submission, i.e.
> showing how to
> Michael> get at the data from a <al-input type=file> etc.
>
> I am not sure that I understand what you are asking here.
>
What you have is:
>>> import albatross
>>> class Ctx(albatross.SimpleContext):
... def input_add(self, *args):
... print args
...
>>> ctx = Ctx('.')
>>> albatross.Template(ctx, '<magic>', '''
... <al-input type="file" name="resume" whitespace>
... ''').to_html(ctx)
('file', 'resume', None, 0)
>>> ctx.flush_content()
<input type="file" name="resume">
What I'd like to see added after that is:
# page module code, inside page_process(), saves the uploaded file
if ctx.req_equals("resume") and len(ctx.locals.resume.value):
filename = "/home/uploads/resumes/new_file.txt"
file = open(filename, 'wb')
file.writelines(ctx.locals.image.value)
file.close()
Actually, it should be alittle more than that, showing getting the
filename as it was on the client's system - but this is off the top of
my head and I don't remember where that's stored atm (hence the need for
the reference =)
Thanks,
Mike
More information about the Albatross-users
mailing list