[web2py] Ajax and table rows.
Hi all, I'm trying to have a ajax callback function whenever I click a certain row. I'd like that row to return the id of the record the row represents. I'm at loss as to the middle argument for the ajax function. I checked the function in the controller gets called but the argument is wrong. I created a simple example so I could try and traceback the problem but I think I'm doing something wrong. This is my view: {{extend 'layout.html'}} table tr class=row id=1 onclick=ajax('echo', ['id'], ':eval') tdHello/tdtdWorld/td /tr tr class=row id=2 onclick=ajax('echo', ['id'], ':eval') tdRow 2/tdtdNew world/td /tr /table div id=target/div And the following is my controller: def one(): return dict() def echo(): return jQuery('#target').html(%s); % request.vars.id What am I doing wrong?
[web2py] Re: Django urls to web2py
When routes.py is the pattern based system, it works locally, but uploading to the GAE cannot find the icons, stylesheets, etc. On the server I see the massage: select routing parameters: BASE
[web2py] Re: Authorization decorators always generate db queries
Checked it just now with Version 1.99.3 (2011-11-20 21:10:53) dev Everything now works ok, no more unnecessary database queries from auth decorators. Thanks On Nov 19, 9:37 am, Ids idsvandermo...@gmail.com wrote: Ok. Will try it monday when I get back to work and have access to a computer with web2py.
[web2py] problem with scheduler
Hi, I'm using web2py version 1.99.2 with the new scheduler. I have a scheduled function that is run once a day at the same time with this parameters: Start Time: 2011-11-10 01:30:00 Next Run Time: 2011-11-22 01:30:00 Stop Time:2020-01-01 00:00:00 Repeats:0 Period:86400seconds Timeout:3600seconds Times Run:... Last Run Time:... it happens that when something wrong happens (like crash or application is killed by kernel) when I restart the application the next run time is changed in the time part and the function is not performed at the same hour I planned... so I have to change by hand every time that it happens. Is it a strange behavior? thanks Manuele
Re: [web2py] Re: Shortcut for fetching a row
There is this important rule that all programers must respect: write code YOU can understand. Khalil
[web2py] Problem in deploying with cherokee+uwsgi
Hi I just downloaded web2py package on a ubuntu server and i set up with cherokee + uwsgi. The uwsgi connection string is /usr/local/bin/uwsgi -s 127.0.0.1:43658 -M -p 8 -z 15 -L -l 128 /var/www/argomenti.in/web2py/wsgihandler.py --pythonpath /var/www/argomenti.in/web2py When i try to access i receive: Internal error Ticket issued: unrecoverable I've looked at this group and i found some topics about this issue but all solved with a chmod. The web2py directory is writable by the www-data user in my case, i did a chmod 777 to all files just to be sure too. Any suggestion?
[web2py] autocomplete type than tab but not autocompleted
Hi! Is it OK that if I type something in autocomplete field then TAB to the suggestions then hit ENTER but nothing is changed in the field? It is not completed. Tnx.
[web2py] Re: Memory leak with scheduler.py and MySQL
Is that fixed already?
Re: [web2py] problem with scheduler
I think repeats=0 is not working, try with another value like 999, 99 2011/11/21 Manuele manuele.pese...@gmail.com ** Hi, I'm using web2py version 1.99.2 with the new scheduler. I have a scheduled function that is run once a day at the same time with this parameters: Start Time: 2011-11-10 01:30:00 Next Run Time: 2011-11-22 01:30:00 Stop Time:2020-01-01 00:00:00 Repeats:0 Period:86400seconds Timeout:3600seconds Times Run:... Last Run Time:... it happens that when something wrong happens (like crash or application is killed by kernel) when I restart the application the next run time is changed in the time part and the function is not performed at the same hour I planned... so I have to change by hand every time that it happens. Is it a strange behavior? thanks Manuele -- http://martin.tecnodoc.com.ar
[web2py] Re: SQLForm.grid - How do I use it properly?
Hey All, I have added a slice for SQLForm.grid in web2py slices. I hope it is of help to everyone starting up with it. Slice#148 (May be it needs proper formatting) http://www.web2pyslices.com/slices/take_slice/148 Villas, I have added the SQLForm.grid syntax derived from your code thread provided above. :) Corrections are welcome. Thanks all for your valuable support. Web2py is Simply The Most Amazingly Powerful and Awesome framework... Thanks and Regards, Rahul (www.flockbird.com - web2py powered) # On Nov 21, 1:06 am, villas villa...@gmail.com wrote: There is a shortage of documentation on the grid, but I've noticed that I often glean a lot from the code (even when I don't understand it all) -- I guess that's one of the beauties of opensource. So, in addition to any other resources you find, take a glance at this... http://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#1376
Re: [web2py] Re: socket.io Web2Py
Thanks for sharing Information. I have used Tornado, Gevent and socket.io and its working fine. Best Regards Shiv On Fri, Nov 18, 2011 at 9:01 AM, Matt Gorecki m...@goelephant.com wrote: I am able to send socket.io events with this code: https://gist.github.com/1375505 It's based off an answer I found on Stack Overflowhttp://stackoverflow.com/questions/6692908/formatting-messages-to-send-to-socket-io-node-js-server-from-python-client . With the code in that gist, you should be able to send one event to your node.js server. If you have a long running Python script, you'll need to send heartbeat packets (with sio.heartbeat() ) every 15 seconds or you'll lose your connection to node.js. This particular example is from a photobooth application I'm working on called PhotoPops. http://myphotopops.com There isn't much there right now as I just used it in public for the first time last Friday at a local event. I think I'll make that Github repo public when I feel a little more confident about it. Matt Gorecki -- Thanks Regards Shiv
[web2py] Register user programmatic way
Hi, I want to import the user details from XL file and register in the user_auth table. If you can share info on how to register the users programmatic way, it will be of great help. Thanks Regards Shiv
[web2py] Re: Problem in deploying with cherokee+uwsgi
Hi Vincenzo, The folder to which you need write permission is /path/to/web2py/applications/yourapplication/errors Note that uwsgi may run as a different user to Cherokee. I use Cherokee with Web2Py keep my installation notes here: http://eden.sahanafoundation.org/wiki/InstallationGuidelinesCherokee Best Wishes, Fran.
[web2py] Re: SQLForm.grid - How do I use it properly?
Massimo, I tried the expressions, but it did not seem to work. Could you consider providing an example so we could get that working? I would be delighted if VirtualFields could be displayed. Do you think that this would be possible? Regards, David
[web2py] Re: SQLForm.grid - How do I use it properly?
Rahul, it is a very good thing that you are trying to pull all this info together. I am sure it will help the documentation effort. Thanks.
Re: [web2py] Register user programmatic way
Hi Bruno, Thanks a lot that was really helpful and solved mine and Shiv problem Thanks, Viren On Mon, Nov 21, 2011 at 5:35 PM, Bruno Rocha rochacbr...@gmail.com wrote: *Create this function in some model* * * *def new_user(first_name, last_name, email, passw): **users = db(db.auth_user.email==email).select() **if users: **return users[0].id **else: **my_crypt = CRYPT(key=auth.settings.hmac_key) **crypt_pass = my_crypt(passw)[0] **id_user= db.auth_user.insert( ** first_name=first_name, ** last_name=last_name, ** email = email, ** password = crypt_pass ** ) **return id_user* Now create user with this: *iduser = new_user('Chris','Mills','ch...@nobody.com','somepasswordhere')* On Mon, Nov 21, 2011 at 8:48 AM, Shiv shiv.veerashe...@gmail.com wrote: Hi, I want to import the user details from XL file and register in the user_auth table. If you can share info on how to register the users programmatic way, it will be of great help. Thanks Regards Shiv -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] ValueError: need more than 1 value to unpack
Hi All, Is there a solution for below traceback I posted (I am on 1.99.2, win7, firefox,ie9). Tried search for a solution in below thread .. no help ... http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f5590e/59d060e8ded6eae0 Traceback 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22. Traceback (most recent call last): File D:\WEB2PY\web2py\gluon \restricted.py, line 194, in restrictedexec ccode in environment File D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambdaself._caller = lambda f: f() File D:/WEB2PY/ web2py/applications/Link_IT/controllers/default.py, line 58, in indexreturn dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in selectreturn self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY \web2py\gluon\dal.py, line 1233, in selectrows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in executereturn self.log_execute(*a, **b) File D:\WEB2PY\web2py \gluon\dal.py, line 1304, in log_executeret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestampdatepart, timepart = val.split( )ValueError: need more than 1 value to unpack here is my controller (default.py) -- def index(): return dict( list_updates=db(db.updates).select()) here is the view (index.html) - {{right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=list_updates}} my model (db.py)- db.define_table('updates', Field('description', 'text'), Field('updated_on','date', readable=False, writable=False, default=now), Field('posted_by', readable=False, writable=False, length=512) ) Please help .. what could be the issue.. I even cleared the db. the issue still persists. Regards, Rahul
Re: [web2py] Ajax and table rows.
The ['id'] middle arg of the ajax function works only with forms, and it looks for the name attribute in form inputs for check its val(). your code needs to be something like this: {{extend 'layout.html'}} *script $(document).ready(function () { $('.row').click(funtion(){* * ** ajax('echo?id=' + $(this).attr('id'), [], ':eval')** * * }); }); /script* table tr class=row id=1 tdHello/tdtdWorld/td /tr tr class=row id=2 tdRow 2/tdtdNew world/td /tr /table div id=target/div And the following is my controller: def one(): return dict() def echo(): return jQuery('#target').html(%s); % request.vars.id -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] ValueError: need more than 1 value to unpack
On Mon, 2011-11-21 at 04:48 -0800, Rahul wrote: my model (db.py)- db.define_table('updates', Field('description', 'text'), Field('updated_on','date', readable=False, writable=False, default=now), Field('posted_by', readable=False, writable=False, length=512) ) What's inside now? It must be a datetime.datetime() or a %Y-%m-%d %H:%M:%S date, not a unix timestamp. Usually request.now fits, if you need to store current date/time. If you want to convert a timestamp into datetime object:: datetime.datetime.fromtimestamp(1321882700) If you want to convert a date in a given format into a datetime: datetime.datetime.strptime(string, format) (Where format is the same accepted by ``strftime()``). By the way: why does sqlite tries to parse the date with fixed format instead of using ``datetime.datetime.strptime()``? Somebody can explain that? -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog: http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica - http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc Description: This is a digitally signed message part
[web2py] Re: web2py on windows 7
Ok, I'll now follow the web2py book, something I should have done to start with :-/ I'm trying to install web2py as a windows 7 service and used an options.py file as described in the book. But it fails to install, it says (in dutch: Error installing service: Access denied. (5)) web2pyweb2py.exe -W install web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.2 (2011-09-26 06:55:33) stable Database drivers available: SQLite3, pymysql Starting hardcron... Installing service web2py Error installing service: Toegang geweigerd. (5) Any advise ? Regards, Stas On Sun, Nov 20, 2011 at 9:14 PM, stas z stas.zytkiew...@gmail.com wrote: Hello, I'm working on a app that also runs on windows 7 and which uses web2py to display various dbase data in html views. The app is build with py2exe and packs the web2py binary for windows and starts the web2py_no_console.exe in a seperate thread. This works fine when one starts the app from the users home directory but web2py fails silently to start when the app, and web2py, is installed in Program files. I suspect that it fails as web2py cannot write stuff inside Program files. Does anyone knows a solution for this problem. Regards, Stas Zytkiewicz -- Free-source educational programs for schools http://www.schoolsplay.org and http://wiki.laptop.org/go/Schoolsplay http://gvr.sf.net and http://wiki.laptop.org/go/Guido_van_Robot
Re: [web2py] ValueError: need more than 1 value to unpack
Rahul, this is a str.split() error and it happens when there are less pieces than str.split() expects. An example: fullname = 'John Smith' (first_name, last_name) = fullname.split( ) print 'first:', first_name, '- last:', last_name John - Smith fullname = 'John' (first_name, last_name) = fullname.split( ) Traceback (most recent call last): File pyshell#6, line 1, in module (first_name, last_name) = fullname.split( ) ValueError: need more than 1 value to unpack There weren't 2 parts in fullname. That's why the error occured. Back to your problem, the same is happening with your updated_on field. I'd make default=request.now on it. BTW, try organize the traceback. It helps people helping you. -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:48 AM, Rahul rahul.dhak...@gmail.com wrote: Hi All, Is there a solution for below traceback I posted (I am on 1.99.2, win7, firefox,ie9). Tried search for a solution in below thread .. no help ... http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f5590e/59d060e8ded6eae0 Traceback 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22. Traceback (most recent call last): File D:\WEB2PY\web2py\gluon \restricted.py, line 194, in restricted exec ccode in environment File D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py, line 276, in module File D:\WEB2PY\web2py\gluon\globals.py, line 149, in lambda self._caller = lambda f: f() File D:/WEB2PY/ web2py/applications/Link_IT/controllers/default.py, line 58, in index return dict(form=form, list_updates=db(db.updates).select()) File D:\WEB2PY\web2py\gluon\dal.py, line 5697, in select return self.db._adapter.select(self.query,fields,attributes) File D:\WEB2PY \web2py\gluon\dal.py, line 1233, in select rows = response(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1223, in response self.execute(sql) File D:\WEB2PY\web2py\gluon\dal.py, line 1309, in execute return self.log_execute(*a, **b) File D:\WEB2PY\web2py \gluon\dal.py, line 1304, in log_execute ret = self.cursor.execute(*a,**b) File C:\Python27\lib\sqlite3\dbapi2.py, line 66, in convert_timestamp datepart, timepart = val.split( )ValueError: need more than 1 value to unpack here is my controller (default.py) -- def index(): return dict( list_updates=db(db.updates).select()) here is the view (index.html) - {{right_sidebar_enabled=False}} {{extend 'layout.html'}} {{=list_updates}} my model (db.py)- db.define_table('updates', Field('description', 'text'), Field('updated_on','date', readable=False, writable=False, default=now), Field('posted_by', readable=False, writable=False, length=512) ) Please help .. what could be the issue.. I even cleared the db. the issue still persists. Regards, Rahul
[web2py] Re: Authorization decorators always generate db queries
Thanks to Anthony, this is an important fix that will speed up a lot complex apps. On Nov 21, 3:03 am, Ids idsvandermo...@gmail.com wrote: Checked it just now with Version 1.99.3 (2011-11-20 21:10:53) dev Everything now works ok, no more unnecessary database queries from auth decorators. Thanks On Nov 19, 9:37 am, Ids idsvandermo...@gmail.com wrote: Ok. Will try it monday when I get back to work and have access to a computer with web2py.
[web2py] Re: Memory leak with scheduler.py and MySQL
yes. in gluon/dal.py TIMINGSSIZE = 100 That means we only store up to 100 queries. You will see the memory grow bot only up to a point. You can also decrease the number: import gluon.dal gluon.dal.TIMINGSIZE = 20 On Nov 21, 4:10 am, szimszon szims...@gmail.com wrote: Is that fixed already?
[web2py] field related to auth.user.id problem when user not logged in
Two questions: I have the following scheme: db.define_table('table', Field('title'), Field('author_id', default=auth.user_id,readable=False, writable=False), ... ) db.define_table('videos', Field('author_id',default=auth.user_id,readable=False, writable=False), Field('table',db.table) ) and i want the videos.table field to take values only from the entries that the same user has entered or Null db.videos.table.requires = IS_IN_DB(db(db.table.author_id==auth.user.id), db.table.id, '% (title)s') I get an error NoneType' object has no attribute 'id' , because the user initially is not logged in so there is no auth.user.id How can i solve this? Second question, if the user had entered a lot of entries which is the best way to display the dropdown list of tables??? Thodoris
[web2py] Re: Ajax and table rows.
Thanks, you guys rock community support.
Re: [web2py] field related to auth.user.id problem when user not logged in
On Mon, Nov 21, 2011 at 12:41 PM, thodoris pasxi...@gmail.com wrote: Two questions: and i want the videos.table field to take values only from the entries that the same user has entered or Null NoneType' object has no attribute 'id' , because the user initially is not logged in so there is no auth.user.id How can i solve this? if auth.user: db.videos.table.requires = IS_IN_DB(db(db.table.author_id==auth.user.id), db.table.id, '% (title)s') else: db.videos.table.requires = IS_IN_DB(db(db.table.author_id==None), db.table.id, '% (title)s') But, according to your define_table()'s, these tables can only be managed (insert or update) with a logged user, or default contents will raise an excpetion because there's no logged user. -- Vinicius Assef.
[web2py] Re: web2py on windows 7
On 21 nov, 07:45, Tom Campbell tomcampb...@gmail.com wrote: I would avoid this by putting Python on the path, then web2py somewhere outside of Program Files, which I would claim is bad form anyway. Like a web2py directory off root, maybe? I can post a little tutorial for a manual Windows install of web2py illustrating this if you like. Please do, I don't know why its given these problems on Windows. Also starting web2py as a service by following the instructions from the web2py manual fails. (See my other reply) Thanks, Stas
[web2py] Re: field related to auth.user.id problem when user not logged in
db.videos.table.requires = IS_IN_DB(db(db.table.author_id==auth.user.id), db.table.id, '%(title)s') Maybe db(db.table.author_id == (auth.user and auth.user.id)) That will return no records when there is no auth.user. Anthony
[web2py] Re: Can web2py do shared IP hosting
Dear Massimo, Thank you for your quick response. I heard your interview on FLOSS Weekly and that's how I discovered web2py. I guess I misread something. I thought I could download web2py and install it with a built-in web server ... Rocket I think was the name. (I haven't researched Rocket yet.) Are you saying that these features are addressed as part of the server environment and not a defined feature of web2py? (I've always had an admin doing this kind of detail work so I've never had to understand it in detail.) I should have been more clear about my computer environment ... my assumption was that I would be running web2py on my own dedicated server ... which is what I do now with my projects. My intention is to replace the server/framework I have now with one based on web2py but I want to be sure it has all the features I will need to grow. For example, I want to design all the new web sites to be mobile compatible using responsive page design, which scales smoothly for desktop, tablet and smart-phone screen sizes. Here's a page with many examples of this in production now: http://designmodo.com/responsive-design-examples/ Warmest regards, Rob:-]
Re: [web2py] field related to auth.user.id problem when user not logged in
But, according to your define_table()'s, these tables can only be managed (insert or update) with a logged user, or default contents will raise an excpetion because there's no logged user. The defaults won't raise an exception (as long as auth is defined prior to the table definitions), because auth.user_id simply returns None when the user is not logged in (i.e., it is not undefined). The same is true for auth.user -- it returns None when there is no logged in user (though auth.user.id will raise an exception because if auth.user is None, obviously it has no 'id' attribute). See very end of this section: http://web2py.com/book/default/chapter/08#Authentication Anthony
Re: [web2py] Ajax and table rows.
Ok, now that this works seems I'm still in trouble. The page I'm loading is one that has a table that I'm trying to make clickable and a form to enter more data. Here is the controller: @auth.requires_login() def budget(): db.expense.parent_table.default = request.args(0) db.expense.category.requires = IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','categories.name') form = crud.create(db.expense) expenses = db(db.expense.parent_table==request.args(0)).select() return dict(user=auth.user.first_name, expenses=expenses, form=form) def edit_expense(): return repr(request.vars.id) My view: table tr thDate and Time/th thTitle/th thCategory/th thAmount/th thSource/th /tr {{ for expense in expenses: }} tr class=expenses id={{=expense.id}} onmouseover=jQuery(this).attr(style.backgroundColor='lightgrey') onmouseout=jQuery(this).attr(style.backgroundColor='white') td{{=expense.datetime}}/td td{{=expense.title}}/td td{{=expense.category.name}}/td td{{=expense.amount}} {{=expense.denomination}}/td td{{=expense.source}}/td /tr {{pass}} /table hr / {{=form}} script $(document).ready(function () { $('.expenses').click(function(){ ajax('edit_expense?id=' + $(this).attr('id'), [], '#target') }); }); /script div id=target/div I added the AJAX script to have it return to edit_expense the id of the row that was clicked but I get an error about the crud.create line in my controller. Thanks again for your help. Tsvi
Re: [web2py] Can web2py do shared IP hosting
Hi Phyo, Thanks for your response. My current environment is a dedicated server machine with a single web server which servers multiple web separate sites on sub-domains and dedicated IP addresses. The configuration at this level has always been handled by an administrator so I know less about it than I should. I'm trying to figure out if web2py can replace my existing system and provide all the features and flexibility that I will need going forward. Thanks again for your help. Peace, Rob:-]
[web2py] Re: field related to auth.user.id problem when user not logged in
Thanx for the help guys, what i did finally is db.videos.table.requires = IS_EMPTY_OR (IS_IN_DB(db(db.table.author_id==auth.user_id), db.table.id, '% (title)s')) What about displaying a BIG dropdown list of tables entries? Any help here ??? On Nov 21, 4:09 pm, Anthony abasta...@gmail.com wrote: But, according to your define_table()'s, these tables can only be managed (insert or update) with a logged user, or default contents will raise an excpetion because there's no logged user. The defaults won't raise an exception (as long as auth is defined prior to the table definitions), because auth.user_id simply returns None when the user is not logged in (i.e., it is not undefined). The same is true for auth.user -- it returns None when there is no logged in user (though auth.user.id will raise an exception because if auth.user is None, obviously it has no 'id' attribute). See very end of this section:http://web2py.com/book/default/chapter/08#Authentication Anthony
[web2py] Re: Can web2py do shared IP hosting
On Monday, November 21, 2011 10:05:02 AM UTC-5, Robert Shaver wrote: I guess I misread something. I thought I could download web2py and install it with a built-in web server ... Rocket I think was the name. (I haven't researched Rocket yet.) Are you saying that these features are addressed as part of the server environment and not a defined feature of web2py? (I've always had an admin doing this kind of detail work so I've never had to understand it in detail.) Rocket is primarily intended for development. You can use it in production as well, though for production it is generally recommended you use a more full-featured web server, like Apache. I should have been more clear about my computer environment ... my assumption was that I would be running web2py on my own dedicated server ... which is what I do now with my projects. My intention is to replace the server/framework I have now with one based on web2py but I want to be sure it has all the features I will need to grow. If you've got full control over your server, you might consider using one of web2py's setup scripts to set up Apache or nginx (http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-ubuntu.sh, http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh). For example, I want to design all the new web sites to be mobile compatible using responsive page design, which scales smoothly for desktop, tablet and smart-phone screen sizes. Here's a page with many examples of this in production now: http://designmodo.com/responsive-design-examples/ The responsive design stuff is mostly handled client side via CSS media queries and Javascript, so that will all work fine with web2py. In fact, the next web2py release (due any day now) will include a new responsive 'welcome' scaffolding app based on Skeleton (http://www.getskeleton.com). Here's an initial demo: http://tests.web2py.com/welcome/ (though a few tweaks have been made to the final version). web2py also includes some server-side code to enable detection of mobile clients and delivery of alternative output. request.user_agent() gives you the user agent details, and request.user_agent().is_mobile tells you if it's a mobile client. Also, adding the @mobilize decorator to a function changes its view file from function.html to function.mobile.html when the request is from a mobile client. Anthony
Re: [web2py] Can web2py do shared IP hosting
Hi Rob, what webserver are you running right now? Kenneth Hi Phyo, Thanks for your response. My current environment is a dedicated server machine with a single web server which servers multiple web separate sites on sub-domains and dedicated IP addresses. The configuration at this level has always been handled by an administrator so I know less about it than I should. I'm trying to figure out if web2py can replace my existing system and provide all the features and flexibility that I will need going forward. Thanks again for your help. Peace, Rob:-]
Re: [web2py] field related to auth.user.id problem when user not logged in
Thanks, Anthony. On Mon, Nov 21, 2011 at 1:09 PM, Anthony abasta...@gmail.com wrote: But, according to your define_table()'s, these tables can only be managed (insert or update) with a logged user, or default contents will raise an excpetion because there's no logged user. The defaults won't raise an exception (as long as auth is defined prior to the table definitions), because auth.user_id simply returns None when the user is not logged in (i.e., it is not undefined). The same is true for auth.user -- it returns None when there is no logged in user (though auth.user.id will raise an exception because if auth.user is None, obviously it has no 'id' attribute). See very end of this section: http://web2py.com/book/default/chapter/08#Authentication Anthony
[web2py] Re: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol on Upgraded v1.99.1
On Nov 13, 10:54 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I think this should be be fixed in both stable and trunk. I am still seeing this error with 1.99.2, should it have been fixed there? On Nov 12, 10:38 am, Tito Garrido titogarr...@gmail.com wrote: Is it already fixed? On Thu, Sep 22, 2011 at 9:04 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Dirk and I ran some tests. 1.99.1 broke rocket with SSL. Do not upgrade if you use rocket with SSL. We will have a fix asap. Massimo On Sep 22, 4:50 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you show me what triggers it? On Sep 22, 4:39 pm, Dirk dirkl...@gmail.com wrote: Upgraded a test environment with the live update, and am seeing the following with embedded server and SSL enabled via CLI: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol TIA, Dirk -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Re: Found a bug: XMLRPC with basic authorization fails
has this patch made it into the codebase? I'm looking at my checkout of 1.99.2 and it doesn't seem to be there (and trunk as well, from the looks of it). Of course, it may have been written differently, I was only checking for the exact strings
[web2py] Re: gevent helper script integration with web2py
I ended up creating a virtualenv with the needed libraries within the modules folder and using the virtualenv python binary to execute the script within the web2py environment. I feel it's a bit hackish, but I'll clean it up in the future. What I do find interesting is that the script is actually executing in the models folder for things like import lookups and for opening files. The db (the DAL connection to the database) is only available as a global in the main() function of my script, I have to explicitly pass it around otherwise. Is this the way it works (both executing within the models folder, and the scope of the globals)? On Nov 20, 3:17 pm, Dave oeyonl...@gmail.com wrote: I have a script that uses gevent which monkey patches the standard library to use green threads (cooperative coroutines). I'd like this to run as a background task using techniques described in homemade task queues or by using web2py's scheduler. Fundamentally my script only needs access to the DAL to manage jobs and perform manual file uploads (http://web2py.com/book/default/chapter/06#Manual-Uploads). Is there a good way to do this without having the monkey patched standard library (socket module, sll module, etc.) from impacting web2py? Thanks, Dave
Re: [web2py] Register user programmatic way
How about including this function in Auth? -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:43 AM, VIREN PATEL viren...@gmail.com wrote: Hi Bruno, Thanks a lot that was really helpful and solved mine and Shiv problem Thanks, Viren On Mon, Nov 21, 2011 at 5:35 PM, Bruno Rocha rochacbr...@gmail.com wrote: Create this function in some model def new_user(first_name, last_name, email, passw): users = db(db.auth_user.email==email).select() if users: return users[0].id else: my_crypt = CRYPT(key=auth.settings.hmac_key) crypt_pass = my_crypt(passw)[0] id_user= db.auth_user.insert( first_name=first_name, last_name=last_name, email = email, password = crypt_pass ) return id_user Now create user with this: iduser = new_user('Chris','Mills','ch...@nobody.com','somepasswordhere') On Mon, Nov 21, 2011 at 8:48 AM, Shiv shiv.veerashe...@gmail.com wrote: Hi, I want to import the user details from XL file and register in the user_auth table. If you can share info on how to register the users programmatic way, it will be of great help. Thanks Regards Shiv -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: field related to auth.user.id problem when user not logged in
On Monday, November 21, 2011 10:38:27 AM UTC-5, thodoris wrote: Thanx for the help guys, what i did finally is db.videos.table.requires = IS_EMPTY_OR (IS_IN_DB(db(db.table.author_id==auth.user_id), db.table.id, '% (title)s')) What about displaying a BIG dropdown list of tables entries? Any help here ??? What do you mean? Do you want a dropdown when there is no auth user, or only when there is? Does the IS_EMPTY_OR cause the dropdown to go away (normally IS_IN_DB automatically produces a dropdown)?
[web2py] update_record() for DB's without an auto_increment field
Greetings! I seem to be having a problem using DAL with legacy databases, namely those without an existing AUTO_INCREMENT field: db.define_table('manufactured_by', Field('product', 'string'), Field('brand', 'string'), primarykey=['product', 'brand']) With a similar setup the update() function works well: db.manufactured_by.insert(product=Perfume, brand=Chanel) rset = db(db.manufactured_by.product==Perfume) rset.update(brand=Dior) Whereas the update_record() function throws an error -- KeyError: 'update_record': row = rset.select().first() row.update_record(brand=Fendi) Same for update_or_insert() which relies on calling update_record(). Tried with SQLite and MySQL backends. Is there any way to make those work? Many thanks! Dmitry from gluon.dal import DAL, Field db = DAL('sqlite://sqlite.db') db.define_table('manufactured_by', Field('product','string'), Field('brand', 'string'), primarykey=['product', 'brand']) db.manufactured_by.insert(product=Perfume, brand=Chanel) rset = db(db.manufactured_by.product==Perfume) row = rset.select().first() print product =, row.product, , brand =, row.brand # This one works fine rset.update(brand=Dior) row = rset.select().first() print product =, row.product, , brand =, row.brand # This throws an error -- KeyError: 'update_record'. row.update_record(brand=Fendi) print product =, row.product, , brand =, row.brand # Same error for update_or_insert(), which calls update_record()
[web2py] Re: Django urls to web2py
Is the problem on GAE only? Do you also get the problem when running with dev_appserver?
[web2py] import_from_csv_file problem with reference fields with 1.99.2?
In my application which is hosted on GAE I have backup/restore functions which use export_to_csv_file/import_from_csv_file. While this is not a practical backup/restore for GAE (restore would take far too long and timeout, so for this purpose I use GAE bulk loader tool), I have used it in the past to backup from GAE and restore to test environment. This used to work fine. However, with 1.99.2, reference fields in all the tables are left with the GAE values rather than being replaced with the new ID's of the corresponding records. Both export and import were done by 1.99.2 and the import otherwise works - there is no reported failure. Is this related to issues 351 or 513 in code.google.com/p/web2py?
[web2py] Re: Django urls to web2py
When using trunk and to work on GAE I needed to rename my app and all internal references to it to lowercase.
[web2py] Re: SQLForm.grid - How do I use it properly?
On Monday, November 21, 2011 7:06:25 AM UTC-5, villas wrote: Massimo, I tried the expressions, but it did not seem to work. Could you consider providing an example so we could get that working? I would be delighted if VirtualFields could be displayed. Do you think that this would be possible? The 'links' argument can be a list of lambdas that take the 'row' object as an argument, or a list of dictionaries with keys 'header' (for the column header) and 'body' for the lambda function (links that are dictionaries get their own column; otherwise, they get added to the last column with the view/edit/delete buttons). Perhaps you could use this to display virtual fields associated with the row. Something like: links=[dict(header='myfield', body=lambda row: row.myfield)] Haven't tried it, though, so not sure it will work. Anthony
[web2py] DAL's virtual fields
In the Official web2py Book I read about DAL's Virtual Fields that: ...each method of the class that takes a single argument (self) is a new virtual field. It seems however that any function of the class is treated as a new field and called to calculate its value. As an example I added a support function to the class: class MyVirtualFields(object): def total_price(self): return self.support_function(self.item.unit_price, self.item.quantity) def support_function(self, price, quantity): return price*quantity And on row retrieval I receive the following exception: TypeError: support_function() takes exactly 3 arguments (1 given) As a workaround I can add default values for arguments and additional checks in the support function. But I wonder what is the proper way to add a non-field function to the class? Thank you! Dmitry from gluon.dal import DAL, Field db = DAL('sqlite://sqlite.db') db.define_table('item', Field('unit_price','double'), Field('quantity','integer')) class MyVirtualFields(object): def total_price(self): return self.support_function(self.item.unit_price, self.item.quantity) def support_function(self, price, quantity): return price*quantity db.item.virtualfields.append(MyVirtualFields()) db.item.insert(unit_price=10, quantity=50) rows = db(db.item).select()
[web2py] Re: update_record() for DB's without an auto_increment field
That is one the restrictions when working with keyed tables. Here are the original notes (see #5): 1) primarykey is a list of the field names that make up the primary key 2) all primarykey fields will have NOT NULL set even if not specified 3) references are to other keyed tables only 4) references must use tablename.fieldname format, as shown above 5) update_record function is not available 6) web2py rev.1354 (or higher) has appadmin support for keyed tables. It should be in the book but I don't see it... On Nov 21, 12:28 pm, Dmitry Vukolov dmitry.vuko...@gmail.com wrote: Greetings! I seem to be having a problem using DAL with legacy databases, namely those without an existing AUTO_INCREMENT field: db.define_table('manufactured_by', Field('product', 'string'), Field('brand', 'string'), primarykey=['product', 'brand']) With a similar setup the update() function works well: db.manufactured_by.insert(product=Perfume, brand=Chanel) rset = db(db.manufactured_by.product==Perfume) rset.update(brand=Dior) Whereas the update_record() function throws an error -- KeyError: 'update_record': row = rset.select().first() row.update_record(brand=Fendi) Same for update_or_insert() which relies on calling update_record(). Tried with SQLite and MySQL backends. Is there any way to make those work? Many thanks! Dmitry update_record_case.py 1KViewDownload
Re: [web2py] DAL's virtual fields
maybe as a static method ( I did not tested, but may works On Mon, Nov 21, 2011 at 3:54 PM, Dmitry Vukolov dmitry.vuko...@gmail.comwrote: class MyVirtualFields(object): def total_price(self): return self.support_function(self.item.unit_price, self.item.quantity) @*staticmethod* def support_function(price, quantity): return price*quantity -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Django urls to web2py
For me it does not works wit Uppercase app name even in rocket server.
Re: [web2py] DAL's virtual fields
That actually works! Many thanks for the suggestion. I wish that could be in the book if that's the recommended approach. Dmitry
[web2py] Re: update_record() for DB's without an auto_increment field
Thank you! Good to know that it's an existing limitation rather than an overlooked bug. If that would be in the book, it will save time trying to figure out what's wrong. Dmitry
[web2py] Google Authentication on GAE
Using the method at http://groups.google.com/group/web2py/browse_thread/thread/641df72d9f897b1b/31f7a52cfcbdb7da?lnk=gstq=google+authentication+GAE#31f7a52cfcbdb7da on 1.99.2, I am getting redirect loop error in the browser: This webpage has a redirect loop The webpage at http://localhost:8080/app/default/user/login?_next=/app/default/index has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer. Any replies would be appreciated.
[web2py] basic authentication using pam
Is it possible to use PAM for basic auth? I have basic auth working (thanks to Hong-Khoan Quach's patch), however I can't seem to link it to PAM. We are using PAM successfully for web based user authentication, but basic auth seems to be ignoring this. Thanks, Matt
[web2py] Re: Django urls to web2py
Exactly - I needed to go everywhere and change to lowercase. But it works now.
[web2py] Appliance Email Form - unauthorized
Tried to install appliance Email Form but Unauthorized message - what is wrong?
[web2py] Re: Register user programmatic way
I will take a patch On Nov 21, 11:27 am, Vinicius Assef vinicius...@gmail.com wrote: How about including this function in Auth? -- Vinicius Assef. On Mon, Nov 21, 2011 at 10:43 AM, VIREN PATEL viren...@gmail.com wrote: Hi Bruno, Thanks a lot that was really helpful and solved mine and Shiv problem Thanks, Viren On Mon, Nov 21, 2011 at 5:35 PM, Bruno Rocha rochacbr...@gmail.com wrote: Create this function in some model def new_user(first_name, last_name, email, passw): users = db(db.auth_user.email==email).select() if users: return users[0].id else: my_crypt = CRYPT(key=auth.settings.hmac_key) crypt_pass = my_crypt(passw)[0] id_user= db.auth_user.insert( first_name=first_name, last_name=last_name, email = email, password = crypt_pass ) return id_user Now create user with this: iduser = new_user('Chris','Mills','ch...@nobody.com','somepasswordhere') On Mon, Nov 21, 2011 at 8:48 AM, Shiv shiv.veerashe...@gmail.com wrote: Hi, I want to import the user details from XL file and register in the user_auth table. If you can share info on how to register the users programmatic way, it will be of great help. Thanks Regards Shiv -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: basic authentication using pam
Good point. Basic auth may not work with PAM. Please open a ticket. On Nov 21, 1:26 pm, Matt Broadstone mbroa...@gmail.com wrote: Is it possible to use PAM for basic auth? I have basic auth working (thanks to Hong-Khoan Quach's patch), however I can't seem to link it to PAM. We are using PAM successfully for web based user authentication, but basic auth seems to be ignoring this. Thanks, Matt
[web2py] Re: Login form hidden _next field isn't reset
Does anyone know anything about this problem? On Fri, Nov 18, 2011 at 12:33 AM, Vinicius Assef vinicius...@gmail.com wrote: I'm making some tests with Auth and I'm facing one problem. This is my controller: http://pastebin.com/CNigd5qL I have a normal login form in default/index I'm following this flow: 1) Enter default/index page. 2) Go to default/protected Here, web2py redirects me to login page. It's right. :-) When I fill in the login form, web2py sends me to default/protected page. It's right, too. :-) After going to default/protected, I go to default/index, click in logout link and I'm redirected to default/index again. It's right, too. :-) But, after I logged out, if I login again in the same browser session, I'm redirected to default/protected page. Even if I didn't try to go there again. Is it right, or the _next hidden login form field should be reset after the successfull redirect to default/protected after the first login? -- Vinicius Assef.
Re: [web2py] Re: basic authentication using pam
On Mon, Nov 21, 2011 at 3:25 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Good point. Basic auth may not work with PAM. Please open a ticket. OK, issue created: http://code.google.com/p/web2py/issues/detail?id=532 Also, in the comments section I've included a patch to allow PAM authentication. As I note in the comment I don't have time to check that this works for all auth cases, but we only allow PAM and form based logins so this solution suffices for our needs. Matt On Nov 21, 1:26 pm, Matt Broadstone mbroa...@gmail.com wrote: Is it possible to use PAM for basic auth? I have basic auth working (thanks to Hong-Khoan Quach's patch), however I can't seem to link it to PAM. We are using PAM successfully for web based user authentication, but basic auth seems to be ignoring this. Thanks, Matt
[web2py] Re: SQLForm.grid - How do I use it properly?
Hi Anthony, Nearly got it! That was certainly helpful. I can show a VirtualField with your lambda idea, but only when I don't specify fields=(...). Unfortunately this means that I have to show every single field in the table, which isn't practical. I tried to include fields(..., db.table.myvirtualfield, ...) in my list of fields, but that throws an error. Do you have another suggestion that I could try? Kind regards, David
[web2py] Re: cannot run web2py on windows 7 machine with python 2.7 installed
I am having exactly the same problem. I'm on Windows 7 64 bit. I searched my disk for Python and found 6,647 occurrences of the word. From the various names on the files I believe that I have versions 2.5, 2.6.1 and 2.6.6 as a result of installing web2py, OpenOffice, InkScape and Blender. So when I clicked on the web2py.exe, what exactly did it do? Did it install Python 2.5 somewhere? (I found python25.dll in my download directory but not inside of the web2py folder.) Did it modify the Windows registry? Did it change any environment variables like path? Does it move any of the files or all they all *installed *in place? Once I clean up I think I'll try the source version. Peace, Rob:-]
[web2py] Re: Found a bug: XMLRPC with basic authorization fails
yes. this was fixed the same day. On Nov 21, 10:24 am, Matt mbroa...@gmail.com wrote: has this patch made it into the codebase? I'm looking at my checkout of 1.99.2 and it doesn't seem to be there (and trunk as well, from the looks of it). Of course, it may have been written differently, I was only checking for the exact strings
[web2py] Re: basic authentication using pam
Your patch is good (for pam and other methods that allow the app to handle the password) and it is in trunk On Nov 21, 3:35 pm, Matt Broadstone mbroa...@gmail.com wrote: On Mon, Nov 21, 2011 at 3:25 PM, Massimo Di Pierromassimo.dipie...@gmail.com wrote: Good point. Basic auth may not work with PAM. Please open a ticket. OK, issue created:http://code.google.com/p/web2py/issues/detail?id=532 Also, in the comments section I've included a patch to allow PAM authentication. As I note in the comment I don't have time to check that this works for all auth cases, but we only allow PAM and form based logins so this solution suffices for our needs. Matt On Nov 21, 1:26 pm, Matt Broadstone mbroa...@gmail.com wrote: Is it possible to use PAM for basic auth? I have basic auth working (thanks to Hong-Khoan Quach's patch), however I can't seem to link it to PAM. We are using PAM successfully for web based user authentication, but basic auth seems to be ignoring this. Thanks, Matt
[web2py] Re: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol on Upgraded v1.99.1
Please try the nightly build and let me know. On Nov 21, 10:07 am, Matt mbroa...@gmail.com wrote: On Nov 13, 10:54 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I think this should be be fixed in both stable and trunk. I am still seeing this error with 1.99.2, should it have been fixed there? On Nov 12, 10:38 am, Tito Garrido titogarr...@gmail.com wrote: Is it already fixed? On Thu, Sep 22, 2011 at 9:04 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Dirk and I ran some tests. 1.99.1 broke rocket with SSL. Do not upgrade if you use rocket with SSL. We will have a fix asap. Massimo On Sep 22, 4:50 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you show me what triggers it? On Sep 22, 4:39 pm, Dirk dirkl...@gmail.com wrote: Upgraded a test environment with the live update, and am seeing the following with embedded server and SSL enabled via CLI: ERROR:Rocket.Errors.Port8000:SSL Error: [Errno 8] _ssl.c:499: EOF occurred in violation of protocol TIA, Dirk -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Problem with using .as_list()
Why doesn't the as_list() seem to work when fields have been specified? Try this: db(db.table.id == 1).select().as_list()#works fine Now this: db(db.table.id == 1).select(db.table.id,db.table.x).as_list() #doesn't work properly with fields Am i missing something? I think as_dict() is the same.
[web2py] Re: SQLForm.grid - How do I use it properly?
On Monday, November 21, 2011 5:08:18 PM UTC-5, villas wrote: Hi Anthony, Nearly got it! That was certainly helpful. I can show a VirtualField with your lambda idea, but only when I don't specify fields=(...). Hmm, I'm not sure why that is. What if you don't specify any fields but instead hide the fields you don't want to show by setting their 'readable' attribute to False? Can you get the virtual fields in that case? Anthony
[web2py] IS_IN_SET validator
This example is given in the validators section of the book: requires = [IS_INT_IN_RANGE(0, 8), IS_IN_SET([2, 3, 5, 7], error_message='must be prime and less than 10')] It does not seem to work. If I attempt to combine IS_IN_SET with any other validator, the dropdown list doesn't work.
[web2py] Re: SQLForm.grid - How do I use it properly?
Yes, that's a good idea and it does seem to work. On the downside, I have a huge number of fields and I think the query will still fetch them all. Also I have to make a very long list of field.readable = False. So, if a better solution appears, I would be very grateful. However, in any case, I really do appreciate your assistance. Thank you and best regards, David
[web2py] Re: IS_IN_SET validator
After giving it a little more thought, I suppose the solution is to use an onvalidation function. However, it is still worthy of mention that something in the book does not seem to provide an expected result.
[web2py] Re: SQLForm.grid - How do I use it properly?
Yes, we should probably come up with a better solution. On Monday, November 21, 2011 8:55:57 PM UTC-5, villas wrote: Yes, that's a good idea and it does seem to work. On the downside, I have a huge number of fields and I think the query will still fetch them all. Also I have to make a very long list of field.readable = False. So, if a better solution appears, I would be very grateful. However, in any case, I really do appreciate your assistance. Thank you and best regards, David
[web2py] Re: IS_IN_SET validator
IS_IN_SET and IS_IN_DB only produce dropdown widgets when they are not within a list of validators. The book mentions this for IS_IN_DB, but not for IS_IN_SET. Anthony On Monday, November 21, 2011 9:27:35 PM UTC-5, villas wrote: After giving it a little more thought, I suppose the solution is to use an onvalidation function. However, it is still worthy of mention that something in the book does not seem to provide an expected result.
[web2py] Re: Google Authentication on GAE
can't remember the symptions, but when using the bulk load option for appconfig to upload/download data i have had to do the following: #/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_login.py # #line 260 in LoginCGI(), add: # # #hack for bulk loader # redirect_url = continue_url # output_headers.append(SetUserInfoCookie('t...@example.com', True)) note that the line number about is at least one GAE version out of date because i am behind by at least 1 GAE version due to other bugs with GAE SDK/web2py in the latest.
[web2py] setting db table for SQLFORM from an argument
I'm trying to abstract several content creation controllers into one controller. I want to use request.args[0] to set the db table in which the new row will be created. So far I've got this: def add(): the_table = request.args[0] tb = db.%s % the_table form = SQLFORM(tb) but I'm getting an error that str object does not have the attribute 'writeable'. It seems like SQLFORM is treating 'tb' as a string object rather than taking the string's content as an argument. Am I missing something? Is there a better way to do this? Thanks, Ian
Re: [web2py] setting db table for SQLFORM from an argument
try db[the_table] http://zerp.ly/rochacbruno Em 22/11/2011 00:49, monotasker scotti...@gmail.com escreveu: I'm trying to abstract several content creation controllers into one controller. I want to use request.args[0] to set the db table in which the new row will be created. So far I've got this: def add(): the_table = request.args[0] tb = db.%s % the_table form = SQLFORM(tb) but I'm getting an error that str object does not have the attribute 'writeable'. It seems like SQLFORM is treating 'tb' as a string object rather than taking the string's content as an argument. Am I missing something? Is there a better way to do this? Thanks, Ian
[web2py] Re: Problem with using .as_list()
What do you mean does not work properly? What do you see, what do you get? On Nov 21, 6:12 pm, villas villa...@gmail.com wrote: Why doesn't the as_list() seem to work when fields have been specified? Try this: db(db.table.id == 1).select().as_list() #works fine Now this:db(db.table.id == 1).select(db.table.id,db.table.x).as_list() #doesn't work properly with fields Am i missing something? I think as_dict() is the same.
[web2py] Re: setting db table for SQLFORM from an argument
As Bruno suggested: def add(): tablename = request.args[0] if not tablename in db.tables(): error() # or other set of allowed tables. form = SQLFORM(db[tablename]) On Nov 21, 8:49 pm, monotasker scotti...@gmail.com wrote: I'm trying to abstract several content creation controllers into one controller. I want to use request.args[0] to set the db table in which the new row will be created. So far I've got this: def add(): the_table = request.args[0] tb = db.%s % the_table form = SQLFORM(tb) but I'm getting an error that str object does not have the attribute 'writeable'. It seems like SQLFORM is treating 'tb' as a string object rather than taking the string's content as an argument. Am I missing something? Is there a better way to do this? Thanks, Ian
[web2py] Re: SQLForm.grid - How do I use it properly?
I am bit lost in this thread. Can you summarize the issue? On Nov 21, 7:55 pm, villas villa...@gmail.com wrote: Yes, that's a good idea and it does seem to work. On the downside, I have a huge number of fields and I think the query will still fetch them all. Also I have to make a very long list of field.readable = False. So, if a better solution appears, I would be very grateful. However, in any case, I really do appreciate your assistance. Thank you and best regards, David
Re: [web2py] setting db table for SQLFORM from an argument
db[the_table] works! Thanks Bruno.
[web2py] Re: setting db table for SQLFORM from an argument
Thanks Massimo. I hadn't included the error handling bit.
[web2py] Insert references in a record
Hello, I'm having difficulty getting inserts to work with tables that have references and I'm sure its something stupid I'm doing wrong. Hopefully you guys can point me in the right direction. I have the following 2 tables. db.define_table('event_users', Field('event', 'reference events'), Field('user_name', 'reference auth_user'), Field('goal', 'double'), Field('last_entry', 'date'), format = lambda row: %s - %s % (row.event.name, row.user_name.first_name)) db.define_table('entries', Field('user', 'reference event_users'), Field('date_entered', 'date'), Field('value', 'double'), format='%(user)s %(date_entered)s') I'm trying to insert a record into the entries table. I have the following SQLFORM to generate the view and then try to pre-populate date_entered and user. User is calculated and is equal to Reference form = SQLFORM(db.entries) form.date_entered = date.today() form.user = user if form.process().accepted: But the form won't submit. When I debug it through Eclipse it says lazyT: value not in database Any suggestions? thanks Adrian
[web2py] Re: Insert references in a record
I am pretty sure the error is not the code you showed us. You are somwhere assigning something to =T(...) where it expects a string. On Nov 21, 11:30 pm, Adrian Edwards aedward...@gmail.com wrote: Hello, I'm having difficulty getting inserts to work with tables that have references and I'm sure its something stupid I'm doing wrong. Hopefully you guys can point me in the right direction. I have the following 2 tables. db.define_table('event_users', Field('event', 'reference events'), Field('user_name', 'reference auth_user'), Field('goal', 'double'), Field('last_entry', 'date'), format = lambda row: %s - %s % (row.event.name, row.user_name.first_name)) db.define_table('entries', Field('user', 'reference event_users'), Field('date_entered', 'date'), Field('value', 'double'), format='%(user)s %(date_entered)s') I'm trying to insert a record into the entries table. I have the following SQLFORM to generate the view and then try to pre-populate date_entered and user. User is calculated and is equal to Reference form = SQLFORM(db.entries) form.date_entered = date.today() form.user = user if form.process().accepted: But the form won't submit. When I debug it through Eclipse it says lazyT: value not in database Any suggestions? thanks Adrian
Re: [web2py] SQLForm.grid - How do I use it properly?
try this : ,links = [lambda row: A( SPAN(_class='icon magnifier') ,'View Post' ,_class='button',_title='View Post' ,_href=URL(args=[view, db.person, row.id]) ) ] On Monday, November 21, 2011, Rahul wrote: Hi Johann, That is correct but I just wanted to know if I can change the existing functionality for SQLForm.grid View button. To be precise - here is an example of what I am trying to do. Example: The default builtin View button on SQLForm.grid has label View, now how can I change its label to say View Post. Note, here I do not intend to over-ride the existing controller(function) that SQLForm.grid's View provides but just change its label. How can we achieve this? I hope you get what I am doing here :) Again - If someone could post the complete syntax for SQLForm.grid(All possible parameters ). It would be really helpful. Thanks Thanks and Regards, Rahul (www.flockbird.com - web2py powered) On Nov 19, 2:13 am, Johann Spies johann.sp...@gmail.com javascript:; wrote: On 18 November 2011 09:00, Rahul rahul.dhak...@gmail.com javascript:; wrote: Hi Johan, All, Sorry but I am not able to get it. With your code above I get an invalid controller You are not supposed to use that code exactly as it is. You must adapt it for your circumstances: links = [lambda row: A('Edit',_href=URL(controller,edit,args=[update, tablename, a.id ])) Replace controller with your controller e.g. 'default' Replace 'edit' with your function in the controller referred to. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)