[web2py] Is web2py the right tool for a report project?
I'm rewriting a python report script that processes CSV files and emails the reports on a monthly basis (triggered from system cron). My python script basically does the following: 1. Parse CSV data. 2. Write html report and save to archive directory on server. 3. Email report as attachment to admins. In the new version, I want to use a templating language so my first thought was to use jinja or mako. But then I got to thinking eventually, I'd like this report to also have a web interface where uses could customize criteria or simply run the defaults manually in between scheduled monthly runs. So perhaps I could learn web framework like web2py and build the new report around web2py and use web2py for templating. However, in reading the docs, it's becoming clear to me that web2py expects to serve the output to a browser, not write monthly files (based on a pre-defined template) to system disk and then email the file to recipients. I'm a web2py newbie. Is this a good first project, or should I stick with python scripts & a templating library to produce the reports. What are your comments/advice? Thanks!
[web2py] mod_rewrite problems on Apache
Hello everyone, I'm trying to rewrite URLs because I can't install web2py on Apache root. I'm using web2py 2.0.9 apps on CentOS 5 & 6 servers. I've fighting this thing for hours... I'm open to using routes.py or getting correct apache syntax. Anything to get a solution. Below is my apache file. It works fine on my CentOS 6 servers Apache Server version: Apache/2.2.15, but on CentOS 5, Server version: Apache/2.2.3 the rewrite rules never fire. I'm totally vexed. I tried using routes.py, routes_out = ((r'/(?P.*)', r'/w2p/\g'),) but on one page, I'm using the FORM helper and the submit button SID links to /reporter/ and so then Apache fires a 404. NameVirtualHost *:80 ServerName web2py RewriteEngine on RewriteLog "/var/log/httpd/rewrite_log" RewriteLogLevel 9 RewriteRule ^/reporter(.*)$ /w2p/reporter$1 [PT,L] RewriteRule ^/welcome(.*)$ /w2p/welcome$1 [PT,L] WSGIScriptAlias /w2p /opt/sap/www/web2py/wsgihandler.py AllowOverride None Order Allow,Deny Deny from all Allow from all AliasMatch ^/([^/]+)/static/(.*) \ /opt/sap/www/web2py/applications/$1/static/$2 Order Allow,Deny Allow from all Deny from all Deny from all Any suggestions or help for me? TIA! Dave -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: mod_rewrite problems on Apache
Thank you very much for that suggestion! It solved my problem, for which I'm most appreciative. Thanks jonten! On Sunday, June 9, 2013 5:17:47 PM UTC-4, jonten wrote: > > I had a similar problem when I recently did a setup with Web2py and Apache > which I did not want to dedicate to the directory root of the web server. > The part I had to modify to get it to work was: > > WSGIScriptAlias / /var/www/web2py/wsgihandler.py > > with: > > WSGIScriptAliasMatch ^/myapp.* /var/www/web2py/wsgihandler.py > WSGIScriptAliasMatch ^/admin.* /var/www/web2py/wsgihandler.py > > I'm not sure if this is the best solution, but it worked for me :) > > //Jon > > On Saturday, June 8, 2013 8:06:27 PM UTC+2, thinkwell wrote: >> >> Hello everyone, >> >> I'm trying to rewrite URLs because I can't install web2py on Apache root. >> I'm using web2py 2.0.9 apps on CentOS 5 & 6 servers. I've fighting this >> thing for hours... I'm open to using routes.py or getting correct apache >> syntax. Anything to get a solution. >> >> Below is my apache file. It works fine on my CentOS 6 servers Apache >> Server version: Apache/2.2.15, but on CentOS 5, Server version: >> Apache/2.2.3 the rewrite rules never fire. I'm totally vexed. >> >> I tried using routes.py, >> routes_out = ((r'/(?P.*)', r'/w2p/\g'),) >> >> but on one page, I'm using the FORM helper and the submit button SID >> links to /reporter/ and so then Apache fires a 404. >> >> >> >> NameVirtualHost *:80 >> >> >> ServerName web2py >> RewriteEngine on >> RewriteLog "/var/log/httpd/rewrite_log" >> RewriteLogLevel 9 >> RewriteRule ^/reporter(.*)$ /w2p/reporter$1 [PT,L] >> RewriteRule ^/welcome(.*)$ /w2p/welcome$1 [PT,L] >> WSGIScriptAlias /w2p /opt/sap/www/web2py/wsgihandler.py >> >> >> AllowOverride None >> Order Allow,Deny >> Deny from all >> >> Allow from all >> >> >> >> AliasMatch ^/([^/]+)/static/(.*) \ >> /opt/sap/www/web2py/applications/$1/static/$2 >> >> >> Order Allow,Deny >> Allow from all >> >> >> >> Deny from all >> >> >> >> Deny from all >> >> >> >> Any suggestions or help for me? >> >> TIA! >> >> Dave >> > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Is web2py the right tool for a report project?
Yea! response.render is the function that I was looking for. The web2py book says: Almost all of its components are built from scratch and are designed to work together, but they function just as well outside of the complete web2py framework. For example, or the template language can be used independently of the web2py framework by importing gluon.dal or gluon.template into your own Python applications. So I thought it could be done, but wasn't getting the *how. *I wish it was clearer exactly *how* that is achieved in the context of individual files, instead of http responses. Anyway, that function gets me out of my cramp. @ villas - thanks for that link looks very helpful and gives me some useful ideas for my report project. Thanks for posting it! On Thursday, June 14, 2012 3:47:15 AM UTC-4, Niphlod wrote: > > yep. web2py can produce csv files as well, and html reports. with > response.render you can "redirect" the normal template to a file instead of > letting it go to the browser. >
[web2py] KeyError on pyfpdf
Hello everyone, I'm experimenting with pyfpdf with HTML formatting, but it's not going so well. Is a bit buggy. For example, this code generates a KeyError: 'width'. {from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.html import * header = HEAD('html2pdf', _align='center') pets = TABLE(_border=1, _width="100%") pets.append(TR(TH('Dogs'),TH("Cats"),TH('Snakes'))) pets.append(TR('Collies','Tabby','Python')) pets.append(TR('Akitas', 'Persian', 'Garter')) class MyFPDF(FPDF, HTMLMixin): pass html2 = pets.xml() print html2 pdf=MyFPDF() #First page pdf.add_page() pdf.write_html(html2) pdf.output('html2.pdf','F')} I {/usr/lib/python2.7/HTMLParser.pyc in goahead(self, end) 156 if startswith('<', i): 157 if starttagopen.match(rawdata, i): # < + letter --> 158 k = self.parse_starttag(i) 159 elif startswith(" 324 self.handle_starttag(tag, attrs) 325 if tag in self.CDATA_CONTENT_ELEMENTS: 326 self.set_cdata_mode(tag) /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.pyc in handle_starttag(self, tag, attrs) 245 self.td = dict([(k.lower(), v) for k,v in attrs.items()]) 246 self.th = True --> 247 if self.td.has_key('width'): 248 self.table_col_width.append(self.td['width']) 249 if tag=='thead': KeyError: 'width' } I tried changing line 247 to - {if self.td.has_key('width'):} But the KeyError is still getting raised. :-( Is generating reports from HTML not recommended? In addition to this KeyError, I've frequently gotten "list out of range" exceptions raised as well, on what seem like the most vanilla of experiments.
Re: [web2py] KeyError on pyfpdf
Thanks Mariano & Alan. Adding width to TD or TH tags did resolve the problem using the original html.py file without the fix implemented.*(Mariano, I tried installing your script and at this point it still fails when no width is specified. Another little issue, os.startfile() seems to be a Windows-only method.)* So now, things are operational again. Looking forward to Mariano's html.py improvements. On Sunday, July 15, 2012 3:04:04 PM UTC-4, Mariano Reingart wrote: > > On Sat, Jul 14, 2012 at 5:06 PM, thinkwell wrote: > > Hello everyone, > > > > I'm experimenting with pyfpdf with HTML formatting, but it's not going > so > > well. Is a bit buggy. For example, this code generates a KeyError: > 'width'. > > > > {from gluon.contrib.pyfpdf import FPDF, HTMLMixin > > from gluon.html import * > > > > header = HEAD('html2pdf', _align='center') > > > > pets = TABLE(_border=1, _width="100%") > > pets.append(TR(TH('Dogs'),TH("Cats"),TH('Snakes'))) > > pets.append(TR('Collies','Tabby','Python')) > > pets.append(TR('Akitas', 'Persian', 'Garter')) > > > > > > class MyFPDF(FPDF, HTMLMixin): > > pass > > > > html2 = pets.xml() > > > > print html2 > > > > pdf=MyFPDF() > > #First page > > pdf.add_page() > > pdf.write_html(html2) > > pdf.output('html2.pdf','F')} > > > > I > > {/usr/lib/python2.7/HTMLParser.pyc in goahead(self, end) > > 156 if startswith('<', i): > > 157 if starttagopen.match(rawdata, i): # < + letter > > --> 158 k = self.parse_starttag(i) > > 159 elif startswith(" > 160 k = self.parse_endtag(i) > > > > /usr/lib/python2.7/HTMLParser.pyc in parse_starttag(self, i) > > 322 self.handle_startendtag(tag, attrs) > > 323 else: > > --> 324 self.handle_starttag(tag, attrs) > > 325 if tag in self.CDATA_CONTENT_ELEMENTS: > > 326 self.set_cdata_mode(tag) > > > > /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.pyc in > > handle_starttag(self, tag, attrs) > > 245 self.td = dict([(k.lower(), v) for k,v in > > attrs.items()]) > > 246 self.th = True > > --> 247 if self.td.has_key('width'): > > 248 self.table_col_width.append(self.td['width']) > > 249 if tag=='thead': > > > > KeyError: 'width' > > } > > > > I tried changing line 247 to - > > {if self.td.has_key('width'):} > > > > But the KeyError is still getting raised. :-( > > You need to restart the webservice to apply changes in gluon > > > Is generating reports from HTML not recommended? In addition to this > > KeyError, I've frequently gotten "list out of range" exceptions raised > as > > well, on what seem like the most vanilla of experiments. > > Current html2pdf conversion will not work properly if you don't use > explicit widths for table cells. > You can see the supported tags and a working example here: > > http://code.google.com/p/pyfpdf/wiki/WriteHTML > > Actually, I'm working in a better html2pdf render, using helpers and > web2pyHTMLParser: > > http://code.google.com/p/pyfpdf/source/browse/fpdf/html.py > > Hopefully, web2py helpers will improve the rendering mechanisms > > Best regards, > > Mariano Reingart > http://www.sistemasagiles.com.ar > http://reingart.blogspot.com >
Re: [web2py] KeyError on pyfpdf
Well, me again. I decided that I wanted to use points as measurements instead of percentages, so now it barfs with an AttributeError. from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.html import * pets = TABLE(_width="720pt") pets.append(TR(TH('Dogs', _width="72pt", _align="left"),TH("Cats",_width="72pt", _align="left"),TH('Snakes',_width="72pt", _align="left"))) pets.append(TR('Collies','Tabby','Python', _width="60pt")) pets.append(TR('Akitas', 'Persian', 'Garter')) pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes')) class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF() #First page pdf.add_page() pdf.write_html(pets.xml()) pdf.output('html2.pdf','F') This is clearly unremarkable HTML, but no, I get tracebacks like so: Traceback (most recent call last): File "pyfpdf_test.py", line 73, in pdf.write_html(pets.xml()) File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", line 388, in write_html h2p.feed(text) File "/usr/lib/python2.7/HTMLParser.py", line 114, in feed self.goahead(0) File "/usr/lib/python2.7/HTMLParser.py", line 158, in goahead k = self.parse_starttag(i) File "/usr/lib/python2.7/HTMLParser.py", line 324, in parse_starttag self.handle_starttag(tag, attrs) File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", line 241, in handle_starttag self.pdf.set_x(self.table_offset) AttributeError: HTML2FPDF instance has no attribute 'table_offset' I find this remarkable; this ordinary HTML; web2py encourages the use of HTML helpers. web2py is easy to use, requires few dependencies, etc. etc. But what a *fight* to create a simple table-based PDF! :-( And I'm still experimenting in the layout stage. My final report will be much larger and include nested tables *(that are already rendering fine in HTML, but not in pyfpdf / html2pdf)*. Should I bite the bullet and install Reportlab? It'll be harder to get started, more complicated to install & maintain (this will have to go on multiple machines). The idea of a simple web2py project was very attractive for these reasons. Are others out there creating PDFs from HTML with pyfpdf & html2pdf?? --
Re: [web2py] KeyError on pyfpdf
No, the "em" still raises an AttributeError. In the post above, I've included all the code to duplicate the problem... On Monday, July 16, 2012 4:17:48 PM UTC-4, Derek wrote: > > Try to use "em", see if you still get the same problem. > > 1em = 12pt > > http://www.getallfix.com/2011/11/convert-empxpt-and-in-css/ > > On Monday, July 16, 2012 1:08:13 PM UTC-7, thinkwell wrote: >> >> Well, me again. I decided that I wanted to use points as measurements >> instead of percentages, so now it barfs with an AttributeError. >> >> >> from gluon.contrib.pyfpdf import FPDF, HTMLMixin >> from gluon.html import * >> >> >> pets = TABLE(_width="720pt") >> pets.append(TR(TH('Dogs', _width="72pt", >> _align="left"),TH("Cats",_width="72pt", >> _align="left"),TH('Snakes',_width="72pt", _align="left"))) >> pets.append(TR('Collies','Tabby','Python', _width="60pt")) >> pets.append(TR('Akitas', 'Persian', 'Garter')) >> pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes')) >> >> >> class MyFPDF(FPDF, HTMLMixin): >> pass >> >> pdf=MyFPDF() >> #First page >> pdf.add_page() >> pdf.write_html(pets.xml()) >> pdf.output('html2.pdf','F') >> >> >> This is clearly unremarkable HTML, but no, I get tracebacks like so: >> >> Traceback (most recent call last): >> File "pyfpdf_test.py", line 73, in >> pdf.write_html(pets.xml()) >> File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", >> line 388, in write_html >> h2p.feed(text) >> File "/usr/lib/python2.7/HTMLParser.py", line 114, in feed >> self.goahead(0) >> File "/usr/lib/python2.7/HTMLParser.py", line 158, in goahead >> k = self.parse_starttag(i) >> File "/usr/lib/python2.7/HTMLParser.py", line 324, in parse_starttag >> self.handle_starttag(tag, attrs) >> File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", >> line 241, in handle_starttag >> self.pdf.set_x(self.table_offset) >> AttributeError: HTML2FPDF instance has no attribute 'table_offset' >> >> I find this remarkable; this ordinary HTML; web2py encourages the use of >> HTML helpers. web2py is easy to use, requires few dependencies, etc. etc. >> But what a *fight* to create a simple table-based PDF! :-( And I'm still >> experimenting in the layout stage. My final report will be much larger and >> include nested tables *(that are already rendering fine in HTML, but not >> in pyfpdf / html2pdf)*. >> >> Should I bite the bullet and install Reportlab? It'll be harder to get >> started, more complicated to install & maintain (this will have to go on >> multiple machines). The idea of a simple web2py project was very attractive >> for these reasons. >> >> Are others out there creating PDFs from HTML with pyfpdf & html2pdf?? >> > --
[web2py] Re: KeyError on pyfpdf
Thanks everybody for your assistance; I'm rethinking my approach here. I'd thought generating a PDF from html would make formatting quick & easy as well as flexible to output to a webpage. But since the PDF for printing is the primary need, perhaps using PDF cells is the way to go. Thanks, Mariano, for your comments about nested tables. Akash, I might take you up on test HTML, or perhaps try your plugin. --
[web2py] NameError one way. 404 NOT FOUND the other...
Hello everyone, I'm working on emailing a message and I'm having some unexpected issues. Here is my code based on the web2py book: from gluon.tools import Mail from report_vars import * report_month = '7-2012' mail = Mail() mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = owner_email mail.settings.login = 'username:password' context = dict(person = comp_owner, company = company, report_month =report_month ) message = response.render('report_email.txt', context) mail.send(to = ['u...@domain.com'], subject = 'Re-Test Function from Web2py', message = message, bcc = tech_email, attachments = Mail.Attachment('{0}_{1}_report.pdf'.format( company_no_spaces, report_month)) ) When I run the code in WingIDE, I get NameError: name 'response' is not defined. If I run in the web2py Shell the NameError isn't raised, but instead I get: HTTP: 404 NOT FOUND [invalid view (report_mail.txt)] What gives? --
[web2py] Re: NameError one way. 404 NOT FOUND the other...
The path to report_email.txt is applications/saplogger/views/report_email.txt and the script I'm running is in applications/saplogger. Why I'm getting the 404 in the shell is baffling. Regarding context & environment, this report will be called from cron, and the email module will be imported into another controller to run. Will I be able to use templates for email text in this scenario? --
Re: [web2py] NameError one way. 404 NOT FOUND the other...
I've set web2py.py as debug file, but it's irritating to have the gui pop open all the time. Also, the TK server window refuses to close after I stop debugging, so after a time there's this proliferation of server windows. :-| I've just included the lines below in each file, which helps autocompletion. if 0: import db Any other WingIDE tips, let me know. On Saturday, August 18, 2012 3:32:49 PM UTC-4, Marin Pranjić wrote: > > You can run web2py in wingide if you set web2py.py as main debug file. > > > --
Re: [web2py] NameError one way. 404 NOT FOUND the other...
Thanks for your assistance everybody. For this particular issue, I suppose I'll just go with string formatting instead of templates; that'll work just as well for now until I understand web2py better. I do appreciate the responsiveness of the web2py mailing list. On Saturday, August 18, 2012 6:14:51 PM UTC-4, Marin Pranjić wrote: > > If you set run parameters to: > -a password > You will not get gui popup > > On Aug 18, 2012 9:56 PM, "thinkwell" > > wrote: > > I've set web2py.py as debug file, but it's irritating to have the gui pop > open all the time. Also, the TK server window refuses to close after I stop > debugging, so after a time there's this proliferation of server windows. > :-| I've just included the lines below in each file, which helps > autocompletion. > > if 0: > import db > > Any other WingIDE tips, let me know. > > > > On Saturday, August 18, 2012 3:32:49 PM UTC-4, Marin Pranjić wrote: > > > > You can run web2py in wing... > -- > > > > > --
[web2py] Deploying as RPM
Hello everyone, The report feature I've been toiling over is now finished - YEA! and ready to be to deployed to the /opt/www/web2py directory of the various machines. This is a task for puppet, which we use for config & package management as it handles RPMs and custom repos extremely well, so that was my plan for deploying this project. My thought was to make an RPM by running setup.py bdist_rpm, but even a fresh copy of web2py throws errors like: error: line 7: Unknown tag: of secure database-driven web-based applications, written and error: query of specfile build/bdist.linux-i686/rpm/SPECS/web2py.spec failed, can't parse error: Failed to execute: "rpm -q --qf '%{name}-%{version}-%{release}.src.rpm %{arch}/%{name}-%{version}-%{release}.%{arch}.rpm\\n' --specfile 'build/bdist.linux-i686/rpm/SPECS/web2py.spec'" Any suggestions? I'm green when it comes to making noarch RPMs with rpmbuild. This is a nonstandard use-case I suppose because it's getting deployed somewhat as an application on many servers. I'm open to advice. --
[web2py] Re: Deploying as RPM
For an update here. I was able to go with two very simple spec files since I use puppet for the cron jobs, apache config files, etc and I simply made two RPMs, one of stock web2py and one of my application with my app listing web2py as a dependency. What you're discussing, LightDot, sounds interesting. -- #-- # P A C K A G E I N F O #-- Name: sap2py Version: 1.0 Release: 1 Summary: Usage reports License: LGPLv3 Group:System Environment/Daemons BuildArch: noarch Source0: web2py-%{version}.tar.gz Buildroot: %{_tmppath}/web2py %description (description) #-- # B U I L D #-- %prep %setup -q %build #-- # I N S T A L L F I L E S #-- %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT mkdir -p -m 755 /opt/sap/www/ cp -r web2py /opt/sap/www/
[web2py] Migrating from CGI Script
I'm migrating a CGI script file to Web2py and I need to be able to receive form posts from another page because the CGI script received a form posted from a webserver that *cannot *be migrated to Web2py, unfortunately. Here's the form section: https://web2pyserver/reporter/blockpage/submit_site";> ... In the original CGI script, I got the form values with cgi.FieldStorage() site_submit_form = cgi.FieldStorage() site = cgi.escape(site_submit_form.getfirst('submit_url', 'Form error, no URL provided')) reason = cgi.escape(site_submit_form.getfirst('submit_reasons', 'Form error, no Reason given')) reasongiven = cgi.escape(site_submit_form.getfirst('submit_reasongiven', 'Form error, no polite reason given')) categories = cgi.escape(site_submit_form.getfirst('submit_categories', 'N/A' )) ip = cgi.escape(site_submit_form.getfirst('submit_ip', 'IP address not supplied')) So, I went to use the same code in a web2py controller: def submit_site(): import cgi siteform = cgi.FieldStorage() site = cgi.escape(siteform.getfirst('submit_url', 'Form error, no URL provided')) reason = cgi.escape(siteform.getfirst('submit_reasons', 'Form error, no Reason given')) reasongiven = cgi.escape(siteform.getfirst('submit_reasongiven', 'Form error, no polite reason given')) categories = cgi.escape(siteform.getfirst('submit_categories', 'N/A')) ip = cgi.escape(siteform.getfirst('submit_ip', 'IP address not supplied' )) return dict(site = site, reason = reason, reasongiven = reasongiven,categories = categories, ip = ip) But the default values are returned. How can web2py receive form input from a non-web2py web page? --
[web2py] Re: Migrating from CGI Script
Hah! There they are. I guess I need to do some more reading on the request attributes. Thanks Niphlod. On Thursday, September 20, 2012 8:03:20 PM UTC-4, Niphlod wrote: > > have you tried simply printing request.post_vars in submit_site() and see > what it does contain? > > --
[web2py] Re: Migrating from CGI Script
One more question - here's how I redid the controller because I need these values for hidden fields in the web2py form. def submit_site(): site = request.post_vars.submit_url ip = request.post_vars.submit_ip However, that only results in values of None. Why can't I use request.post_vars.submit_ip in the controller? I built the form successfully in a view, but I was hoping to build the form in the controller so I can use validation on some fields. How can access the form data inside the controller? --
[web2py] Re: Migrating from CGI Script
Yes, the form was generated outsite web2py and posted to the web2py controller "submit_site". My frustration is that in the controller, response.post_vars.submit_ip (and all form fields) have a value of None, but in the VIEW, they show correctly. WHY!? It can't be blamed out the external form because the request.post_vars values show up correctly in the VIEW. How can I access them in the controller? On Saturday, September 22, 2012 7:22:10 AM UTC-4, Niphlod wrote: > > I didn't get the problem. Wasn't the form generated "outside" web2py and > you wanted web2py only to catch the submitted part ? > > request.post_vars include every value (hidden or not) that the controller > receives. if in response.post_vars there's no "submit_ip", than it's > probably your "outside" form that has something not working. > > On Saturday, September 22, 2012 12:49:11 AM UTC+2, thinkwell wrote: >> >> One more question - here's how I redid the controller because I need >> these values for hidden fields in the web2py form. >> >> def submit_site(): >> site = request.post_vars.submit_url >> ip = request.post_vars.submit_ip >> >> However, that only results in values of None. Why can't I use >> request.post_vars.submit_ip in the controller? I built the form >> successfully in a view, but I was hoping to build the form in the >> controller so I can use validation on some fields. How can access the form >> data inside the controller? >> > --
[web2py] Re: Migrating from CGI Script
Apologies, apologies, Niphlod. Went to get the controller and saw might mistake. Classic PEBKAC situation. Thanks for your help. On Saturday, September 22, 2012 9:45:05 AM UTC-4, Niphlod wrote: > > Can you please post the complete controller ? I still don't understand > when you say "the view is ok, but request.post_vars is empty". If you built > a view in web2py, and it's tied to that controller, it's impossible that > the view can "see" something that the controller "isn't seeing". > > On Saturday, September 22, 2012 3:25:09 PM UTC+2, thinkwell wrote: >> >> Yes, the form was generated outsite web2py and posted to the web2py >> controller "submit_site". My frustration is that in the controller, >> response.post_vars.submit_ip (and all form fields) have a value of None, >> but in the VIEW, they show correctly. WHY!? >> >> It can't be blamed out the external form because the request.post_vars >> values show up correctly in the VIEW. How can I access them in the >> controller? >> >> On Saturday, September 22, 2012 7:22:10 AM UTC-4, Niphlod wrote: >>> >>> I didn't get the problem. Wasn't the form generated "outside" web2py and >>> you wanted web2py only to catch the submitted part ? >>> >>> request.post_vars include every value (hidden or not) that the >>> controller receives. if in response.post_vars there's no "submit_ip", than >>> it's probably your "outside" form that has something not working. >>> >>> On Saturday, September 22, 2012 12:49:11 AM UTC+2, thinkwell wrote: >>>> >>>> One more question - here's how I redid the controller because I need >>>> these values for hidden fields in the web2py form. >>>> >>>> def submit_site(): >>>> site = request.post_vars.submit_url >>>> ip = request.post_vars.submit_ip >>>> >>>> However, that only results in values of None. Why can't I use >>>> request.post_vars.submit_ip in the controller? I built the form >>>> successfully in a view, but I was hoping to build the form in the >>>> controller so I can use validation on some fields. How can access the form >>>> data inside the controller? >>>> >>> --
[web2py] Re: Download the book as local app?
Thanks, Massimo, this is great! On Wednesday, November 28, 2012 2:26:19 PM UTC-5, Massimo Di Pierro wrote: > > Yes. Install web2py and then install the book from > https://github.com/mdipierro/web2py-book > > it is just a web2py app. > > On Wednesday, 28 November 2012 05:45:39 UTC-6, Thomas Wimmer wrote: >> >> Is there a way to get the book as a local running app? >> The pdf way is not comfortable. >> As i dont have inet all the time this would be great. >> >> Thx >> > --