Hi Anthony,
Thanks for helping me solve this problem. I gave your solution and
corrections a try, but the request for the url
just isn't made.
I think I give up on solving the problem, there are to many issues I run
into trying to solve it. The closest to a functioning solution
is:
<a href="#vCardModal" data-toggle="modal"><img data-src="holder.js/48x48"
src="{{=URL('static','img/icons/vCard.png')}}" alt="" width="48px"
height="48px" /></a>
<div id="vCardModal" class="modal hide fade">
{{=LOAD('vcard','mailVcard',args=node.id,ajax=True)}}
</div> <!-- /modal -->
Since it's a simple form, it's not really a problem to load it while
rendering the view which contains it.
However, it leaves me with an error ticket that's puzzling me. When I
submit the form I get the following error:
Traceback (most recent call last):
File "/Users/annet/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/Users/annet/web2py/applications/init/views/vcard/mailVcard.html", line
23, in <module>
NameError: name 'form' is not defined
The view mailVcard.html contains the following code:
{{if form:}}
{{=form}}
{{pass}}
This is the mailVcard() function:
def mailVcard():
form=SQLFORM.factory(...)
if form.process(keepvalues=True).accepted:
context=dict(note=request.vars.note)
message=response.render('mail/vcard.html',context)
strIO=cStringIO.StringIO()
vstr=getVcard(int(request.args(0)))
strIO.write(vstr)
strIO.seek(0)
filename=str(session.n) + '.vcf'
if mail.send(to=request.vars.to,subject='vCard
attached',message=[None,message],\
attachments=mail.Attachment(strIO,filename=filename),reply_to=request.vars.replyTo):
response.flash="Mail sent"
session.alert='alert-success'
else:
form.errors.to="Unable to send mail"
return dict(form=form)
and this is the getVcard(id) function:
def getVcard(id):
vcard=org=n=fn=jobtitle=session.n=address=telecom=None
node=retrieve_node(db,id)
if node:
if node.computedSubClassID==SC_ORGANIZATION:
org=n=node.computedName
elif node.computedSubClassID==SC_PROFESSIONAL:
fn=node.computedNameReversed
person=db(db.person.nodeID==id).select(db.person.jobTitle).first()
if person:
n=person.lastName + ';' + person.firstName + ';' +
person.familyNamePreposition +';;'
jobtitle=person.jobTitle
session.n=n
address=retrieve_address(db,id)
telecom=retrieve_telecom(db,id)
vcard=response.render(view='vcard/vcard.vcf',org=org,n=n,fn=fn,jobtitle=jobtitle,address=address,telecom=telecom)
return vcard.replace('\n\n','\n')
else:
return None
The thing puzzling me most is that when I add the following line to
getVcard():
response.view='vcard/vcard.vcf'
vcard=response.render(view='vcard/vcard.vcf',org=org,n=n,fn=fn,jobtitle=jobtitle,address=address,telecom=telecom)
The mailVcard() function processes correctly, however, after processing the
vcard.vcf is displayed in the modal window.
When I try to correct this by adding response.view='vcard/mailVcard.html'
after if mail.send(), somehow both views are displayed.
Regards,
Annet.
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.