*Sorry everybody but i need your help again.*

Here is my code:

def languages_pedit(): 

  req_id=request.args(0)

  form = SQLFORM.factory(

  Field('sortpdf', 'string', label='Sort-by', 
requires=IS_IN_SET(['ISO-Code','Description']), default='ISO-Code'),

  formstyle = 'table3cols',

  submit_button='Submit')

  if form.process(onvalidation=languages_validate).accepted:

  response.flash = 'Form Accepted'

  redirect(URL('print_languages',args=request.vars.sortpdf))

  elif form.errors:

  response.flash = 'form has errors'

  response.title = 'Languages'

  return dict(form=form)

 

 * #I tried this mk_pdffile(pdffile,'languages.pdf') but it did not work*

def mk_pdffile(pdffile,pdfname):

  import cStringIO

  pdfdata = open(pdffile,"rb").read()

  response.headers['Content-Type']='application/pdf' 

  return response.stream(cStringIO.StringIO(pdfdata), attachment=True, 
filename=pdfname)

 

@auth.requires_login()

def print_languages(): 

  sortpdf=request.args(0)

  if len(request.args):

  import datetime

  now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

  if sortpdf=='ISO-Code': 

  ORDERBY=db.allanguages.lang_iso

  else: 

  ORDERBY=db.allanguages.description

  records = db(db.allanguages.id>=0).select(orderby=ORDERBY)

  ltxfile = str(os.path.join(request.folder, 'tex', 'languages.tex'))

  pdffile = str(os.path.join(request.folder, 'tex', 'languages.pdf'))

  with open (ltxfile, 'wb') as texfile:

  .......................................

  #Code to make my texfile....................

  .......................................

  texfile.write('\\end{document}\n')

  texfile.close()

  os.system('pdflatex '+ltxfile)

  if os.path.isfile(pdffile): 

  os.remove(pdffile)

  os.rename('languages.pdf', pdffile)

  pdfdata = open(pdffile,"rb").read()

  response.headers['Content-Type']='application/pdf' 

  return response.stream(cStringIO.StringIO(pdfdata), attachment=True, 
filename='languages.pdf') 

 

*This works fine but the code below does not get excecuted and my SUBMIT 
Button stays pressed?*

  

  return dict(redirect(URL('languages_pedit')))

 

--------------------------------------------------------------------------------------------------------------------------

*1)Why doesn’t web2py excecuted return dict(red......, after opening the 
pdf-file with return response.stream(c....*

 
*2)After displaying the pdf-file my SUBMIT Button stays pressed*

*3)Is there another way to excecute the response.stream, something like 
excecute or activate instead of return?*

 
*What am i doing wrong?????*

 

*karl*

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to