[web2py] SQLFORM.grid export missing computed fields
Hi Guys, I have a grid with two more columns with computed fields using below implementation - links = [{'header':'column1','body':lambda row: function1(row.id)}] It displays as I expected, but when I tried to export to csv (csv=True parameter is set) that column is missing. Am I missing something or it is not supported in grid. Appreciate if someone could point me to the right direction. Regards, k0aun9 --
[web2py] Re: PythonAnywhere, upgrading to latest Web2Py?
Thanks for the tip, sorry it took me so long to say that. I must have switched off notifications from Google Groups some time in the past. Hmm, okay so we should probably let existing users know that they can make that fix and then try the upgrade. By default we will be installing the latest stable version soon anyway. Cheers Hansel On Friday, 7 September 2012 10:34:49 UTC+1, Nico Zanferrari wrote: Hello Hansel! You can also easily fix the upgrade script as described herehttps://groups.google.com/d/msg/web2py/glJjRw-TLKU/AkmktM7XExYJ and let existing users decide directly from the administrative interface! In this way the upgrade to 2.0.8 seems to work fine, except for a ticket error at the end of the upgrade that hangs the application until you reload the web app. And a silly Running on %s on the administrative interface itself under the version number. Thank you for the great work, Nico --
[web2py] Re: auth.wiki() '_create' doesn't redirect properly
If you request a page that doesn't exist, then you are directed to _create. It would be nice to be able to suppress that behaviour. You have to be logged in to go on and create the page. If you call a wiki page inside a view with auth.wiki(slug='mywrongpage') it does not always redirect correctly. You can work around this by using LOAD(), which is in fact better. So I'm only mentioning this for Massimo in case he wanted the auth.wiki() inside views to remain as a feature, in which case it would have to be fixed. I think it should be deprecated if it dosn't add anything. Zen... There should be one -- and preferably only one -- obvious way to do it. On Friday, October 19, 2012 2:02:18 AM UTC+1, Bill Thayer wrote: Back on the original topic. When I click on a menu item I also get re-directed back to the _create page. Is this a permission thing perhaps? Now that I mention it, isn't there supposed to be a field to select the permission level for the page? --
Re: [web2py] Re: cannot upgrade to 2.1.1 from GUI on Pythonanywhere
Excellent, thanks very much Nico. Greatly appreciate your work. On Wednesday, 17 October 2012 22:25:35 UTC+1, Nico Zanferrari wrote: Hi Hansel. I've just changed a single line of code in the default PA installation, following rochacbruno suggestion on https://groups.google.com/forum/#!msg/web2py/glJjRw-TLKU/AkmktM7XExYJ . This allows everyone to simply upgrade by themselves to the latest version from the web2py administrative console, if they wish so. My suggestion is to implement ASAP this simple fix on all existing web2py installations on PythonAnywhere, And from tomorrow you should use version 2.1.1 as the new base install version of web2py, as Massimo pointed out. Thank you, Nico --
[web2py] Ajax / cid with A helper not working
I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cid in more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
Re: [web2py] Re: tags and speed
hi Thank you for your explanation. It is really helpful The address of the chapter in the book is Efficient search by tag and i choose this approach because i thought that search would be the most important thing of the application (that was right) The table tag is similar like in your example 2, but only one tag per row, so: game_id tag 1 excitement 1 funny I learned some lessons: - do usability testing ass soon as possible (it came as a surprise for me that using Datatables is the most useful) - be prepared for lots of data: my initial assumption was 200 games, and now i have more than 1000. I will try with cache first. andrej On Friday, October 19, 2012 1:21:37 AM UTC+2, Niphlod wrote: old mean bad thing about normalized vs denormalized model. Don't know what you read in the cookbok, but here's the thing. You have a game pacman that is tagged as arcade, and a game invaders tagged as horror First things first: you may want to change horror to needs parent around later in the future. That's why you may want to create an external tags table and reference it in your games one. tags table 1 arcade 2 horror game_name tags pacman 1 invaders 2 To display pacman arcade invaders horror you just need a simple join. Changing record 2 of the tags table allows you to have pacman arcade invaders needs parents around Next problem on the line: you want multiple tags for a single game (invaders needs both arcade and horror tags). Welcome to normalization hell. Books have been written about it in the last 60-70 years, with terms like 3NF and Cardinality all around ^_^ Let's take this by examples 1) you change the tags table like this id tag_name game_id 1 arcade 1 1 arcade 2 2 horror 2 getting tags for a single game is fast, change horror to needs parents around is fast, getting all possible tags is enough fast (depending on the number of rows of the tags table) but fetch the right tags for every game can be slow 2) you create a games table like this id game_name tags 1 pacman |arcade| 2 invaders |arcade|horror| getting tags for a single game is fast, updating a tag for a game is quite fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow 3) you create a games table like this id game_name tags_id 1 pacman |1| 2 invaders |1|2| getting tags for a single game is fast, updating a tag for a game is quite fast, changing horrors is fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow So, with no need to change tag names from horror to needs parents around, I'd say the right way for displaying your table is 2) (list:string), else 3) (list:reference). If you need to suggest previously entered tags (i.e. you don't want to end having arcade, arcady, arcadian, 'rcade spat all around), I'd still go for 2) + one separate table (or a cached list) holding all previously entered tags, just to speedup the suggestion phase (hoping users won't screw up). Method 1) is faster only when: - tags are more than the games - cleaning normalization logics are heavy - you need to update tag names often - the only need is displaying tags for a single game (direct query on a single table, the tags one) - you need to compute something like how many times the arcade tag is applied to all my games (i.e. for a tag cloud) There are several other methods, and all of them in the end do the job. You just need to see what are your requirements and choose carefully. Your agenda is: - spend the less time possible with queries you have to invoke often - pay the price of your model in high computations for other things (or, let's save the results of those computations externally once every hour) --
Re: [web2py] Re: pythondiary
I was working for the last few hours on supporting appadmin's queries into web2admin and these are my conclusions: - executing queries and displaying them in the same smartgrid table would complicate the code very much (smartgrid already supports smart queries and the possibility of using both of them generates too many conditions) - the appadmin and web2admin target two different needs although some features overlap (the ability to run powerful queries might not be a good idea to expose to the clients) - if dal queries are a must for the admin then maybe the appadmin should stay as it is and web2admin should only be an optional plugin Either way I hope more people would find out about it. -rif vineri, 19 octombrie 2012, 06:39:31 UTC+3, rochacbruno a scris: To don't let this issue to get lost, I created a ticket about this: http://code.google.com/p/web2py/issues/detail?id=1103 --
[web2py] Re: Ajax / cid with A helper not working
please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,puppa);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cid in more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] is commit necessary for update_or_insert() in scheduler
Just noticed that records won't get updated when I call update_or_insert from scheduler, unless I include commit. Should it be like that? tbl_a.update_or_insert(...) tbl_b.update_or_insert(...) db.commit() --
[web2py] There were changes in MS SQLServer driver?
Hello, I have a production application that uses MS SQL Server in a UNIX environment, running web2py version 1.99.4. the connection is: dal unixodbc freetds sqlserver. I'm trying to migrate to web2py version 2.1.1, but fails to connect to the database: type 'exceptions.RuntimeError'(Failure to connect, tried 5 times: Traceback (most recent call last): File /usr/home/jose/web2py/gluon/dal.py, line 6754, in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File /usr/home/jose/web2py/gluon/dal.py, line 3034, in __init__ if do_connect: self.reconnect() File /usr/home/jose/web2py/gluon/dal.py, line 582, in reconnect self.connection = f() File /usr/home/jose/web2py/gluon/dal.py, line 3032, in connector return self.driver.connect(cnxn,**driver_args) Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)') ) the connection is: db = DAL http://127.0.0.1:8001/examples/global/vars/DAL( mssql://CAPC;UID=user;PWD=pwd) Any idea? Thanks Jose --
[web2py] Re: is commit necessary for update_or_insert() in scheduler
in any external process when you use dal you should commit to save changes. web2py commits at the end of the request by default, but in the scheduler (it is an external process, after all) you should do it manually. You must think to the scheduler as a web2py shell (launched with web2py.py -M -S yourapp), the execution environment is the same. On Friday, October 19, 2012 3:33:32 PM UTC+2, Adi wrote: Just noticed that records won't get updated when I call update_or_insert from scheduler, unless I include commit. Should it be like that? tbl_a.update_or_insert(...) tbl_b.update_or_insert(...) db.commit() --
[web2py] Re: SQLFORM.grid export missing computed fields
Links are not included in the csv export. The proper way to do it would be to use computed fields or virtual fields. Yet the grid must be improved to support it. Please open a ticket. massimo On Friday, 19 October 2012 04:33:37 UTC-5, k0aun9 wrote: Hi Guys, I have a grid with two more columns with computed fields using below implementation - links = [{'header':'column1','body':lambda row: function1(row.id)}] It displays as I expected, but when I tried to export to csv (csv=True parameter is set) that column is missing. Am I missing something or it is not supported in grid. Appreciate if someone could point me to the right direction. Regards, k0aun9 --
[web2py] Re: There were changes in MS SQLServer driver?
I found this [1] that I had asked. I see that the same error occurred with version 1.99.7 [1] https://groups.google.com/forum/?fromgroups=#!topic/web2py/OlUTguqcqpw Jose --
[web2py] Re: Ajax / cid with A helper not working
I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cid in more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] Re: Ajax / cid with A helper not working
yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cid in more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
Re: [web2py] Re: is commit necessary for update_or_insert() in scheduler
Thank you Niphlod! Every day I thank you, Massimo and everyone who contribute, for a scheduler, and web2py in general :) The scheduler is now on autopilot, simulating a workflow and works like a charm... Just loading large data through it, and will see how will app behave once all is in... We'll also switch to nginx and uwsgi, hopefully that will be a good move. On Fri, Oct 19, 2012 at 9:38 AM, Niphlod niph...@gmail.com wrote: in any external process when you use dal you should commit to save changes. web2py commits at the end of the request by default, but in the scheduler (it is an external process, after all) you should do it manually. You must think to the scheduler as a web2py shell (launched with web2py.py -M -S yourapp), the execution environment is the same. On Friday, October 19, 2012 3:33:32 PM UTC+2, Adi wrote: Just noticed that records won't get updated when I call update_or_insert from scheduler, unless I include commit. Should it be like that? tbl_a.update_or_insert(...) tbl_b.update_or_insert(...) db.commit() -- --
[web2py] Re: There were changes in MS SQLServer driver?
I answer myself db = DAL http://127.0.0.1:8001/examples/global/vars/DAL( mssql://CAPC;UID=user;PWD=pwd) must explain the dsn: db = DAL http://127.0.0.1:8001/examples/global/vars/DAL( mssql://dsn=CAPC;UID=user;PWD=pwd) Jose --
[web2py] Scheduler conflict
I upgraded to the newest web2py (2.1.1) Launch it with: ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword -K applicationName When I run the -K application (ie scheduler) I am then unable to access the admin or front end of the site. I simply see the dreaded Safari Cannot connect to server message. The scheduler does nothing crazy. It updates a file in /tmp/ with the current date/time 3 times over a 60 second period. Had anyone else experienced this? --
[web2py] Re: cron not work in 2.0.9
Thanks, worked perfectly. Great work. --
[web2py] Re: Scheduler conflict
-K starts the scheduler. Scheduler and webserver are meant to be executed on different processes. So, web2py.py -i -p 8000 -a apassword in one shell and web2py.py -K applicationName in another one. From 2.0.0 onwards, there is the possibility to start two separate processes from one command line, but you have to use -X too. So, ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword -K applicationName -X does what ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword and ./web2py.py -K applicationName previously did in older versions. On Friday, October 19, 2012 4:55:26 PM UTC+2, Mike Anson wrote: I upgraded to the newest web2py (2.1.1) Launch it with: ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword -K applicationName When I run the -K application (ie scheduler) I am then unable to access the admin or front end of the site. I simply see the dreaded Safari Cannot connect to server message. The scheduler does nothing crazy. It updates a file in /tmp/ with the current date/time 3 times over a 60 second period. Had anyone else experienced this? --
[web2py] Re: Scheduler conflict
Thanks for that Niphlod. On Friday, 19 October 2012 11:10:17 UTC-4, Niphlod wrote: -K starts the scheduler. Scheduler and webserver are meant to be executed on different processes. So, web2py.py -i -p 8000 -a apassword in one shell and web2py.py -K applicationName in another one. From 2.0.0 onwards, there is the possibility to start two separate processes from one command line, but you have to use -X too. So, ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword -K applicationName -X does what ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword and ./web2py.py -K applicationName previously did in older versions. On Friday, October 19, 2012 4:55:26 PM UTC+2, Mike Anson wrote: I upgraded to the newest web2py (2.1.1) Launch it with: ./web2py.py -i xxx.xxx.xx.xx -p 8000 -c /etc/ssl/certs/cert-file.crt -k /etc/ssl/certs/key-file.key -a apassword -K applicationName When I run the -K application (ie scheduler) I am then unable to access the admin or front end of the site. I simply see the dreaded Safari Cannot connect to server message. The scheduler does nothing crazy. It updates a file in /tmp/ with the current date/time 3 times over a 60 second period. Had anyone else experienced this? --
[web2py] Re: auth.wiki() '_create' doesn't redirect properly
If you request a page that doesn't exist, then you are directed to _create. It would be nice to be able to suppress that behaviour. You have to be logged in to go on and create the page. That could be easily fixed by adding an auth.is_logged_in() check, but what would be the correct behavior in that case? BTW: I didn't get what feature is the one to be deprecated. --
Re: [web2py] [OT] Ubuntu 12.10 will no longer ship with Python 2
Python2 is also installed by default, and importantly, /usr/bin/python is still a symlink to python2.7 --
[web2py] Re: auth.wiki documentation?
Is there any advanced documentation on auth.wiki similar to the plugin_wiki chapter in the book? AFAIK it's an experimental feature yet which would explain the lack of documentation. There are some examples posted at this group. We could build some docs out of the source code, although it seems that there isn't much help in gluon.tools docstrings. --
[web2py] Re: The web2py grid/crud plugin you've always dreamed about! Options
I'm working with web2py 2.1.1 and I have the same problem with PowerGrid What is then __init__.py solution? Thanks El martes, 9 de agosto de 2011 11:45:52 UTC+2, peter escribió: I found the problem, it was caused by having something in _init_.py Thanks On Aug 8, 4:10 pm, peter peterchutchin...@gmail.com wrote: And where does the custom_importer get its paths from, because they seem different in some apps to in others. So how can I check the paths or change them. Thanks On Aug 8, 1:08 pm, Bruno Rocha rochacbr...@gmail.com wrote: it is imported by the web2py custom_importer On Mon, Aug 8, 2011 at 8:26 AM, peter peterchutchin...@gmail.com wrote: Let me ask the question the other way round. How come powergridapp does find the module powergrid. If I look at the current working directory, it is the web2py folder, and if I look at sys.path, it does not have the applications folder in there, so how come the from plugin_PowerGrid.PowerGrid import PowerGrid statement succeeds in finding the module when it is relative to the applications path? what path is it using to find the powergrid module, and where does it get this path from? Thanks Peter On Aug 6, 6:01 pm, peter peterchutchin...@gmail.com wrote: It is 1.98.2 On Aug 6, 5:28 pm, Bruno Rocha rochacbr...@gmail.com wrote: What is your web2py version? The plugin works only in 1.97+ http://zerp.ly/rochacbruno Em 06/08/2011 08:55, peter peterchutchin...@gmail.com escreveu: I have powergridapp working on my system, however when I added the powergrid plugin to my app I get No module named plugin_PowerGrid.PowerGrid Yet, the file organisation seems to be the same. I have plugin_PowerGrid within my modules folder and PowerGrid.py within that folder. Any help appreciated. Thanks Peter- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - -- -- Bruno Rocha [ About me:http://zerp.ly/rochacbruno] [ Aprenda a programar:http://CursoDePython.com.br] [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br] [ Consultoria em desenvolvimento web:http://www.blouweb.com]- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - --
[web2py] Re: manage_groups AD problem
I am having trouble with manage_group=True, when I enable it i am getting Invalid Login but without it logins work. Does AD Group Management in web2py work? Kind regards, --
[web2py] Re: Loading modules fails - web2py 2.1.1(and earlier) / python 2.7.1 / Mac OS X
Well it seems that after a lot of research and specially after posting this question that I found the solution. I've tried facebook-sdk module and had to modify just one line to make it work: facebook.py, line 49: # Find a JSON parser try: import simplejson as json To # Find a JSON parser try: import gluon.contrib.simplejson as json And that's all. Hope it helps anybody! On Thursday, October 18, 2012 1:43:29 PM UTC-3, Luciano Laporta Podazza wrote: Hello, first of all thank you Massimo and you people for this awesome framework! I'm in love with it! :D I've tried to load some facebook modules and none of them works, at least on Mac OS. This is what I did: 1. Get facebook api from one of these repos: https://github.com/sciyoshi/pyfacebook/ https://github.com/jgorset/facepy https://github.com/pythonforfacebook/facebook-sdk 2. Copy them on modules/ like this: modules/facebook-api-folder/files.py 3. Load it from the controller, e.g. facepy module: def index(): from facepy import graph_api It doesn't matter what I try, I always get some errors: - type 'exceptions.ImportError' No module named facepy (or other module's name) - With facebook-sdk it says that simplejson can't be loaded 'cause it doesn't exists(and it exists and works!) - it doesn't matter the way I put the module folder under modules/, for example modules/facebookmodule/sub-dir/module.py and then from facebookmodule.subdir import module. I always get the error that the module does not exists. - I even tried copying the module under site-packages and it seems to load the module(I get no errors about it) but then I get the error that simplejson doesn't exists(and this is not true). A friend of mine tried this on GNU/Linux and modules works perfectly, so it seems the issue is related with Mac OS. Any ideas?. please note that I'm a newbie with python and web2py. LOT of thanks in advance :) --
[web2py] CPU and memory issues with apache
Not sure if web2py has anything with this. Could be. First issue is that CPU jumps up to 100%. I am watching it with htop and it happens every few minutes, 'apache2' process is using it. Site becomes unresponsive. I tried to restart apache several times but it didn't help. However, after server reboot CPU is back to normal and mostly below 2% usage. Another issue is the memory. After server reboot memory consumption is 25%. After some time it goes up to 85%. I have a controller that calls subprocess.Popen and sometimes it doesn't work because of Cannot allocate memory. This makes the memory consumption an issue. It seems that only apache memory is growing (still using htop to check it). I am not an apache expert and not sure what to do. I can provide additional details if needed. I hope someone can help :) Marin --
[web2py] Re: web2py.com offline
El viernes, 20 de julio de 2012 14:22:36 UTC-3, Dave escribió:can't get to the website today Me neither --
Re: [web2py] Is this possible?
Ok, now I understand... That should work. About the suggestion, I have no single key for table and field tuple... The database table is not normalized and the only way I found so far is to use a composed pk formed with table and field to refer to unique field entry. If I had not identical field name in differents tables I could avoid that. Anyway, until now it has work well, I may need to better engineer this part of my database in the future thought. Thanks Richard On Thu, Oct 18, 2012 at 6:31 PM, Niphlod niph...@gmail.com wrote: you are calling db.table1 somewhere. In my code there is no db.table1 at alljust tried, works. Readable example tablename = 'test1' labels = dict(test1_foo='test1label') db.define_table(tablename, Field('foo', label=labels[%s_foo % tablename]) ) BTW: you'd be better off separating table name and field name in your labels dict (or even, structure it as dict(table=tablename,fields=dict(fieldname=label))). If you have a table named *foo* with a field *bar* and a table *foob*with a column *ar* you are going to display the same label for both ;-) On Thursday, October 18, 2012 11:09:56 PM UTC+2, Richard wrote: I still get type 'exceptions.AttributeError' 'DAL' object has no attribute 'table1' You right that I didn't need call db.table._tablename and db.table.field.name... I was just trying something else before then I forget I didn't need to call those attributes. Anyway, I think it is not possible since model is not yet define. FYI dblables_en is a dict like this one {'table1field1': 'field1LableStoreInDb'} Thanks. Richard On Thu, Oct 18, 2012 at 4:40 PM, Niphlod nip...@gmail.com wrote: you are asking to python to evaluate a variable that doesn't exists. It seems that you know the tablename and fields in advance (because dblabels_en is somewhat filled already) so why can't you just tablename = 'test1' db.define_table(tablename, Field('foo', label=T(dblabels_en[%s_foo % tablename]))) ? On Thursday, October 18, 2012 9:57:09 PM UTC+2, Richard wrote: Hello, Is it possible to do that? db.define_table(... Field(... label=T(dblabels_en[db.table._tablename+db.table.field.name]*** *) I can do db.define_table(...) db.table.field.lable=T(**dblabel**s_en[db.table._**tablename+db.** table.field.name http://db.table.field.name]**) Inside table model definition table is not yet define then I can refer to it. I try with lambda with no succes. Do you see a way to refer to the db.table._tablename in order to make it execute only once that the model is defined? Thanks Richard -- -- --
Re: [web2py] is there a way to do something like that (tooltip and label)
Nice! It works! Thanks Bruno. Richard On Thu, Oct 18, 2012 at 5:54 PM, Bruno Rocha rochacbr...@gmail.com wrote: Try this: db.table.field.label = *CAT(*T(dblabels[concat]), A(I(_class='icon-info-sign'), _href=##, _id=example1, _rel=popover, **{'_data-content': 'Help comment here!', '_data-original-title': 'Help comment title...'})*)* -- --
[web2py] how to loop through tables with 1M records?
I just tried to perform a select() on a mysql table with 700k records. All available memory on my mac was consumed to the point that I had to kill the process. I reduced number of fields just to id, and got the results after some time, but wondering if there is some better approach in order to loop through all records with all needed fields? Thanks, Adi --
Re: [web2py] how to loop through tables with 1M records?
_last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id --
Re: [web2py] how to loop through tables with 1M records?
Thank you Vasile for your quick response. This will be perfect. On Friday, October 19, 2012 2:02:41 PM UTC-4, Vasile Ermicioi wrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id --
[web2py] Trunk, error after login
Traceback (most recent call last): File /home/www-data/test-web2py/gluon/main.py, line 561, in wsgibase session._try_store_on_disk(request, response) File /home/www-data/test-web2py/gluon/globals.py, line 703, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle function objects It happens with trunk and 2.1.1 but not with 2.0.9 Marin --
Re: [web2py] is there a way to do something like that (tooltip and label)
Why is this not working : CAT(T(dblabels[concat]), *' ',* A(I(_class='icon-info-sign'), _href=##, _id=example1, _rel=popover, **{'_data-content': T(dbtooltips[concat]), '_data-original-title': 'Titre du commentaire d\'aide'}) if dbtooltips[concat]!='' and dbtooltips[concat]!=None else None) I get : type 'exceptions.TypeError' cannot concatenate 'str' and 'NoneType' objects When it execute in normal web2py flow it failed with the above error, but it works in shell. Richard On Fri, Oct 19, 2012 at 1:47 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Nice! It works! Thanks Bruno. Richard On Thu, Oct 18, 2012 at 5:54 PM, Bruno Rocha rochacbr...@gmail.comwrote: Try this: db.table.field.label = *CAT(*T(dblabels[concat]), A(I(_class='icon-info-sign'), _href=##, _id=example1, _rel=popover, **{'_data-content': 'Help comment here!', '_data-original-title': 'Help comment title...'})*)* -- --
[web2py] Re: Trunk, error after login
doesn't happen here. What are you storing into session ? On Friday, October 19, 2012 8:26:09 PM UTC+2, Marin Pranjić wrote: Traceback (most recent call last): File /home/www-data/test-web2py/gluon/main.py, line 561, in wsgibase session._try_store_on_disk(request, response) File /home/www-data/test-web2py/gluon/globals.py, line 703, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle function objects It happens with trunk and 2.1.1 but not with 2.0.9 Marin --
Re: [web2py] is there a way to do something like that (tooltip and label)
With a SPAN(' ') it get away. Richard On Fri, Oct 19, 2012 at 2:30 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Why is this not working : CAT(T(dblabels[concat]), *' ',* A(I(_class='icon-info-sign'), _href=##, _id=example1, _rel=popover, **{'_data-content': T(dbtooltips[concat]), '_data-original-title': 'Titre du commentaire d\'aide'}) if dbtooltips[concat]!='' and dbtooltips[concat]!=None else None) I get : type 'exceptions.TypeError' cannot concatenate 'str' and 'NoneType' objects When it execute in normal web2py flow it failed with the above error, but it works in shell. Richard On Fri, Oct 19, 2012 at 1:47 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Nice! It works! Thanks Bruno. Richard On Thu, Oct 18, 2012 at 5:54 PM, Bruno Rocha rochacbr...@gmail.comwrote: Try this: db.table.field.label = *CAT(*T(dblabels[concat]), A(I(_class='icon-info-sign'), _href=##, _id=example1, _rel=popover, **{'_data-content': 'Help comment here!', '_data-original-title': 'Help comment title...'})*)* -- --
[web2py] Re: manage_groups AD problem
Are you talking about ldap_auth? On Friday, 19 October 2012 02:38:39 UTC-5, software.ted wrote: I am having trouble with manage_group=True, when I enable it i am getting Invalid Login but without it logins work. Does AD Group Management in web2py work? Kind regards, --
[web2py] Re: There were changes in MS SQLServer driver?
So, is the issue closed? On Friday, 19 October 2012 09:51:40 UTC-5, Jose wrote: I answer myself db = DAL http://127.0.0.1:8001/examples/global/vars/DAL( mssql://CAPC;UID=user;PWD=pwd) must explain the dsn: db = DAL http://127.0.0.1:8001/examples/global/vars/DAL( mssql://dsn=CAPC;UID=user;PWD=pwd) Jose --
[web2py] web2py.com is down
As in the object Richard --
Re: [web2py] how to loop through tables with 1M records?
the set returned by select is always a full result set, because it is extracted and parsed alltogether. Slicing with limits is good (and recommended, if possible). Just remember that you can save a lot of time and memory passing cacheable=True to the select() function. References will be stripped off the normal Rows record, as long as other convenience functions like update_record and delete_record. If you can live without those, for large queries I'd go with select(cacheable=True) all the time On Friday, October 19, 2012 8:17:38 PM UTC+2, Adi wrote: Thank you Vasile for your quick response. This will be perfect. On Friday, October 19, 2012 2:02:41 PM UTC-4, Vasile Ermicioi wrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id --
Re: [web2py] web2py.com is down
confirm, web2py.com is down On Friday, October 19, 2012 7:48:25 PM UTC+1, Richard wrote: As in the object Richard --
[web2py] Re: Trunk, error after login
Do you have a lazy virtual fields in a table and then store records with the lazy virtual field in the session? On Friday, 19 October 2012 13:26:09 UTC-5, Marin Pranjić wrote: Traceback (most recent call last): File /home/www-data/test-web2py/gluon/main.py, line 561, in wsgibase session._try_store_on_disk(request, response) File /home/www-data/test-web2py/gluon/globals.py, line 703, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle function objects It happens with trunk and 2.1.1 but not with 2.0.9 Marin --
[web2py] Re: Form, with Dropbox and distinct values from db.
in your code, macaddr is a resultset of your query. Basically it's a list of Rows objects, done like this [ {'mac_addr' : value}, {'mac_addr':value1}, {'mac_addr' : value2}] you should reduce the list of dictionaries to a list of values. def get_macaddr(): # Grab distinct MAC addresses from DB macaddr = db(db.wifiusage).select(db.wifiusage.mac_addr, distinct=True) macaddr = [row.mac_addr for row in macaddr] #line added by Niphlod form = SQLFORM.factory( Field('macaddr', label='Select a MAC Address', requires=IS_IN_SET( macaddr))) return dict(form=form) And everything should work ok. On Thursday, October 18, 2012 1:02:44 AM UTC+2, Jason Jeremias wrote: So I'm trying out Web2py, I'm a complet newbie. I've been using python to write CGI for years, I have python cgi that I use to display data from mysql db. Its pretty simple and I thought I'd trying to recreate it using web2py. Basically its a simple html form that has a drop box and a submit button. The drop box is filled with mac addresses from a database. So basically you select the mac address, hit submit and it brings back all the data in the db related to that mac address. My current cgi program uses a simple function to grab the distinct mac addresses from the db and put them in to a dropdown. def PrintSelectMAC(): db = MySQLdb.connect(localhost,myuser,mypass,wifi_usage) cursor = db.cursor() sql = 'SELECT DISTINCT(mac_addr) from wifi_usage' cursor.execute(sql) data = cursor.fetchall() print (bSelect MAC Addresses:/BBR \n) print (SELECT NAME=\mac_addr\) for row in sorted(data): macaddr = row[0] print (OPTION VALUE=\%s\%s) %(macaddr, macaddr) print (/SELECT) I'm trying to get just this far with Web2py and I'm running into a learning curve or something. Here's what I've done so far.. in my Model (db.py) I have added.. db = DAL(mysql://myuser:mypass@localhost/wifi_usage) db.define_table('wifiusage', Field('u_date', 'date'), Field('account_id', 'string', length=16), Field('mac_addr', 'string', length=20), Field('upstream', 'integer'), Field('downstream', 'integer'), Field('total', 'integer'), Field('location', 'string'), Field('package', 'string') ) So this worked well. I then populated this database with data. in my controller (index) I added: def get_macaddr(): # Grab distinct MAC addresses from DB macaddr = db(db.wifiusage).select(db.wifiusage.mac_addr, distinct=True) form = SQLFORM.factory( Field('macaddr', label='Select a MAC Address', requires=IS_IN_SET(macaddr))) return dict(form=form) I created a get_macaddr.html view. It looks like this. {{extend 'layout.html'}} h1This is the get_macaddr.html template/h1 {{=form} Here's the issue. My Form dropdown box. contains entries that look like this. Row {'mac_addr': '0123456789ab'} What I want is it to contain just the macaddress ''0123456789ab' for the value I have to admit the syntax is messing with me. I'm sure I'm doing something silly, Perhaps I've been doing cgi to long. I want to stick with it and learn web2py, what am I doing wrong? Thanks --
[web2py] Re: Trunk, error after login
I have virtual and lazy fields on auth_user table and I store them in auth on each request. Lazy field is the the issue because I store lambda in auth. I just tried to remove it and it works without it. So, I have: if auth.user: auth.user.something = lambda: ... And this fails. I can live without it but I thought it was safe because auth is filtering the fields, right? Dana petak, 19. listopada 2012. 20:52:15 UTC+2, korisnik Massimo Di Pierro napisao je: Do you have a lazy virtual fields in a table and then store records with the lazy virtual field in the session? On Friday, 19 October 2012 13:26:09 UTC-5, Marin Pranjić wrote: Traceback (most recent call last): File /home/www-data/test-web2py/gluon/main.py, line 561, in wsgibase session._try_store_on_disk(request, response) File /home/www-data/test-web2py/gluon/globals.py, line 703, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle function objects It happens with trunk and 2.1.1 but not with 2.0.9 Marin --
Re: [web2py] CPU and memory issues with apache
Look like a memory leaks... Maybe you could profile your app with web2py included profiler... You just need to add -F profileroutputfile.txt at the end of the initialization web2py string Richard On Fri, Oct 19, 2012 at 1:24 PM, Marin Pranjić marin.pran...@gmail.comwrote: Not sure if web2py has anything with this. Could be. First issue is that CPU jumps up to 100%. I am watching it with htop and it happens every few minutes, 'apache2' process is using it. Site becomes unresponsive. I tried to restart apache several times but it didn't help. However, after server reboot CPU is back to normal and mostly below 2% usage. Another issue is the memory. After server reboot memory consumption is 25%. After some time it goes up to 85%. I have a controller that calls subprocess.Popen and sometimes it doesn't work because of Cannot allocate memory. This makes the memory consumption an issue. It seems that only apache memory is growing (still using htop to check it). I am not an apache expert and not sure what to do. I can provide additional details if needed. I hope someone can help :) Marin -- --
[web2py] Re: Trunk, error after login
The problem is that auth stores itself in session (session.auth = auth) Now sure why this worked before. Massimo On Friday, 19 October 2012 14:02:35 UTC-5, Marin Pranjić wrote: I have virtual and lazy fields on auth_user table and I store them in auth on each request. Lazy field is the the issue because I store lambda in auth. I just tried to remove it and it works without it. So, I have: if auth.user: auth.user.something = lambda: ... And this fails. I can live without it but I thought it was safe because auth is filtering the fields, right? Dana petak, 19. listopada 2012. 20:52:15 UTC+2, korisnik Massimo Di Pierro napisao je: Do you have a lazy virtual fields in a table and then store records with the lazy virtual field in the session? On Friday, 19 October 2012 13:26:09 UTC-5, Marin Pranjić wrote: Traceback (most recent call last): File /home/www-data/test-web2py/gluon/main.py, line 561, in wsgibase session._try_store_on_disk(request, response) File /home/www-data/test-web2py/gluon/globals.py, line 703, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex raise TypeError, can't pickle %s objects % base.__name__ TypeError: can't pickle function objects It happens with trunk and 2.1.1 but not with 2.0.9 Marin --
[web2py] Re: CPU and memory issues with apache
What web2py version? What Python version? What apache version? Do you get the leak running with rocket? On Friday, 19 October 2012 12:24:07 UTC-5, Marin Pranjić wrote: Not sure if web2py has anything with this. Could be. First issue is that CPU jumps up to 100%. I am watching it with htop and it happens every few minutes, 'apache2' process is using it. Site becomes unresponsive. I tried to restart apache several times but it didn't help. However, after server reboot CPU is back to normal and mostly below 2% usage. Another issue is the memory. After server reboot memory consumption is 25%. After some time it goes up to 85%. I have a controller that calls subprocess.Popen and sometimes it doesn't work because of Cannot allocate memory. This makes the memory consumption an issue. It seems that only apache memory is growing (still using htop to check it). I am not an apache expert and not sure what to do. I can provide additional details if needed. I hope someone can help :) Marin --
Re: [web2py] how to loop through tables with 1M records?
I'm afraid, limitby will not work, since it returns limited set, and I guess it's not possible to dynamically change the limit, so I'll have to sort of loop through some kind of subqueries, or use the original query with limited set of fields (takes 60secs for 700k records, not ready to test on 2-3M records), insert them into scheduler and then let scheduler deal with updating full records in it's own time :) Will try now using cacheable=True. I know I sound like a kid in a candy store, and I'm not patronizing, but truly love scheduler... Reminds me of 8 years ago working with FileNet Visual Workflow :) On Fri, Oct 19, 2012 at 2:51 PM, Niphlod niph...@gmail.com wrote: the set returned by select is always a full result set, because it is extracted and parsed alltogether. Slicing with limits is good (and recommended, if possible). Just remember that you can save a lot of time and memory passing cacheable=True to the select() function. References will be stripped off the normal Rows record, as long as other convenience functions like update_record and delete_record. If you can live without those, for large queries I'd go with select(cacheable=True) all the time On Friday, October 19, 2012 8:17:38 PM UTC+2, Adi wrote: Thank you Vasile for your quick response. This will be perfect. On Friday, October 19, 2012 2:02:41 PM UTC-4, Vasile Ermicioi wrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).**select(limitby=(0,_items_per_**page), orderby=db.table.id): #do something _last_id = row.id -- --
Re: [web2py] how to loop through tables with 1M records?
_last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id have you tried it and it doesn't work? do you understand the logic? --
Re: [web2py] how to loop through tables with 1M records?
increase _items_per_page to 20 000 --
[web2py] pep8
It was pointed out by our friend Andriy that web2py has poor pep8 compliance. So we made a huge number of changes to make it more compliant. We changed every .py file in web2py using an automated tool (autopep8) except feedparser, simplejson, fpdf and pyrpf (third party modules). It now passes all tests. Yet I want to release 2.1.2 asap and it would be great if you could check out the code in trunk and confirm it still works for you. massimo --
Re: [web2py] how to loop through tables with 1M records?
Yes Vasile, I tried, and understand the logic... May change it slightly and use it as subquery with an offset. The problem is that I'm dealing with legacy tables that go up to 3 million rows, and have lot of columns that need to be checked, so your solution will work, and I will be loading data in sets with changed limitby(min, max)... Thank you very much for your help! On Fri, Oct 19, 2012 at 3:30 PM, Vasile Ermicioi elff...@gmail.com wrote: increase _items_per_page to 20 000 -- --
Re: [web2py] how to loop through tables with 1M records?
_last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id you don;t need to change anything to load all data, this code is loading everything in slices as you need, all records are ordered by id, and next query will load all next _items_per_page items db.table.id_last_id - will skip all previous records --
Re: [web2py] Re: tags and speed
should i use .select(..., cacheable=True) or cache.disk('games',lambda:games what is the difference? andrej On Friday, October 19, 2012 1:20:08 PM UTC+2, andrej burja wrote: hi Thank you for your explanation. It is really helpful The address of the chapter in the book is Efficient search by tag and i choose this approach because i thought that search would be the most important thing of the application (that was right) The table tag is similar like in your example 2, but only one tag per row, so: game_id tag 1 excitement 1 funny I learned some lessons: - do usability testing ass soon as possible (it came as a surprise for me that using Datatables is the most useful) - be prepared for lots of data: my initial assumption was 200 games, and now i have more than 1000. I will try with cache first. andrej On Friday, October 19, 2012 1:21:37 AM UTC+2, Niphlod wrote: old mean bad thing about normalized vs denormalized model. Don't know what you read in the cookbok, but here's the thing. You have a game pacman that is tagged as arcade, and a game invaders tagged as horror First things first: you may want to change horror to needs parent around later in the future. That's why you may want to create an external tags table and reference it in your games one. tags table 1 arcade 2 horror game_name tags pacman 1 invaders 2 To display pacman arcade invaders horror you just need a simple join. Changing record 2 of the tags table allows you to have pacman arcade invaders needs parents around Next problem on the line: you want multiple tags for a single game (invaders needs both arcade and horror tags). Welcome to normalization hell. Books have been written about it in the last 60-70 years, with terms like 3NF and Cardinality all around ^_^ Let's take this by examples 1) you change the tags table like this id tag_name game_id 1 arcade 1 1 arcade 2 2 horror 2 getting tags for a single game is fast, change horror to needs parents around is fast, getting all possible tags is enough fast (depending on the number of rows of the tags table) but fetch the right tags for every game can be slow 2) you create a games table like this id game_name tags 1 pacman |arcade| 2 invaders |arcade|horror| getting tags for a single game is fast, updating a tag for a game is quite fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow 3) you create a games table like this id game_name tags_id 1 pacman |1| 2 invaders |1|2| getting tags for a single game is fast, updating a tag for a game is quite fast, changing horrors is fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow So, with no need to change tag names from horror to needs parents around, I'd say the right way for displaying your table is 2) (list:string), else 3) (list:reference). If you need to suggest previously entered tags (i.e. you don't want to end having arcade, arcady, arcadian, 'rcade spat all around), I'd still go for 2) + one separate table (or a cached list) holding all previously entered tags, just to speedup the suggestion phase (hoping users won't screw up). Method 1) is faster only when: - tags are more than the games - cleaning normalization logics are heavy - you need to update tag names often - the only need is displaying tags for a single game (direct query on a single table, the tags one) - you need to compute something like how many times the arcade tag is applied to all my games (i.e. for a tag cloud) There are several other methods, and all of them in the end do the job. You just need to see what are your requirements and choose carefully. Your agenda is: - spend the less time possible with queries you have to invoke often - pay the price of your model in high computations for other things (or, let's save the results of those computations externally once every hour) --
[web2py] Re: There were changes in MS SQLServer driver?
El viernes, 19 de octubre de 2012 15:48:26 UTC-3, Massimo Di Pierro escribió: So, is the issue closed? Yes. Jose --
[web2py] Version 2.1.1 error: Table' object has no attribute '_id'
My app was working fine with Version 1.99.2. I upgrade to Version 2.1.1 and it shows this error. I'm using DB2 for my database. PDTFF is new table defined by web2py so it has id field but the others are existing and doesn't have id field. *Traceback (most recent call last):* File C:\web2py\gluon\restricted.py, line 209, in restricted exec ccode in environment File C:/web2py/applications/fedex/controllers/default.py, line 205, in module File C:\web2py\gluon\globals.py, line 187, in lambda self._caller = lambda f: f() File C:\web2py\gluon\tools.py, line 2838, in f return action(*a, **b) File C:/web2py/applications/fedex/controllers/default.py, line 116, in next form = SQLFORM(db.PDTFF,record) File C:\web2py\gluon\sqlhtml.py, line 1038, in __init__ inp = self.widgets.options.widget(field, default) File C:\web2py\gluon\sqlhtml.py, line 226, in widget options = requires[0].options() File C:\web2py\gluon\validators.py, line 2500, in _options options = self.other.options() File C:\web2py\gluon\validators.py, line 484, in options self.build_set() File C:\web2py\gluon\validators.py, line 471, in build_set records = self.dbset(table).select(*fields, **dd) File C:\web2py\gluon\dal.py, line 8726, in __call__ query = self.db._adapter.id_query(query) File C:\web2py\gluon\dal.py, line 631, in id_query return table._id != None File C:\web2py\gluon\dal.py, line 7636, in __getitem__ return ogetattr(self, str(key)) AttributeError: 'Table' object has no attribute '_id' *Function argument list* (self=Table TDMKNP00 (KNCTCD,KNKNCD,KNKNNM), key='_id') *Model* # coding: utf8 # Employee info table on HELPDESK dbh.define_table('tbluser', Field('name', length=255), Field('location', length=255), Field('emailaddress', length=255)) # Dept Master db.define_table('TDMBUP01', Field('BUSEC1', length=3), Field('BUBURK', length=12), primarykey=['BUSEC1']) # Country Master db.define_table('TDMCNP00', Field('CNCNCD', length=3), Field('CNCNNM', length=30), primarykey=['CNCNCD']) # Area 2 Master db.define_table('TDMKNP00', Field('KNCTCD', length=3), Field('KNKNCD', length=2), Field('KNKNNM', length=30), primarykey=['KNCTCD','KNKNCD']) # Purchase Order db.define_table('SDTH2P01', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Open FedEx Purchase Order db.define_table('SDTH2PF1', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Received Order db.define_table('SDTJ2P00', Field('J2DNO', length=8), Field('J2GNO', 'integer'), Field('J2TSCD',length=8), Field('J2TSK1',length=35), Field('J2TSK2',length=35), Field('J2TSPE',length=22), Field('J2ODA1',length=30), Field('J2ODA2',length=30), Field('J2ODA7',length=20), Field('J2KNCD',length=2), Field('J2CNCD',length=3), Field('J2OYUB',length=10), Field('J2OTEL',length=20), Field('J2KYSC',length=12), Field('J2NSD','integer'), primarykey=['J2DNO','J2GNO']) # FedEx Request Output file db.define_table('PDTFF', Field('FFDNO', length=8, label='HJ#'), Field('FFTRD', 'date', label=Requested), Field('FFJCSC', length=3, label=Dept), Field('FFBURK', length=12, label=Dept Name), Field('FFJDNO', length=8, label=JJ#), Field('FFJGNO', 'integer', label=JJ line#), Field('FFJJDN', length=8, label=J# (JP)), Field('FFJJGN', 'integer', label=J line# (JP)), Field('FFACCT', length=9, label=FedEx Acct #), Field('FFCUST', length=30, label=Company Name), Field('FFNSD', 'date',label=Delivery Due), Field('FFPRCD', length=15,label=Product Code), Field('FFPRKJ', length=50,label=Part Number), Field('FFTRS', 'integer',label=Quantity), Field('FFTSK1',length=35,label=Name 1), Field('FFTSK2',length=35,label=Name 2), Field('FFTSPE',length=22,label=Attn:), Field('FFODA1',length=30,label=Address 1), Field('FFODA2',length=30,label=Adderss 2), Field('FFODA7',length=20,label=City), Field('FFKNCD',length=2,label=State), Field('FFCNCD',length=3,label=Country), Field('FFOYUB',length=10,label=Zip), Field('FFOTEL',length=20,label=Phone), Field('FFKYSC',length=12,label=Customer Order#),
[web2py] Re: Ajax / cid with A helper not working
I dropped the user_signature. Now it looks like: a href=/testapp/view/2 onclick=web2py_component(quot;/testapp/view/2quot;,quot;post1234quot;);return false; Title Title Title /a Still doesn't work. I'm on Version 2.0.9 (2012-09-17 21:37:10) stable. On Friday, October 19, 2012 9:51:52 PM UTC+8, Niphlod wrote: yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cidin more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] Re: Version 2.1.1 error: Table' object has no attribute '_id'
It looks this line failed. Here I simply edit the record provided by user's select. form = SQLFORM(db.PDTFF,record) On Friday, October 19, 2012 3:27:53 PM UTC-5, Omi Chiba wrote: My app was working fine with Version 1.99.2. I upgrade to Version 2.1.1 and it shows this error. I'm using DB2 for my database. PDTFF is new table defined by web2py so it has id field but the others are existing and doesn't have id field. *Traceback (most recent call last):* File C:\web2py\gluon\restricted.py, line 209, in restricted exec ccode in environment File C:/web2py/applications/fedex/controllers/default.py, line 205, in module File C:\web2py\gluon\globals.py, line 187, in lambda self._caller = lambda f: f() File C:\web2py\gluon\tools.py, line 2838, in f return action(*a, **b) File C:/web2py/applications/fedex/controllers/default.py, line 116, in next form = SQLFORM(db.PDTFF,record) File C:\web2py\gluon\sqlhtml.py, line 1038, in __init__ inp = self.widgets.options.widget(field, default) File C:\web2py\gluon\sqlhtml.py, line 226, in widget options = requires[0].options() File C:\web2py\gluon\validators.py, line 2500, in _options options = self.other.options() File C:\web2py\gluon\validators.py, line 484, in options self.build_set() File C:\web2py\gluon\validators.py, line 471, in build_set records = self.dbset(table).select(*fields, **dd) File C:\web2py\gluon\dal.py, line 8726, in __call__ query = self.db._adapter.id_query(query) File C:\web2py\gluon\dal.py, line 631, in id_query return table._id != None File C:\web2py\gluon\dal.py, line 7636, in __getitem__ return ogetattr(self, str(key)) AttributeError: 'Table' object has no attribute '_id' *Function argument list* (self=Table TDMKNP00 (KNCTCD,KNKNCD,KNKNNM), key='_id') *Model* # coding: utf8 # Employee info table on HELPDESK dbh.define_table('tbluser', Field('name', length=255), Field('location', length=255), Field('emailaddress', length=255)) # Dept Master db.define_table('TDMBUP01', Field('BUSEC1', length=3), Field('BUBURK', length=12), primarykey=['BUSEC1']) # Country Master db.define_table('TDMCNP00', Field('CNCNCD', length=3), Field('CNCNNM', length=30), primarykey=['CNCNCD']) # Area 2 Master db.define_table('TDMKNP00', Field('KNCTCD', length=3), Field('KNKNCD', length=2), Field('KNKNNM', length=30), primarykey=['KNCTCD','KNKNCD']) # Purchase Order db.define_table('SDTH2P01', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Open FedEx Purchase Order db.define_table('SDTH2PF1', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Received Order db.define_table('SDTJ2P00', Field('J2DNO', length=8), Field('J2GNO', 'integer'), Field('J2TSCD',length=8), Field('J2TSK1',length=35), Field('J2TSK2',length=35), Field('J2TSPE',length=22), Field('J2ODA1',length=30), Field('J2ODA2',length=30), Field('J2ODA7',length=20), Field('J2KNCD',length=2), Field('J2CNCD',length=3), Field('J2OYUB',length=10), Field('J2OTEL',length=20), Field('J2KYSC',length=12), Field('J2NSD','integer'), primarykey=['J2DNO','J2GNO']) # FedEx Request Output file db.define_table('PDTFF', Field('FFDNO', length=8, label='HJ#'), Field('FFTRD', 'date', label=Requested), Field('FFJCSC', length=3, label=Dept), Field('FFBURK', length=12, label=Dept Name), Field('FFJDNO', length=8, label=JJ#), Field('FFJGNO', 'integer', label=JJ line#), Field('FFJJDN', length=8, label=J# (JP)), Field('FFJJGN', 'integer', label=J line# (JP)), Field('FFACCT', length=9, label=FedEx Acct #), Field('FFCUST', length=30, label=Company Name), Field('FFNSD', 'date',label=Delivery Due), Field('FFPRCD', length=15,label=Product Code), Field('FFPRKJ', length=50,label=Part Number), Field('FFTRS', 'integer',label=Quantity), Field('FFTSK1',length=35,label=Name 1), Field('FFTSK2',length=35,label=Name 2), Field('FFTSPE',length=22,label=Attn:), Field('FFODA1',length=30,label=Address 1),
Re: [web2py] how to loop through tables with 1M records?
i put it exactly as it is, but it stopped working after 1000 records... will double check again. On Fri, Oct 19, 2012 at 3:47 PM, Vasile Ermicioi elff...@gmail.com wrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id you don;t need to change anything to load all data, this code is loading everything in slices as you need, all records are ordered by id, and next query will load all next _items_per_page items db.table.id_last_id - will skip all previous records -- --
Re: [web2py] how to loop through tables with 1M records?
also _last_id = row.id after your code inside the loop is required --
Re: [web2py] how to loop through tables with 1M records?
it's missing the outer loop. _last_id = 0 _items_per_page=1000 while True: rows = db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id) if len(rows) == 0: break for row in rows: #do something _last_id = row.id Should work. On Friday, October 19, 2012 10:52:06 PM UTC+2, Adi wrote: i put it exactly as it is, but it stopped working after 1000 records... will double check again. On Fri, Oct 19, 2012 at 3:47 PM, Vasile Ermicioi elf...@gmail.comjavascript: wrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id you don;t need to change anything to load all data, this code is loading everything in slices as you need, all records are ordered by id, and next query will load all next _items_per_page items db.table.id_last_id - will skip all previous records -- --
[web2py] Re: Ajax / cid with A helper not working
Right now I can't switch to 2.0.9 . Can you try current trunk ? On Friday, October 19, 2012 10:44:33 PM UTC+2, lyn2py wrote: I dropped the user_signature. Now it looks like: a href=/testapp/view/2 onclick=web2py_component(quot;/testapp/view/2quot;,quot;post1234quot;);return false; Title Title Title /a Still doesn't work. I'm on Version 2.0.9 (2012-09-17 21:37:10) stable. On Friday, October 19, 2012 9:51:52 PM UTC+8, Niphlod wrote: yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cidin more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] Re: Ajax / cid with A helper not working
My results on the latest git clone, Version 2.1.1 (2012-10-19 14:59:27) dev --- The same as before. the quotation marks are still quot; In addition, I have lost my dropdown menus (response.menu). I thought maybe I created a new app on the trunk and ported over all my controllers, models, database, views. But still have the above 2 not working (the cid and the dropdown menus) On Saturday, October 20, 2012 5:13:09 AM UTC+8, Niphlod wrote: Right now I can't switch to 2.0.9 . Can you try current trunk ? On Friday, October 19, 2012 10:44:33 PM UTC+2, lyn2py wrote: I dropped the user_signature. Now it looks like: a href=/testapp/view/2 onclick=web2py_component(quot;/testapp/view/2quot;,quot;post1234quot;);return false; Title Title Title /a Still doesn't work. I'm on Version 2.0.9 (2012-09-17 21:37:10) stable. On Friday, October 19, 2012 9:51:52 PM UTC+8, Niphlod wrote: yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cidin more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] Re: Version 2.1.1 error: Table' object has no attribute '_id'
It worked when I specified single prymarykey. It's kind of make sense but why it worked previously and not working current? db.PDTFF.FFKNCD.requires=IS_NULL_OR(IS_IN_DB(db,db.TDMKNP00.KNKNCD,'%(KNKNNM)s')) *After* # Area 2 Master db.define_table('TDMKNP00', Field('KNCTCD', length=3), Field('KNKNCD', length=2), Field('KNKNNM', length=30), primarykey=['KNKNCD']) *Before* # Area 2 Master db.define_table('TDMKNP00', Field('KNCTCD', length=3), Field('KNKNCD', length=2), Field('KNKNNM', length=30), primarykey=['KNCTCD','KNKNCD']) On Friday, October 19, 2012 3:48:53 PM UTC-5, Omi Chiba wrote: It looks this line failed. Here I simply edit the record provided by user's select. form = SQLFORM(db.PDTFF,record) On Friday, October 19, 2012 3:27:53 PM UTC-5, Omi Chiba wrote: My app was working fine with Version 1.99.2. I upgrade to Version 2.1.1 and it shows this error. I'm using DB2 for my database. PDTFF is new table defined by web2py so it has id field but the others are existing and doesn't have id field. *Traceback (most recent call last):* File C:\web2py\gluon\restricted.py, line 209, in restricted exec ccode in environment File C:/web2py/applications/fedex/controllers/default.py, line 205, in module File C:\web2py\gluon\globals.py, line 187, in lambda self._caller = lambda f: f() File C:\web2py\gluon\tools.py, line 2838, in f return action(*a, **b) File C:/web2py/applications/fedex/controllers/default.py, line 116, in next form = SQLFORM(db.PDTFF,record) File C:\web2py\gluon\sqlhtml.py, line 1038, in __init__ inp = self.widgets.options.widget(field, default) File C:\web2py\gluon\sqlhtml.py, line 226, in widget options = requires[0].options() File C:\web2py\gluon\validators.py, line 2500, in _options options = self.other.options() File C:\web2py\gluon\validators.py, line 484, in options self.build_set() File C:\web2py\gluon\validators.py, line 471, in build_set records = self.dbset(table).select(*fields, **dd) File C:\web2py\gluon\dal.py, line 8726, in __call__ query = self.db._adapter.id_query(query) File C:\web2py\gluon\dal.py, line 631, in id_query return table._id != None File C:\web2py\gluon\dal.py, line 7636, in __getitem__ return ogetattr(self, str(key)) AttributeError: 'Table' object has no attribute '_id' *Function argument list* (self=Table TDMKNP00 (KNCTCD,KNKNCD,KNKNNM), key='_id') *Model* # coding: utf8 # Employee info table on HELPDESK dbh.define_table('tbluser', Field('name', length=255), Field('location', length=255), Field('emailaddress', length=255)) # Dept Master db.define_table('TDMBUP01', Field('BUSEC1', length=3), Field('BUBURK', length=12), primarykey=['BUSEC1']) # Country Master db.define_table('TDMCNP00', Field('CNCNCD', length=3), Field('CNCNNM', length=30), primarykey=['CNCNCD']) # Area 2 Master db.define_table('TDMKNP00', Field('KNCTCD', length=3), Field('KNKNCD', length=2), Field('KNKNNM', length=30), primarykey=['KNCTCD','KNKNCD']) # Purchase Order db.define_table('SDTH2P01', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Open FedEx Purchase Order db.define_table('SDTH2PF1', Field('H2DNO', length=8), Field('H2TRD1', 'integer'), Field('H2JJDN', length=8), Field('H2JJGN', 'integer'), Field('H2JDNO', length=8), Field('H2JGNO', 'integer'), Field('H2JCSC', length=3), Field('H2HSKB', length=1), Field('H2KSM', length=3), Field('H2PRCD', length=15), Field('H2PRKJ', length=50), Field('H2TRS', 'integer'), Field('H2HZS', 'integer'), primarykey=['H2DNO']) # Received Order db.define_table('SDTJ2P00', Field('J2DNO', length=8), Field('J2GNO', 'integer'), Field('J2TSCD',length=8), Field('J2TSK1',length=35), Field('J2TSK2',length=35), Field('J2TSPE',length=22), Field('J2ODA1',length=30), Field('J2ODA2',length=30), Field('J2ODA7',length=20), Field('J2KNCD',length=2), Field('J2CNCD',length=3), Field('J2OYUB',length=10), Field('J2OTEL',length=20), Field('J2KYSC',length=12), Field('J2NSD','integer'), primarykey=['J2DNO','J2GNO']) # FedEx Request Output file db.define_table('PDTFF', Field('FFDNO', length=8, label='HJ#'), Field('FFTRD', 'date', label=Requested), Field('FFJCSC', length=3, label=Dept), Field('FFBURK', length=12, label=Dept Name), Field('FFJDNO', length=8, label=JJ#),
Re: [web2py] Re: tags and speed
.select(..., cacheable=True) does not cache anything. It just generates a simpler Rows object without methods and without a link to db. .select(, cache=(cache.ram,3600)) does the caching. On Friday, 19 October 2012 15:06:06 UTC-5, andrej burja wrote: should i use .select(..., cacheable=True) or cache.disk('games',lambda:games what is the difference? andrej On Friday, October 19, 2012 1:20:08 PM UTC+2, andrej burja wrote: hi Thank you for your explanation. It is really helpful The address of the chapter in the book is Efficient search by tag and i choose this approach because i thought that search would be the most important thing of the application (that was right) The table tag is similar like in your example 2, but only one tag per row, so: game_id tag 1 excitement 1 funny I learned some lessons: - do usability testing ass soon as possible (it came as a surprise for me that using Datatables is the most useful) - be prepared for lots of data: my initial assumption was 200 games, and now i have more than 1000. I will try with cache first. andrej On Friday, October 19, 2012 1:21:37 AM UTC+2, Niphlod wrote: old mean bad thing about normalized vs denormalized model. Don't know what you read in the cookbok, but here's the thing. You have a game pacman that is tagged as arcade, and a game invaders tagged as horror First things first: you may want to change horror to needs parent around later in the future. That's why you may want to create an external tags table and reference it in your games one. tags table 1 arcade 2 horror game_name tags pacman 1 invaders 2 To display pacman arcade invaders horror you just need a simple join. Changing record 2 of the tags table allows you to have pacman arcade invaders needs parents around Next problem on the line: you want multiple tags for a single game (invaders needs both arcade and horror tags). Welcome to normalization hell. Books have been written about it in the last 60-70 years, with terms like 3NF and Cardinality all around ^_^ Let's take this by examples 1) you change the tags table like this id tag_name game_id 1 arcade 1 1 arcade 2 2 horror 2 getting tags for a single game is fast, change horror to needs parents around is fast, getting all possible tags is enough fast (depending on the number of rows of the tags table) but fetch the right tags for every game can be slow 2) you create a games table like this id game_name tags 1 pacman |arcade| 2 invaders |arcade|horror| getting tags for a single game is fast, updating a tag for a game is quite fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow 3) you create a games table like this id game_name tags_id 1 pacman |1| 2 invaders |1|2| getting tags for a single game is fast, updating a tag for a game is quite fast, changing horrors is fast but changing all horror to needs parents around can be fast only if done outside web2py with a manual replace, getting all possible tags can be slow So, with no need to change tag names from horror to needs parents around, I'd say the right way for displaying your table is 2) (list:string), else 3) (list:reference). If you need to suggest previously entered tags (i.e. you don't want to end having arcade, arcady, arcadian, 'rcade spat all around), I'd still go for 2) + one separate table (or a cached list) holding all previously entered tags, just to speedup the suggestion phase (hoping users won't screw up). Method 1) is faster only when: - tags are more than the games - cleaning normalization logics are heavy - you need to update tag names often - the only need is displaying tags for a single game (direct query on a single table, the tags one) - you need to compute something like how many times the arcade tag is applied to all my games (i.e. for a tag cloud) There are several other methods, and all of them in the end do the job. You just need to see what are your requirements and choose carefully. Your agenda is: - spend the less time possible with queries you have to invoke often - pay the price of your model in high computations for other things (or, let's save the results of those computations externally once every hour) --
[web2py] Custom import creates module name conflicts (2.1.1)
I upgraded to v 2.1.1 and now see problems with module name conflicts due to the custom importer. Previously I used v2.0.9 without problems. I have a custom application module named utils.py. This appears to conflict with the gluon.utils module. I was able to simulate using the basic web2py zip file and then creating a simple module applications/welcome/modules/utils.py. When I access the welcome default page, I get this error: Traceback (most recent call last): File /root/tmp/web2py/web2py/gluon/restricted.py, line 209, in restricted exec ccode in environment File /root/tmp/web2py/web2py/applications/welcome/models/db.py, line 42, in from gluon.tools import Auth, Crud, Service, PluginManager, prettydate File /root/tmp/web2py/web2py/gluon/custom_import.py, line 89, in custom_importer return NATIVE_IMPORTER(name,globals,locals,fromlist,level) File /root/tmp/web2py/web2py/gluon/tools.py, line 30, in from utils import web2py_uuid ImportError: cannot import name web2py_uuid I disabled the custom importer by issuing a return immediately in gluon/custom_import.py def custom_import_install() and the problem goes away. I can also correct this specific issue if I change this line in gluon/tools.py -from utils import web2py_uuid +from gluon.utils import web2py_uuid This last change works, but it isn't a complete solution. For example, in another application I have a constants.py module. It is conflicting with a constants module MySQLdb makes use of. Deep in the code of MySQLdb there is a line: from constants import CLIENT, FIELD_TYPE That import fails as it tries to find those classes in my custom module. I can always rename my custom module, but this becomes a cat and mouse game. I can't know every module name already in use. Any suggestions for this? It's a bit of a show stopper for me. Perhaps an option should be available to disable the custom importer. --
[web2py] Admin Mobile Interface
I may be slow to catch up on this, since I have *just* upgraded to 2.1.1 (trunk)... but I had to say it! The admin mobile interface is very cool! I haven't played with all the features yet though. Working great as far as I can see. Thank you guys! --
[web2py] Re: Admin Mobile Interface
On this point, can we have a button on the mobile interface to 'switch' back to the web interface? On Saturday, October 20, 2012 6:02:16 AM UTC+8, lyn2py wrote: I may be slow to catch up on this, since I have *just* upgraded to 2.1.1 (trunk)... but I had to say it! The admin mobile interface is very cool! I haven't played with all the features yet though. Working great as far as I can see. Thank you guys! --
[web2py] Re: Ajax / cid with A helper not working
something is off with your controller. Try to post a minimalist app to reproduce the problem, I can't simulate your issue. On Friday, October 19, 2012 11:35:51 PM UTC+2, lyn2py wrote: My results on the latest git clone, Version 2.1.1 (2012-10-19 14:59:27) dev --- The same as before. the quotation marks are still quot; In addition, I have lost my dropdown menus (response.menu). I thought maybe I created a new app on the trunk and ported over all my controllers, models, database, views. But still have the above 2 not working (the cid and the dropdown menus) On Saturday, October 20, 2012 5:13:09 AM UTC+8, Niphlod wrote: Right now I can't switch to 2.0.9 . Can you try current trunk ? On Friday, October 19, 2012 10:44:33 PM UTC+2, lyn2py wrote: I dropped the user_signature. Now it looks like: a href=/testapp/view/2 onclick=web2py_component(quot;/testapp/view/2quot;,quot;post1234quot;);return false; Title Title Title /a Still doesn't work. I'm on Version 2.0.9 (2012-09-17 21:37:10) stable. On Friday, October 19, 2012 9:51:52 PM UTC+8, Niphlod wrote: yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cidin more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
Re: [web2py] web2py.com is down
Seems up for me On Saturday, October 20, 2012 2:52:15 AM UTC+8, Francisco Costa wrote: confirm, web2py.com is down On Friday, October 19, 2012 7:48:25 PM UTC+1, Richard wrote: As in the object Richard --
[web2py] Re: Removing need for first and last name in auth
The issue says fixed, so am I to understand there's now a way to customize the auth.navbar Welcome message that hasn't been documented yet or was this simply a fix for the breakage issues? On Monday, January 30, 2012 6:51:45 AM UTC-8, Anthony wrote: On Sunday, January 29, 2012 7:36:07 PM UTC-5, HittingSmoke wrote: I'd like to use auth with only a username instead of first and last name. I defined my own tables without a first and last name but it still causes issues throughout the app. For instance, when I try to use appadmin to add a user to a new auth group I get an error (type 'exceptions.KeyError' 'first_name') if there is no first and last name fields in the database. If I create them but make them unreadable and unwritable the page will load but all of the entries in the User ID dropdown say None None (user ID #). The default validator for auth_permission.user_id and auth_event.user_id is: IS_IN_DB(db, '%s.id' % settings.table_user_name, '%(first_name)s %(last_name)s (%(id)s)') After calling auth.define_tables(), you can change those to: db.auth_permission.user_id.requires = IS_IN_DB(db, '%s.id' % settings.table_user_name, '%(username)s (%(id)s)') Perhaps this should happen automatically when the first_name and last_name fields are not included in auth_user. The auth Welcome bar is also fixed to the first name field and if not used it will says Welcome, None. You can easily replace the navbar by removing auth.navbar from the layout.html view and replacing it with a custom navbar. However, we should make auth.navbar more customizable. Please open an issue ( http://code.google.com/p/web2py/issues/list) and reference this thread. Anthony --
[web2py] trunk - 404 not found
for this url, http://127.0.0.1:8000/fermer/default/user/login but works fine with 1.99.4 --
[web2py] Re: Custom import creates module name conflicts (2.1.1)
Good catch. Fixed in trunk On Friday, 19 October 2012 16:54:54 UTC-5, Jim Karsten wrote: I upgraded to v 2.1.1 and now see problems with module name conflicts due to the custom importer. Previously I used v2.0.9 without problems. I have a custom application module named utils.py. This appears to conflict with the gluon.utils module. I was able to simulate using the basic web2py zip file and then creating a simple module applications/welcome/modules/utils.py. When I access the welcome default page, I get this error: Traceback (most recent call last): File /root/tmp/web2py/web2py/gluon/restricted.py, line 209, in restricted exec ccode in environment File /root/tmp/web2py/web2py/applications/welcome/models/db.py, line 42, in from gluon.tools import Auth, Crud, Service, PluginManager, prettydate File /root/tmp/web2py/web2py/gluon/custom_import.py, line 89, in custom_importer return NATIVE_IMPORTER(name,globals,locals,fromlist,level) File /root/tmp/web2py/web2py/gluon/tools.py, line 30, in from utils import web2py_uuid ImportError: cannot import name web2py_uuid I disabled the custom importer by issuing a return immediately in gluon/custom_import.py def custom_import_install() and the problem goes away. I can also correct this specific issue if I change this line in gluon/tools.py -from utils import web2py_uuid +from gluon.utils import web2py_uuid This last change works, but it isn't a complete solution. For example, in another application I have a constants.py module. It is conflicting with a constants module MySQLdb makes use of. Deep in the code of MySQLdb there is a line: from constants import CLIENT, FIELD_TYPE That import fails as it tries to find those classes in my custom module. I can always rename my custom module, but this becomes a cat and mouse game. I can't know every module name already in use. Any suggestions for this? It's a bit of a show stopper for me. Perhaps an option should be available to disable the custom importer. --
[web2py] Re: Admin Mobile Interface
I assume you mean in the mobile admin demo. I just added as you suggested. Good idea. On Friday, 19 October 2012 17:20:28 UTC-5, lyn2py wrote: On this point, can we have a button on the mobile interface to 'switch' back to the web interface? On Saturday, October 20, 2012 6:02:16 AM UTC+8, lyn2py wrote: I may be slow to catch up on this, since I have *just* upgraded to 2.1.1 (trunk)... but I had to say it! The admin mobile interface is very cool! I haven't played with all the features yet though. Working great as far as I can see. Thank you guys! --
Re: [web2py] web2py.com is down
It was down but probably a network issue since I could not connect with ssh either. On Friday, 19 October 2012 18:07:46 UTC-5, Luther Goh Lu Feng wrote: Seems up for me On Saturday, October 20, 2012 2:52:15 AM UTC+8, Francisco Costa wrote: confirm, web2py.com is down On Friday, October 19, 2012 7:48:25 PM UTC+1, Richard wrote: As in the object Richard --
Re: [web2py] I am looking for specifics : how to db.define_table in sub directories in the MODELS directory !
Definitely clearer ! ... Thanks a bunch guys ! ... in conclusion : whenever one decides to do the conditional model approach for performance concerns or else ... database tables better be defined first ! even more so if there are reference fields in the tables involved! in which case a table creation logic would need to be in place prior to the deployment of a conditional model scheme ! --
[web2py] Re: pep8
Things appear alright after a quick test drive of trunk here. ~Brian On Friday, October 19, 2012 2:31:31 PM UTC-5, Massimo Di Pierro wrote: It was pointed out by our friend Andriy that web2py has poor pep8 compliance. So we made a huge number of changes to make it more compliant. We changed every .py file in web2py using an automated tool (autopep8) except feedparser, simplejson, fpdf and pyrpf (third party modules). It now passes all tests. Yet I want to release 2.1.2 asap and it would be great if you could check out the code in trunk and confirm it still works for you. massimo --
Re: [web2py] how to loop through tables with 1M records?
Does work. Thank you both very much! Now that I have thousands of queued/backlogged tasks in a scheduler, I noticed that my regular tasks, which are of higher priority will be on hold until everything else gets processed. Maybe, it would be a good idea to have a field for a priority of a task? (just a thought) On Fri, Oct 19, 2012 at 5:11 PM, Niphlod niph...@gmail.com wrote: it's missing the outer loop. _last_id = 0 _items_per_page=1000 while True: rows = db(db.table.id_last_id).select(limitby=(0,_items_per_page), orderby=db.table.id) if len(rows) == 0: break for row in rows: #do something _last_id = row.id Should work. On Friday, October 19, 2012 10:52:06 PM UTC+2, Adi wrote: i put it exactly as it is, but it stopped working after 1000 records... will double check again. On Fri, Oct 19, 2012 at 3:47 PM, Vasile Ermicioi elf...@gmail.comwrote: _last_id = 0 _items_per_page=1000 for row in db(db.table.id_last_id).selec**t(limitby=(0,_items_per_page), orderby=db.table.id): #do something _last_id = row.id you don;t need to change anything to load all data, this code is loading everything in slices as you need, all records are ordered by id, and next query will load all next _items_per_page items db.table.id_last_id - will skip all previous records -- -- -- Thanks, Adnan video: http://vimeo.com/24653283 --
[web2py] Re: Ajax / cid with A helper not working
Hi Niphlod, Thanks for the suggestion, I finally figured out what's wrong. I had the code $(document).ready(function()... when that was removed, it worked. On Saturday, October 20, 2012 6:27:01 AM UTC+8, Niphlod wrote: something is off with your controller. Try to post a minimalist app to reproduce the problem, I can't simulate your issue. On Friday, October 19, 2012 11:35:51 PM UTC+2, lyn2py wrote: My results on the latest git clone, Version 2.1.1 (2012-10-19 14:59:27) dev --- The same as before. the quotation marks are still quot; In addition, I have lost my dropdown menus (response.menu). I thought maybe I created a new app on the trunk and ported over all my controllers, models, database, views. But still have the above 2 not working (the cid and the dropdown menus) On Saturday, October 20, 2012 5:13:09 AM UTC+8, Niphlod wrote: Right now I can't switch to 2.0.9 . Can you try current trunk ? On Friday, October 19, 2012 10:44:33 PM UTC+2, lyn2py wrote: I dropped the user_signature. Now it looks like: a href=/testapp/view/2 onclick=web2py_component(quot;/testapp/view/2quot;,quot;post1234quot;);return false; Title Title Title /a Still doesn't work. I'm on Version 2.0.9 (2012-09-17 21:37:10) stable. On Friday, October 19, 2012 9:51:52 PM UTC+8, Niphlod wrote: yep, indeed there seems to be a problem in your rendered link. Can you see if removing user_signature the link works ? On Friday, October 19, 2012 3:41:24 PM UTC+2, lyn2py wrote: I looked up source and pasted it wholesale here: a href=/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47af onclick=web2py_component(quot;/testapp/view/2?_signature=55b3689d7a3d25c3607631da547ad3139b3e47afquot;,quot;post1234quot;);return false;Title Title Title/a It looks like the quotation marks are not appearing correctly? On Friday, October 19, 2012 9:03:24 PM UTC+8, Niphlod wrote: please check that your link is rendered to something like a onclick=web2py_component(/app/default/view/1,post1234);return false; href=/app/default/view/1title/a If that's the case, and it's not working, then something is off with the javascript (this functionality relies on web2py.js loaded). Anyway, this works on the welcome app. On Friday, October 19, 2012 1:03:01 PM UTC+2, lyn2py wrote: I looking at web2py book here: http://web2py.com/books/default/chapter/34/05 Tha A helper takes a special argument called cid. It works as follows: {{=A('linked page', _href='http://example.com', cid='myid')}} div id=myid/div and a click on the link causes the content to be loaded in the div. This is similar but more powerful than the above syntax since it is designed to refresh page components. We discuss applications of cid in more detail in Chapter 12, in the context of components. These ajax features require jQuery and static/js/web2py_ajax.js, which are automatically included by placing {{include 'web2py_ajax.html'}} in the layout head. views/web2py_ajax.html defines some variables based on request and includes all necessary js and css files. Here's what I've done: index page: {{extend layout.html}} p{{=A(post.title, _href=URL('default','view',args=[post.id],user_signature=True), cid='post1234')}}/p div id=post1234/div But when I click on the link, nothing appears in the div id=post1234 /. I didn't make changes to layout.html, which means, web2py_ajax.html is already included. When it is a normal link (aka no cid in the A helper), the page (view) loads fine. --
[web2py] Where does auth.wiki save pages to?
I can't find them in my database... --
Re: [web2py] Re: manage_groups AD problem
Yes that's one am referring to. The moment I introduce the parameter manage_groups users fail to login against AD...this is my sample code: from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods = [ldap_auth(mode='ad', manage_groups= True, bind_dn = 'CN=Admin,DC=example,DC=co,DC= zm', bind_pw = 'ADPASSWORD', group_dn = 'DC= example,DC=co,DC=zm', group_name_attrib = 'cn', group_member_attrib = 'member', group_filterstr = 'objectClass=Group', server='xxx.xxx.xxx.xxx', base_dn='dc=example,dc=co,dc=zm')] Any reason why group management is not working? Is there another way I can use AD users and assign rolls to certain users? Teddy L. On Oct 19, 2012 8:46 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Are you talking about ldap_auth? On Friday, 19 October 2012 02:38:39 UTC-5, software.ted wrote: I am having trouble with manage_group=True, when I enable it i am getting Invalid Login but without it logins work. Does AD Group Management in web2py work? Kind regards, -- --