I am till confused about (1). The url "...buy_one/3#zoom-t2_person-foto-41" is not generated by T2. Do you have
db.table.field.represent=... somewhere? (2) The trunk will be promoted to production in about one week. Massimo On Dec 29, 10:47 am, Peter <peter.kleyn...@gmail.com> wrote: > Hi Massimo, thanks for helping out again... > > Re (1), interaction between T2 and args passed in the query string, > here's the basic code: > > in default.py: > def buy_one(): > prod=db(db.product.id==request.args[0]).select()[0] > form = t2.display(db.t2_person,query= > (db.t2_person.id==t2.person_id)) > return dict(form=form,prod=prod) > > in buy_one.html: > {{extend 'layout.html'}} > <!-- ...some use of { {=prod.fields} }, presentation of product to > buy... --> > {{=form}} <!-- show personal details, present edit --> > <p><a href="{{=URL(r=request,f='edit_details',vars=dict > (next='buy_one'))}}">Click here</a> to edit your details.</p><br/> > > The initial URL is eg ".../default/buy_one/3" (ie, prod_id=3) > When I click on the image presented (very nicely, by the way) by > t2.display, the resulting URL is>>> "...buy_one/3#zoom-t2_person-foto-41" > which clearly can't work. > > Using a request.var (?prod_id=3) leads to a similar result. > > None of this is a dealbreaker, but I was starting to wonder if it was > generally unwise (ie, stupid) to use request.args and .vars in > combination with T2 forms. > The default "args[-1]=t2.id" behavior in T2 also points in that > direction. If it's just a fluke, I can try to work around it. Elements > (...) again... ;-) > > Re (2), using the elements(...) fix-- it IS attractive for lots of > little issues I have. When do you expect this functionality to appear > in a production release? If that is within a week or two, I can use > trunk for my current project... > > Cheers & thanks for a great tool, > -Peter > > On Dec 29, 3:21 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > 1) I am sorry. I do not understand without a code example. > > > 2) not possible. I agree there should be a way to do it. > > Using the latest trunk you can do > > > form.element(_type='submit').update(_value='click me!') > > > Massimo > > > On Dec 29, 5:21 am, Peter <peter.kleyn...@gmail.com> wrote: > > > > Thank you -- based on all of your input I'm having another stab at > > > using T2. > > > Two more questions: > > > > - How do you pass variables to T2-enabled pages without breaking T2 > > > behaviors? For instance, I have a page where person X buys product P; > > > prod_id is passed as a var or an arg in the query string. The T2 form > > > shows person X's details, including an inline image (very nice ;-)), > > > but the #zoom anchor doesn't work because the prod_id in the URL gets > > > in the way. What's the best practice here?? I can sneak prod_id into > > > the session vars, but that doesn't seem very RESTful -- apart from it > > > being a pain not being able to embed the prod_id in a link... > > > > - Call me stupid, I can't find the way to rename the submit button on > > > T2 update/create forms? I know you can do this with submit_button= in > > > SQLFORM, but this doesn't seem to get passed into T2 forms. The only > > > way is to manipulate the components[..] stuff -- eg, through the new > > > elements interface? > > > > Cheers again... > > > -Peter > > > > On Dec 29, 7:10 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > define a widget, something like: > > > > > def myhelper(field,value): > > > > field_id='%s_%s' % (field._tablename,field.name) > > > > inp=INPUT(_type='file',_id=field_id,_class=field.type, > > > > _name=field.name, requires=field.requires) > > > > if not value: return inp > > > > url='app/controller/download/'+value ###### edit this line > > > > return DIV(inp,IMG(_src=url,_width=200), > > > > INPUT(_type='checkbox',_name=field.name > > > > +'__delete'),'delete]') > > > > > tell web2py that the field should be represented by the widget. > > > > > works with sqlform, t2 and t3. > > > > > Massimo > > > > > db.yourtable.yourfield.represent=myhelper > > > > > On Dec 28, 3:42 pm, Peter <peter.kleyn...@gmail.com> wrote: > > > > > > I need to display a form with images inline, ie with <img> tags. The > > > > > default behavior for SQLFORM is to only show a <file> link on the form > > > > > (assuming I provide a download URL in the constructor, which I do). > > > > > > What's the best way to do this -- if at all? Again, I have difficulty > > > > > "breaking into" the SQLFORM object... Am I doomed to write my own > > > > > upload logic? > > > > > > BTW, I would really appreciate a more formal API for SQLFORM that is > > > > > more geared towards using it piecemeal rather than the single > > > > > {{=form}}, which is suitable less than half of my current > > > > > application's forms. Ideally, any magic that SQLFORM provides should > > > > > be exposed in a lower-level API as well... > > > > > > Note: I'm not a hardcore Pythonhead, more the type of "enterprise" > > > > > developer that I think Massimo seems to have had in mind when he > > > > > called web2py a "enterprise" framework. ;-) I thought I would be able > > > > > to get going quickly with SQLFORM and T2 CRUD, but so far, it's been a > > > > > bit of an uphill battle, I'm afraid... All the more frustrating > > > > > because I think it's very very close to what I need. > > > > > > Cheers, > > > > > -Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---