[web2py] Apache/mod_wsgi: Exposing individual web2py apps alongside other non-web2py services

2012-01-17 Thread Kevin Ivarsen
Hello, I have an Apache server with mod_wsgi, and I would like to host web2py alongside a variety of other things. For example: http://example.com/ hosts a PHP website. Might link to things like / about.php, /users/view.php, etc http://example.com/files a standard Apache listing of files in

[web2py] Book formatting error

2011-11-07 Thread Kevin Ivarsen
Hi folks, I spotted a couple formatting errors in the online book today. In chapter 7, under the section about the process and validate methods: 1. The formatting of the section header is a little strange - the words process and methods are smaller than the rest of the text. I assume that

[web2py] Re: Book formatting error

2011-11-07 Thread Kevin Ivarsen
On Nov 7, 2:57 pm, Anthony abasta...@gmail.com wrote: On Monday, November 7, 2011 4:34:26 PM UTC-5, Kevin Ivarsen wrote: FWIW - back in March I had been given access as a book editor through my gmail account, and I'd be happy to make these corrections, but it seems that I'm no longer able

[web2py] Building up a Query from nothing

2011-10-05 Thread Kevin Ivarsen
Hi everybody, I'm building a page that will search for rows in a database table based on optional URL parameters, or return all rows if no parameters are given. However, I'm having trouble finding a good way to build up the query without having an existing Query object to start with. Web2py

[web2py] Re: Building up a Query from nothing

2011-10-05 Thread Kevin Ivarsen
is to start with WHERE 1=1 (which should get optimized away by the SQL engine) and go from there. However, I couldn't find a way to make a Query that evaluated to the equivalent of 1=1. Cheers, Kevin On Oct 5, 1:39 pm, Kevin Ivarsen kivar...@gmail.com wrote: Hi everybody, I'm building a page

[web2py] Speeding up model execution for large models

2011-08-15 Thread Kevin Ivarsen
Hello, I'm using web2py with a relatively large legacy database. We have about 70 tables, and models/db.py is close to 1000 lines long. The problem I'm facing is that all of these Field() constructors and define_table() calls take about 150-200ms to execute, and this overhead occurs each time

[web2py] Re: Speeding up model execution for large models

2011-08-15 Thread Kevin Ivarsen
.) Anthony On Monday, August 15, 2011 6:30:06 PM UTC-4, Kevin Ivarsen wrote: Hello, I'm using web2py with a relatively large legacy database. We have about 70 tables, and models/db.py is close to 1000 lines long. The problem I'm facing is that all of these Field() constructors

[web2py] Re: Speeding up model execution for large models

