Here are some example controllers that are used from my earlier post:
def check(self):
for root, folders, files in os.walk('/home/py/xmlPostData/'):
c.checkList = files
return render('/check.mako')
def results(self):
session = request.environ['beaker.session']
if 'postxml' and 'posturl' in request.params:
c.postxml = request.params['postxml']
c.posturl = request.params['posturl']
elif 'checkbutton' in request.params:
c.check = []
for dist in request.params:
if re.search('checkbutton', dist):
pass
else:
c.check.append(request.params[dist])
session['checkList'] = c.check
session.save()
redirect_to(controller='lookup', action='postcheck')
else:
c.xmlResults = {}
for wd in session['checkList']:
c.xmlResults[wd] = session['xmlResponse']
return render('/results.mako')
I wouldn't say this is the best way to go about things and is rather sloppy.
This is all part of quite a major system so please overlook the example and
take what you need. It is poorly documented so I apologize for that.
On Mon, Oct 12, 2009 at 11:48 AM, gazza <[email protected]> wrote:
>
> Hi,
>
> I actually went ahead and did what what Ken did, I will have a look it
> how Johnathan implemented it.
>
> <table cellspacing=5>
> % for item in c.list:
> <tr>
> <td>
> ${item.description}
> </td>
> <td>
> $item.price}
> </td>
> <td>
> <input type="checkbox" name=$item.description value=
> $item.description/>
> </td>
> </tr>
>
> When posting to an action in the controller. How does it get the
> values of the checkboxes?
>
> Much appreciated,
> garyc
>
>
>
>
> On Oct 12, 10:17 am, Jonathan Vanasco <[email protected]> wrote:
> > the simplest:
> >
> > <td>
> > ${h.check_box('fieldname')}
> > </td>
> >
> > it looks like it was changed a bit though to:
> > checkbox(name, value=’1’, checked=False, label=None, **attrs)
> >
> > when looping things like Ken suggested, i like to do stuff like this:
> >
> > % for id in list:
> > <%
> > checked= ''
> > if test:
> > checked= ' checked="checked"'
> > %>
> > <input name="checks" value="${id}"${checked}/>
> > %endfor
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---