2011-08-15 Thread Kevin Ivarsen
, August 15, 2011 8:18:30 PM UTC-4, Kevin Ivarsen wrote: Hi Anthony, Thanks for the quick response. I do use migrate=False already. I have not tried bytecode compiling the app, but earlier today I did a quick test: I wrapped the contents of my long db.py in an if False: block (causing

[web2py] Small toolbar bug in 1.96.3

2011-06-05 Thread Kevin Ivarsen
I downloaded the new 1.96 release today to try out. I spotted one small bug in generic.html - the toolbar is not shown if there is only one variable sent to the template. For example, given this controller: def test(): return dict(foo=1, bar=2) the toolbar shows up, but in: def test():

[web2py] Re: Small toolbar bug in 1.96.3

2011-06-05 Thread Kevin Ivarsen
I see - guess I hadn't noticed that behavior previously. For what it's worth, I found it to be surprising behavior today when I was testing it out. Kevin On Jun 5, 7:21 pm, Anthony abasta...@gmail.com wrote: On Sunday, June 5, 2011 6:42:20 PM UTC-4, Kevin Ivarsen wrote: I downloaded the new

[web2py] Re: bug in dal.py with multicolumn primary keys

2011-06-05 Thread Kevin Ivarsen
I ran into this awhile back, and the following fix worked for me. There might be a cleaner way to do it, but I'll offer it here: if hasattr(table,'_primarykey'): fields = [(field.name, value) for field, value in fields] fields = dict(fields) return dict( [ (k,fields[k]) for k in

[web2py] Re: bug in dal.py with multicolumn primary keys

2011-06-05 Thread Kevin Ivarsen
Oops - looks like the fix already made its way into 1.96.2 or 1.96.3. Great! Kevin On Jun 2, 2:34 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: will fix this tonight. On Jun 2, 1:00 pm, Loren McGinnis mcginnis.lo...@gmail.com wrote: I'm bumping this message, because the bug

[web2py] Possible regression selecting all from keyed tables

2011-06-05 Thread Kevin Ivarsen
Hi folks, At some point between 1.94 and 1.96, the DAL seems to have lost the (presumably supported) ability to select all entries from a keyed table. Consider the following test: db = DAL(None) db.define_table('mytable', Field('foo'), Field('bar'), primarykey=['foo'])

[web2py] Re: question from stackoverflow - DB transactions

2011-03-26 Thread Kevin Ivarsen
I'm not sure if carrying a transaction across multiple requests is possible, mainly because you can't be assured of getting the same connection to the database across requests. Looking through the code, it does appear to be possible to override the default commit behavior at the end of a

[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-26 Thread Kevin Ivarsen
Yes, this is a replacement. Trivial differences - just replaced MySQLdb references to gluon.contrib.pymysql, removed the comment up top about depending on MySQLdb, and added .. to the python path so that it can find gluon.contrib even if the web2py directory isn't in your system pythonpath.

[web2py] Re: Problem slicing dal Rows

2011-03-26 Thread Kevin Ivarsen
It appears that Python's __getslice__(self, a, b) overload has a surprising behavior. From http://docs.python.org/reference/datamodel.html#object.__getslice__: If negative indexes are used in the slice, the length of the sequence is added to that index. So when you evaluate rows[-20:], Python

[web2py] Re: DAL not working in shell

2011-03-25 Thread Kevin Ivarsen
Are you using the shell in the web browser, accessed via the Admin app, or the command line shell? There are currently some limitations in the browser-based shell that prevent things like database connections and open file handles from working. (Speaking more precisely, the online shell can

Re: [web2py] Re: book bugs

2011-03-25 Thread Kevin Ivarsen
As of right now the site is working for me. It may have been a temporary error. Kevin

[web2py] Re: DAL not working in shell

2011-03-25 Thread Kevin Ivarsen
I see that the web2py book describes tarting the shell in Chapter 2 under Starting Up: http://web2py.com/book/default/chapter/02#Starting-up However, I think Chapter 6 should clarify that you need to use the command line shell and not the browser-based shell for doing the interactive examples,

Re: [web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-25 Thread Kevin Ivarsen
modifications by Massimo Di Pierro, Ron McOuat, and Kevin Ivarsen ''' from optparse import OptionParser import re import sys sys.path.append(..) from gluon.contrib import pymysql # If true, write some diagnostic messages to stderr. Overridden by -v option SHOW_LOG_MESSAGES = False data_type_map = dict

[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-24 Thread Kevin Ivarsen
The extract_mysql_models.py script runs at the command line - either from cmd.exe in Windows or a Terminal window in Mac / Linux. Which operating system are you running? I can try to walk you through the steps. Also, I don't believe MySQLdb is included with web2py by default, but it is easy to

[web2py] Re: book bugs

2011-03-24 Thread Kevin Ivarsen
Good catch. I've made the edit. Cheers, Kevin

[web2py] Re: Alternative for annoying default javascript integer/double/decimal validtors

2011-03-23 Thread Kevin Ivarsen
I was about to suggest the same thing as Massimo. It's a trivial change to the regex; I think the following works: if (! this.value.match(/^[+-]?[0-9]*[.,]?[0-9]*$/)) { I like the simplicity of this method, even if it doesn't provide perfect client-side validation. Getting data about arbitrary

[web2py] Re: web2py Issues

2011-03-21 Thread Kevin Ivarsen
Why do you need to redirect back to the same view to display the error? The normal way of doing this is basically what you currently have: if there is an error in the form in the POST, immediately redisplay the form. I think the reason this is failing is because of the formkey technique used

[web2py] Re: web2py Issues

2011-03-21 Thread Kevin Ivarsen
One other thought - if web2py wasn't rejecting the form based on the formkey after redirect, I think you would actually be running into an infinite redirect loop here the way things are currently structured! Cheers, Kevin

[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-21 Thread Kevin Ivarsen
In web2py, you could import MySQLdb and make SQL queries directly, but you would lose out on a lot of the time-saving features that web2py offers, such as automatic form generation for database tables. Instead, you would typically use web2py's DAL (Database Abstraction Layer), which provides a

[web2py] Re: Validators for webservices?

2011-03-20 Thread Kevin Ivarsen
Massimo's method may be better -- I haven't personally experimented with the restful stuff yet. But you can still use SQLFORM or SQLFORM.factory with form.accepts() to run the validators. You just don't display the form anywhere if you don't need to. You also need to pass formname=None to

[web2py] Re: web2py Issues

2011-03-20 Thread Kevin Ivarsen
Hi Neveen, Without a bit more context I'm having trouble determining the problem. In principle you should be able to pass vars=request.vars to URL and have them show up in the redirected URL. For example: def func1(): if request.vars.value == hello: return you submitted hello

[web2py] Changelog version number 1.64.4 - 1.94.4

2011-03-20 Thread Kevin Ivarsen
Hi Massimo, The latest changelog entry shows 1.64.4 rather than 1.94.4. The same thing happened with 1.93... have you checked to see if your keyboard is upside-down? :-) Also, should there be a 1.94.5? Cheers, Kevin

[web2py] Re: web2py pycon 2011 tutorial video - second part

2011-03-20 Thread Kevin Ivarsen
As I understand it, there was an error and the second part unfortunately did not get recorded. Cheers, Kevin

[web2py] Converting legacy MySQL databases to web2py DAL

2011-03-20 Thread Kevin Ivarsen
it, improve it and continue. Created by Falko Krause, minor modifications by Massimo Di Pierro, Ron McOuat, and Kevin Ivarsen ''' from optparse import OptionParser import re import sys import MySQLdb # If true, write some diagnostic messages to stderr. Overridden by -v option SHOW_LOG_MESSAGES = False

[web2py] Re: layouts and =include

2011-03-20 Thread Kevin Ivarsen
Hi kyrussa, Try the following: layout.html: Begin main layout {{include}} End main layout layout_body.html: {{extend layout.html}} Begin layout body {{include}} End layout body mypage.html {{extend layout_body.html}} This is my content When you render mypage, you should get:

[web2py] Alternative for annoying default javascript integer/double/decimal validtors

2011-03-20 Thread Kevin Ivarsen
Hi all, I find the default javascript validators for integer, double, and decimal SQLFORM fields to be a little annoying. Consider the following surprising behaviors: - You can't navigate within the textbox using the keyboard. Pressing left, right, home, or end all result in the cursor

[web2py] Re: layouts and =include

2011-03-20 Thread Kevin Ivarsen
For another alternative which I think is more flexible, look at the {{block}} syntax. This lets you define multiple sections that can be overridden by an extending template. Example (untested): -- layout.html title{{block title}}My default title{{end}}/title script {{block scripts}} {{end}}

[web2py] Re: passing value to xml

2011-03-20 Thread Kevin Ivarsen
To expand on DenesL's reply, from your controller you would access these values in the following ways: For http://example.com/app/controller/service.xml/somevalue you would use: request.args(0) # returns somevalue, or None if nothing is provided For

[web2py] Re: web2py anti-propaganda video

2011-03-18 Thread Kevin Ivarsen
Another very useful video - thanks for putting these out! Clever use of decorators for template support. While we're on the topic of using web2py features outside of web2py: I have a package with library code, command line scripts, etc. -- let's call it mypackage Let's say I also have a

[web2py] Re: book bugs

2011-03-18 Thread Kevin Ivarsen
villas: tonight I went through the edits you made, and just about everything looks like it was correctly added to the book, including these two IS_DATE corrections. Thanks for your work on this! Kevin

[web2py] Re: video about new RESTful APIs

2011-03-17 Thread Kevin Ivarsen
I was confused by this as well. In the message above, I think simply add this to your model should read simply add this to your *controller* which of course makes much more sense. On Mar 17, 4:05 pm, David J. da...@styleflare.com wrote: For clarification; This gets put in the model code not

[web2py] Reverse order of changelog

2011-03-17 Thread Kevin Ivarsen
With today's new release I checked the changelog and noticed that the most recent entires are still at the bottom of the page. There was a thread a couple weeks ago where Nik Go submitted a reversed changelog, which I find more readable:

[web2py] kryten.py?

2011-03-16 Thread Kevin Ivarsen
Massimo: I've seen you use a tool called kryten.py to play back python sessions in some recent videos (e.g. http://vimeo.com/20760298). Google doesn't seem to know about it... is this something you wrote? Would you consider making it available? Thanks, Kevin

[web2py] Re: kryten.py?

2011-03-16 Thread Kevin Ivarsen
Nevermind, I see it was addressed in this thread: https://groups.google.com/d/topic/web2py/-w5YrSs67Mc/discussion Looking forward to seeing it released! Kevin

[web2py] Re: gae RFC

2011-03-16 Thread Kevin Ivarsen
I'm biased in that I don't do any GAE development, but even though it's only 7MB, it seems like a big jump relative to the size of the current code base. If you exclude the examples directory under applications, the web2py source tree comes in at about 5 megs. I really like the lightweight

[web2py] Re: Proposals for New Tagline

2011-03-15 Thread Kevin Ivarsen
So far I like Productivity by design. Although it depends on what the goals of a tagline should be. If you want to make the framework discoverable through search engines, it might be more important to include words like python / mvc / web framework. The web2py name by itself has the strength of

[web2py] Re: Small edits to web2py book

2011-03-15 Thread Kevin Ivarsen
project. I have already done thoseedits(and I hope correctly!).  If you post moreedits,  I and other editors are very pleased to make the changes. Best regards, David On Mar 14, 8:53 pm, Kevin Ivarsen kivar...@gmail.com wrote: Folks, I've been working my way through the web2py book

[web2py] Re: Proposals for New Tagline

2011-03-15 Thread Kevin Ivarsen
I don't know how to fit it in elegantly, but wanted to offer the idea of relating Python's batteries included mantra to web2py. That's one thing that struck me about web2py early on - it gives you a lot of nice features right off the bat. Kevin On Mar 15, 3:49 pm, mwolfe02

[web2py] Re: Can't connect to MySQL server on 'localhost'

2011-03-15 Thread Kevin Ivarsen
Miguel, MySQL can communicate over either TCP or a named pipe. It's possible that your MySQL server is only listening on the named pipe. I could imagine that the mysql command line client would connect successfully over this channel, but Python would try to connect to the TCP socket and fail.

[web2py] Video of Pycon web2py tutorial?

2011-03-14 Thread Kevin Ivarsen
Videos from some of the Pycon talks have been showing up on http://pycon.blip.tv. Does anyone know if videos or audio from the tutorial sessions (Massimo's web2py tutorial in particular) will eventually become available? Thanks, Kevin

[web2py] Re: Video of Pycon web2py tutorial?

2011-03-14 Thread Kevin Ivarsen
, Kevin Ivarsen wrote: Videos from some of the Pycon talks have been showing up on http://pycon.blip.tv. Does anyone know if videos or audio from the tutorial sessions (Massimo's web2py tutorial in particular) will eventually become available? Thanks, Kevin

[web2py] Small edits to web2py book

2011-03-14 Thread Kevin Ivarsen
Folks, I've been working my way through the web2py book. The content is outstanding - many thanks to everyone who is involved with this work! However, a few small typos popped out at me along the way. Starting around Chapter 5 I began recording these as I noticed them. (I haven't yet tried to go

[web2py] Re: Database fieldname convention

2011-03-07 Thread Kevin Ivarsen
Hello, I recently ran into this problem as well - field names with uppercase characters were ignored in SQLFORM inserts/updates. Luckily, I found that the behavior is fixed in the latest 1.93.2 release of web2py. Try upgrading and see if that solves the problem. Kevin On Mar 7, 4:15 am, StUStD

[web2py] Re: web2py recommended web hosting

2011-03-07 Thread Kevin Ivarsen
I recently had a good experience deploying a web2py website with a VPS on hostgator.com. During peak periods we had several dozen simultaneous users hitting the site, and everything remained speedy and responsive. We used MySQL and Apache with mod_wsgi to deploy. Kevin On Mar 7, 4:12 am,

[web2py] boolean type in MySQL: CHAR(1) vs TINYINT(1)

2011-03-05 Thread Kevin Ivarsen
I'm connecting to a legacy MySQL database (migrate=False) with a lot of fields declared BOOLEAN, and noticed that attempts to modify these fields with the DAL failed. The DAL issues a query like this: UPDATE sometable SET someflag='T' WHERE ... but this gets rejected by MySQL. Reading through

[web2py] Version typo in latest changelog

2011-03-05 Thread Kevin Ivarsen
The latest changelog entry has a small typo: the version is listed as 1.63.1-2, but I believe it should be 1.93.1-2. http://web2py.com/examples/default/changelog Hopefully this is the appropriate place to report that sort of thing. Cheers, Kevin