[web2py] editing afiled when one controller submits a data

2012-10-20 Thread alazar baharu
hello every on e am developing a simple office space management information 
system using web 2py and i get in trouble doing some tasks.
i have a table called office where office information will be saved there 
including office capacity and there is also a table which helps in giving 
office to users 
and what i want is when submitting a data in the office giving table i want 
to decrease one space in the office table record ? but i cant do this is 
there any one who can help me doing this please ?

my controller looks like this 
def create_Response():
form=SQLFORM(db.Response).process()
##here i want to add the code 
if form.accepted:
   response.flash=you have sucessfully reponded to the request
return dict(form=form)

-- 





Re: [web2py] Re: manage_groups AD problem

2012-10-20 Thread szimszon
Could you set ldap_auth's *logging_level* to debug and see (in console) 
what's happening? Or you could specify *allowed_groups*=['some group name'] 
if there a logic error and login  works only with allowed_groups set.

Sorry I have no AD to test. With ldap it works. So I need a bit help...

2012. október 20., szombat 7:44:20 UTC+2 időpontban software.ted a 
következőt írta:

 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@gmail.comjavascript: 
 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, 

  -- 
  
  
  



-- 





[web2py] Re: editing afiled when one controller submits a data

2012-10-20 Thread alazar baharu


On Friday, October 19, 2012 11:50:20 PM UTC-7, alazar baharu wrote:

 hello every on e am developing a simple office space management 
 information system using web 2py and i get in trouble doing some tasks.
 i have a table called office where office information will be saved there 
 including office capacity and there is also a table which helps in giving 
 office to users 
 and what i want is when submitting a data in the office giving table i 
 want to decrease one space in the office table record ? but i cant do this 
 is there any one who can help me doing this please ?

 my controller looks like this 

hello again sorry for posting again my controlers looks like this 
def create_Response():
form=SQLFORM(db.Response).process()
rows=db().select(db.Office.Office_number= Assigned_Office_Number, 
Active=True)
ala= len(rows) - 1
update=crud.update(db.Office, Free_space=ala)
if form.accepted:
   response.flash=you have sucessfully reponded to the request
return dict(form=form, update=update) 

-- 





Re: [web2py] Re: manage_groups AD problem

2012-10-20 Thread Teddy Nyambe
Whr do I set the log level and see how the code is executing I realy need
that for debugging.
On Oct 20, 2012 9:20 AM, szimszon szims...@gmail.com wrote:

 Could you set ldap_auth's *logging_level* to debug and see (in console)
 what's happening? Or you could specify *allowed_groups*=['some group
 name'] if there a logic error and login  works only with allowed_groups set.

 Sorry I have no AD to test. With ldap it works. So I need a bit help...

 2012. október 20., szombat 7:44:20 UTC+2 időpontban software.ted a
 következőt írta:

 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@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,

  --




  --





-- 





Re: [web2py] Re: manage_groups AD problem

2012-10-20 Thread szimszon

ldap_auth(...as usual...,logging_level='debug')

2012. október 20., szombat 9:29:44 UTC+2 időpontban software.ted a 
következőt írta:

 Whr do I set the log level and see how the code is executing I realy need 
 that for debugging.
 On Oct 20, 2012 9:20 AM, szimszon szim...@gmail.com javascript: 
 wrote:

 Could you set ldap_auth's *logging_level* to debug and see (in console) 
 what's happening? Or you could specify *allowed_groups*=['some group 
 name'] if there a logic error and login  works only with allowed_groups set.

 Sorry I have no AD to test. With ldap it works. So I need a bit help...

 2012. október 20., szombat 7:44:20 UTC+2 időpontban software.ted a 
 következőt írta:

 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@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, 

  -- 
  
  
  

  -- 
  
  
  



-- 





[web2py] Re: fake_migrate help

2012-10-20 Thread lyn2py
I performed as Massimo's suggestion,
fake_migrate_all=True,migrate_enabled=True

But I ran into an Internal Error: Unknown. (no ticket).



On Thursday, October 18, 2012 8:17:23 PM UTC+8, Massimo Di Pierro wrote:

 You mean you do not see the .table files?

 Try:
 fake_migrate_all=True,migrate_enabled=True
 could be an error in the book.

 On Thursday, 18 October 2012 01:29:42 UTC-5, lyn2py wrote:

 Hello all, something went wrong with the database table files, and they 
 were accidentally completely removed (the whole database folder).

 I need to rebuild all the database files, so I did:
 db = DAL('postgres://',fake_migrate_all=True,migrate_enabled=
 False)

 According to the manual, this is supposed to rebuild the database table 
 files, but I still don't see the database folder appearing in the app's 
 folder.

 May I know what I should do to fix migrations?

 Thank you!



-- 





[web2py] comparing two database tables

2012-10-20 Thread praveen krishna
Hii,
 I have two tables 
db.define_table('plugin_seq',
Field('filename',readable=False,writable=False),
Field('raw_seq','text'),
Field('processed_seq', 'text'),
Field('reverse_seq','text')
 
)
db.define_table('primer_seq',Field('filename',readable=False,writable=False),
Field('raw_seq','text'),
Field('processed_seq', 'text'),
)



I want to compare the processed_seq field in the two tables what can be 
possible approach I have tried by creating two forms for each table but its 
not working.

-- 





[web2py] 404 not found for user/login when using routes_apps_raw

2012-10-20 Thread Vasile Ermicioi
I need unicode urls, so I enabled routes_apps_raw for my app,
and in models I have a  file 0.py where I have this code

if not request.args:
request.args = List(request.raw_args.split('/')) if request.raw_args 
else []
if not request.args:
request.args = List()

and when going to /app/default/user/login 

I got an error 404

it works fine for 1.99.4 but doesn't work with trunk

if I disable routes_app_raw then it works

so I propose to enable unicode urls by default,
flask routing supports unicode args and vars

-- 





[web2py] web2py love

2012-10-20 Thread rif
Constrained by some performance requirements I am developing a web app 
using Go http://golang.org/, Gorilla http://www.gorillatoolkit.org/, The 
Goods http://thegoods.biz/ and MongoDB http://labix.org/mgo.

While I enjoy the beauty of go and the lightweight feeling of minimal 
libraries I stop from time to time to re-appreciate web2py for all the help 
it provides.

All the little things like: painless crud, csrf, auth, form validation, 
many little/unknown checks that we have come to take for granted came from 
hours of work done by someone else for us.

Thank you Massimo and web2py team and receive all our love!

-- 





Re: [web2py] Re: CPU and memory issues with apache

2012-10-20 Thread Massimo Di Pierro
I think you are experiencing what is described in this post:
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/leak/web2py/Go1TUyDm4ys/_2W7qnK8ZMEJ
and it was fixed in 2.1.1.

Massimo

On Saturday, 20 October 2012 02:04:32 UTC-5, Marin Pranjić wrote:

 web2py 2.0.9
 python 2.7.2

 I tried apache, rocket and uwsgi.

 I was stressing the server with many requests to monitor the memory usage.
 Memory was slowly going up.
 I think it is normal for memory to increase a bit but not sure how much 
 should it go up, and should it decrease when I stop making traffic.

 I don't know how to speed up the memory problem. I didn't try other 
 servers much because this happens in production and I depend on apache 
 config (rewrite rules).

 After apache restart, memory is ~120Mb and the rest is free.
 It goes up to 250Mb very fast and then it stabilizes (i think this is 
 expected).

 However this is how it looks like after some time (image attached).

 I do not use any sort of caching in web2py. I do not host anything else in 
 apache that might cause it.
 I use default apache config with mpm_worker module.
 It should create 2 only processes with many threads and it does.



 On Fri, Oct 19, 2012 at 9:16 PM, Massimo Di Pierro 
 massimo@gmail.comjavascript:
  wrote:

 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

  -- 
  
  
  




-- 





[web2py] Re: fake_migrate help

2012-10-20 Thread Massimo Di Pierro
When you get an unkown error there is a traceback in the console or apache 
logs. Can I see the traceback?

On Saturday, 20 October 2012 04:04:22 UTC-5, lyn2py wrote:

 I performed as Massimo's suggestion,
 fake_migrate_all=True,migrate_enabled=True

 But I ran into an Internal Error: Unknown. (no ticket).



 On Thursday, October 18, 2012 8:17:23 PM UTC+8, Massimo Di Pierro wrote:

 You mean you do not see the .table files?

 Try:
 fake_migrate_all=True,migrate_enabled=True
 could be an error in the book.

 On Thursday, 18 October 2012 01:29:42 UTC-5, lyn2py wrote:

 Hello all, something went wrong with the database table files, and they 
 were accidentally completely removed (the whole database folder).

 I need to rebuild all the database files, so I did:
 db = DAL('postgres://',fake_migrate_all=True,migrate_enabled=
 False)

 According to the manual, this is supposed to rebuild the database table 
 files, but I still don't see the database folder appearing in the app's 
 folder.

 May I know what I should do to fix migrations?

 Thank you!



-- 





[web2py] Re: 404 not found for user/login when using routes_apps_raw

2012-10-20 Thread Vasile Ermicioi
common guys, this is the second post and no one replies me,

since 1.99.4 no web2py version works with my apps and this is a bad sign,
where is the promise of fast bug fixing - or do you think this is not a 
bug? 
web2py promises backward compatibility, or something changed?

I pointed as detailed as I could, now I have 2 choices  - to fix by myself 
or to change the framework


-- 





[web2py] Re: pep8

2012-10-20 Thread Alan Etkin


 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.


What kind of app tests would be necessary to detect issues?

After looking at the changes list in Google code, it seems to me that no 
pep8ification was made to gluon.dal. Is it supposed to be adapted to pep8 
also?

-- 





[web2py] Re: pep8

2012-10-20 Thread Massimo Di Pierro
strange. I see lots of changes in gluon/dal.py. For example

raise SyntaxError, 

into

raise SyntaxError(...)

I cannot say what can go wrong. autopep8 should not change the logic.

On Saturday, 20 October 2012 08:47:13 UTC-5, Alan Etkin wrote:

 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.


 What kind of app tests would be necessary to detect issues?

 After looking at the changes list in Google code, it seems to me that no 
 pep8ification was made to gluon.dal. Is it supposed to be adapted to pep8 
 also?



-- 





[web2py] Re: 404 not found for user/login when using routes_apps_raw

2012-10-20 Thread Massimo Di Pierro
I agree that currently the URL is validated even if you 
have routes_apps_raw.
Please an issue in google code and it will be addresses asap.

massimo


On Saturday, 20 October 2012 05:40:22 UTC-5, Vasile Ermicioi wrote:

 I need unicode urls, so I enabled routes_apps_raw for my app,
 and in models I have a  file 0.py where I have this code

 if not request.args:
 request.args = List(request.raw_args.split('/')) if request.raw_args 
 else []
 if not request.args:
 request.args = List()

 and when going to /app/default/user/login 

 I got an error 404

 it works fine for 1.99.4 but doesn't work with trunk

 if I disable routes_app_raw then it works

 so I propose to enable unicode urls by default,
 flask routing supports unicode args and vars


-- 





Re: [web2py] Re: CPU and memory issues with apache

2012-10-20 Thread Niphlod
one sec. I don't see in that htop 2 processes with many threads. There 
are 27 different PIDs there! What is your apache config ?

On Saturday, October 20, 2012 2:20:23 PM UTC+2, Massimo Di Pierro wrote:

 I think you are experiencing what is described in this post:

 https://groups.google.com/forum/?fromgroups=#!searchin/web2py/leak/web2py/Go1TUyDm4ys/_2W7qnK8ZMEJ
 and it was fixed in 2.1.1.

 Massimo

 On Saturday, 20 October 2012 02:04:32 UTC-5, Marin Pranjić wrote:

 web2py 2.0.9
 python 2.7.2

 I tried apache, rocket and uwsgi.

 I was stressing the server with many requests to monitor the memory usage.
 Memory was slowly going up.
 I think it is normal for memory to increase a bit but not sure how much 
 should it go up, and should it decrease when I stop making traffic.

 I don't know how to speed up the memory problem. I didn't try other 
 servers much because this happens in production and I depend on apache 
 config (rewrite rules).

 After apache restart, memory is ~120Mb and the rest is free.
 It goes up to 250Mb very fast and then it stabilizes (i think this is 
 expected).

 However this is how it looks like after some time (image attached).

 I do not use any sort of caching in web2py. I do not host anything else 
 in apache that might cause it.
 I use default apache config with mpm_worker module.
 It should create 2 only processes with many threads and it does.



 On Fri, Oct 19, 2012 at 9:16 PM, Massimo Di Pierro massimo@gmail.com
  wrote:

 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

  -- 
  
  
  




-- 





[web2py] Re: Ajax / cid with A helper not working

2012-10-20 Thread Niphlod
Where was that ? (just for future reference if anyone sees this thread)

On Saturday, October 20, 2012 4:08:50 AM UTC+2, lyn2py wrote:

 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 requestand 
 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: Where does auth.wiki save pages to?

2012-10-20 Thread Alan Etkin


 I can't find them in my database...


Wikis are stored in the wiki_page table
To make wiki_ tables visible you must add this statement to your base model 
file (i.e. db.py)

auth.wiki(resolve=False)

The resolve argument prevents web2py to configure the response for the wiki 
user interface, but adds the table definitions to the model, so you can do 
custom crud with wiki data.

Then you can optionally call auth.wiki() in the controller to enable the 
wiki interface for a given action

Wiki tables are not defined until auth.wiki is called.

-- 





[web2py] Re: 404 not found for user/login when using routes_apps_raw

2012-10-20 Thread Massimo Di Pierro
I should clarify my answer. While I am not sure if raw_args is working as 
intended or not, and I am looking into this, web2py does not limit your 
ability to use unicode in URLs. It just asks you to do in a way that is 
safe.

For example, imagine you want an url like this:

http://hostname/wiki/ɸ

and your app is called myapp. What web2py does not like is that you map ɸ 
as an arg. It is ok to map ɸ as a var. So you can have a rule like:

routes_in = [('/wiki/$anything', '/myapp/default/wiki?key=$anything')]

and in myapp/controllers/default.py

def wiki():
 key = request.vars.key # contains ɸ
 

The rule is that args are automatically validated, vars are not and you 
must validate them yourself.
The purpose of raw_args is not to allow you use unicode in the URL (which 
can do with the method before) but to loosen up the autovalidation of args 
and I am not sure it is a good idea. If you use routes, args are defined 
after routing.

Massimo




On Saturday, 20 October 2012 05:40:22 UTC-5, Vasile Ermicioi wrote:

 I need unicode urls, so I enabled routes_apps_raw for my app,
 and in models I have a  file 0.py where I have this code

 if not request.args:
 request.args = List(request.raw_args.split('/')) if request.raw_args 
 else []
 if not request.args:
 request.args = List()

 and when going to /app/default/user/login 

 I got an error 404

 it works fine for 1.99.4 but doesn't work with trunk

 if I disable routes_app_raw then it works

 so I propose to enable unicode urls by default,
 flask routing supports unicode args and vars


-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Niphlod
no prio available (it's hard to manage a task queued 3 hours ago with 
prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

hackish way: tasks are picked up ordered by next_run_time. So, queue your 
tasks with next_runtime = request.now - datetime.timedelta(hours=1) kinda 
works. 

Right way: separate queues, important tasks and less important tasks.  
You can create different queues assigning different group_name to tasks and 
start - at least 2 - separate scheduler processes. By default tasks are in 
the group 'main', and the scheduler worker processes those only


def task1(a, b=2):
 #need high prio

def task2(a, b=2):
#needs low prio

from gluon.scheduler import Scheduler
mysched = Scheduler(db)

#new api
mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

#old api
from gluon.serializers import json
db.scheduler_task.validate_and_insert(function_name='task1', args=json(['a'
]), vars=json({'b':1}), group_name='fast_track')
db.scheduler_task.validate_and_insert(function_name='task2', args=json(['a'
]), vars=json({'b':1}), group_name='slow_track')


Then, start one scheduler per queue with
web2py.py -K appname:fast_track,appname:slow_track

If you just need some important tasks without assignign slow_track to the 
zillions you have already, just forget about the group_name='slow_track' 
and start schedulers with this command line
web2py.py -K appname,appname:fast_track
Then assign to fast_track only the ones you want to exec first and, 
assuming that fast_track has less tasks in queue, they will be executed 
before the zillion ones in the main group.

Clear ?

On Saturday, October 20, 2012 3:01:24 AM UTC+2, Adi wrote:

 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 nip...@gmail.com 
 javascript: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




-- 





Re: [web2py] I am looking for specifics : how to db.define_table in sub directories in the MODELS directory !

2012-10-20 Thread Niphlod
if you use 'reference tablename' replace all your 'defined' with 'created 
yet on the database' and all you sentence is right. 

On Saturday, October 20, 2012 2:41:52 AM UTC+2, Don_X wrote:

 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: Web2Py on OpenShift

2012-10-20 Thread apps in tables


Hi,

which cloud storage service is accessible from openshift-deployed web2py 
app?

s3 , dropbox , google drive , ...

My main purpose is to store photos.

Regards,

Ashraf

-- 





[web2py] Re: Loading modules fails - web2py 2.1.1(and earlier) / python 2.7.1 / Mac OS X

2012-10-20 Thread Massimo Di Pierro
I am very puzzled but this. It should not be necessary. Does the code below 
work for you?

$ python web2py.py -S welcome 
(InteractiveConsole)
 import simplejson

Do you have a module called simplejson in yourapp/modules/? 

From a normal python shell, shat happens if you do?

 import simplejson

On Thursday, 18 October 2012 14:17:38 UTC-5, Luciano Laporta Podazza wrote:

 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] Re: unable to submit auth forms

2012-10-20 Thread Massimo Di Pierro
I still do not understand. Can you give me exact steps to reproduce the 
problem?

On Thursday, 18 October 2012 02:18:50 UTC-5, Rohan Malhotra wrote:


 On Thursday, 18 October 2012 02:51:52 UTC+5:30, Massimo Di Pierro wrote:

 What is the code? Is this something that worked before? using a custom 
 form?

 On Wednesday, 17 October 2012 09:17:57 UTC-5, Rohan Malhotra wrote:

 Version 2.1.1 (2012-10-15 12:44:40) stable

 Hi,

 I am not able to submit an auth form. I am using default auth code. On 
 submitting the form, password is shown as invalid and 'enter from 0 to 
 512 characters' error is thrown. Input

 td class=w2p_fw
 input class=password invalidinput id=auth_user_password 
 name=password type=password 
 value=passwod_value_entered_before_submitting_form
 div class=error_wrapper
 div class=error id=password__error style=display: block;enter 
 from 0 to 512 characters/div
 /div
 /td


 Please advice.

 Thanks


 It is default code copied from scaffolding app with no customization.

 I downgraded web2py to 1.99 version and things started to work again 
 without any change in code.

 -Ro 


-- 





[web2py] Re: Web2Py on OpenShift

2012-10-20 Thread Andrew
Ashraf,

I replied on the github issue as well but you should be able to add boto to 
web2py lib and use it to store photos on your S3 account without issue. Let 
me know if you run into any problems.

Regards,
Andrew

On Saturday, October 20, 2012 9:43:08 AM UTC-5, apps in tables wrote:

 Hi,

 which cloud storage service is accessible from openshift-deployed web2py 
 app?

 s3 , dropbox , google drive , ...

 My main purpose is to store photos.

 Regards,

 Ashraf


-- 





[web2py] Re: Web2Py on OpenShift

2012-10-20 Thread Massimo Di Pierro
Notice you can do

$ pip install pyfilesystem

 import pyfilesystem
 s3 = fs.s3fs.S3FS()
 db.define_table('mytable',,Field('file','upload',uploadfs = s3),...)

You can use any pyfilesystem (s3, dropbox, ftp, zip, etc) to store your 
uploads.



On Saturday, 20 October 2012 09:50:39 UTC-5, Andrew wrote:

 Ashraf,

 I replied on the github issue as well but you should be able to add boto 
 to web2py lib and use it to store photos on your S3 account without issue. 
 Let me know if you run into any problems.

 Regards,
 Andrew

 On Saturday, October 20, 2012 9:43:08 AM UTC-5, apps in tables wrote:

 Hi,

 which cloud storage service is accessible from openshift-deployed web2py 
 app?

 s3 , dropbox , google drive , ...

 My main purpose is to store photos.

 Regards,

 Ashraf



-- 





[web2py] Re: Wiki Body CLOB class 'cx_Oracle.DatabaseError' ORA-01704: string literal too long?

2012-10-20 Thread Massimo Di Pierro
Hello Bill
which web2py version? Can you try 2.1.1?

On Thursday, 18 October 2012 19:19:40 UTC-5, Bill Thayer wrote:


 Using the auth.wiki I am defining my menu. When I hit submit I get the 
 error below. The menu I wrote in is currently long I guess but it couldn't 
 be more than 4000 bytes (oracle CLOB length) could it? Perhaps it's the 
 HTML that gets stored in the DB?...That's what I suspected then I 
 remembered that in WIKI_MEDIA I added a blob field to store files on the 
 database and the 3 jpg images all larger that 4kb loaded with no problem.



 Traceback (most recent call last):
  File C:\web2py_src_2.1.1\web2py\gluon\restricted.py, line 209, inrestricted
  exec ccode in environment
  File 
 C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/default.py
 , line 283, in module
  File C:\web2py_src_2.1.1\web2py\gluon\globals.py, line 187, in lambda
  self._caller = lambda f: f()
  File 
 C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/default.py
 , line 22, in index
  return auth.wiki()
  File C:\web2py_src_2.1.1\web2py\gluon\tools.py, line 3227, in wiki
  return self._wiki.read(slug)['content'] if slug else self._wiki()
  File C:\web2py_src_2.1.1\web2py\gluon\tools.py, line 4697, in __call__
  return self.edit(request.args(1) or 'index')
  File C:\web2py_src_2.1.1\web2py\gluon\tools.py, line 4791, in edit
  formstyle='table2cols',showid=False).process()
  File C:\web2py_src_2.1.1\web2py\gluon\html.py, line 2135, in process
  self.validate(**kwargs)
  File C:\web2py_src_2.1.1\web2py\gluon\html.py, line 2075, in validate
  if self.accepts(**kwargs):
  File C:\web2py_src_2.1.1\web2py\gluon\sqlhtml.py, line 1439, in accepts
  self.table._db(self.table._id == self.record[self.id_field_name]).update
 (**fields)
  File C:\web2py_src_2.1.1\web2py\gluon\dal.py, line 8814, in update
  ret = db._adapter.update(tablename,self.query,fields)
  File C:\web2py_src_2.1.1\web2py\gluon\dal.py, line 1371, in update
  self.execute(sql)
  File C:\web2py_src_2.1.1\web2py\gluon\dal.py, line 2856, in execute
  return self.log_execute(command, args)
  File C:\web2py_src_2.1.1\web2py\gluon\dal.py, line 1687, in log_execute
  ret = self.cursor.execute(*a, **b)
 DatabaseError: ORA-01704: string literal too long




 This article explains how to define a LOB field 
 http://www.dba-oracle.com/t_table_blob_lob_storage.htm in SQL. The SQL I 
 am reading in SQL developer from tables created by web2py is different but 
 should work. Then I got to messing with my menu markmin and discovered if I 
 remove the @ from two of my menu items then it submits fine.

 - Request  @request
 - - Measurement  @order-measurment
 - - Model  @model
 - Product  @Product
 - - Measurements  Measurements
 - - - S-Parameters  @S-Parameters
 - - - DC-IV  DC-IV
 - - - Load Pull  @Load-Pull
 - - Models  @Models
 .
 .
 .



 https://groups.google.com/d/msg/web2py/f66R-f3QvDo/gZR40A87SJ4J - 
 Discussion from September 09 where Massimo posted a fix to sql.py (a file 
 only used for backward compatibility) but I'm not convinced it's a CLOB 
 problem.

 -Bill


-- 





[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
Delete should return the number of deleted records. What is your proposal?

On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian


-- 





[web2py] Re: about constraints on fields of table

2012-10-20 Thread Massimo Di Pierro
Sorry I was not clear. IS_DATE and IS_DATETIME allow you to specify a 
format. IS_TIME does not. You cannot use IS_DATE with a time only format 
string (dates do not include time). Please open a ticket with a suggestion 
for enhancement.

On Wednesday, 17 October 2012 12:52:58 UTC-5, dantuluri jaganadha raju 
wrote:

 I kept field('aaa', requires=IS_DATE(format='%H:%M')) . and when I try 
 to open database administration and that particular table I am getting 
 error 
 str' object has no attribute 'year'. and more over I want only time as 
 input to a field

Thank in advance.

 On Friday, October 12, 2012 10:44:23 AM UTC+5:30, dantuluri jaganadha raju 
 wrote:

 Hi,
  I want to accept only 9 digit number as input to one field and 
 other's are invalid. and in another field I want to accept time format of 
 form (hours:minutes to hours:minutes).
  
Thank you in advance...



-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Adnan Smajlovic
all clear :) in process of implementing.

Is new api defined in scheduler.py, since i don't see it in there (2.1.1
(2012-10-17 17:00:46) dev), but I'm modifying the existing code to employ
fast_track, since order confirmations are getting behind. This will be
really good :) Thanks again, and again...

On Sat, Oct 20, 2012 at 10:37 AM, Niphlod niph...@gmail.com wrote:

 no prio available (it's hard to manage a task queued 3 hours ago with
 prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

 hackish way: tasks are picked up ordered by next_run_time. So, queue
 your tasks with next_runtime = request.now - datetime.timedelta(hours=1)
 kinda works.

 Right way: separate queues, important tasks and less important tasks.
 You can create different queues assigning different group_name to tasks and
 start - at least 2 - separate scheduler processes. By default tasks are in
 the group 'main', and the scheduler worker processes those only


 Then, start one scheduler per queue with
 web2py.py -K appname:fast_track,appname:

 def task1(a, b=2):
  #need high prio

 def task2(a, b=2):
 #needs low prio

 from gluon.scheduler import Scheduler
 mysched = Scheduler(db)

 #new api
 mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
 mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

 #old api
 from gluon.serializers import json
 db.scheduler_task.validate_and_insert(function_name='task1', args=json([
 'a']), vars=json({'b':1}), group_name='fast_track')
 db.scheduler_task.validate_and_insert(function_name='task2', args=json([
 'a']), vars=json({'b':1}), group_name='slow_track')

 slow_track

 If you just need some important tasks without assignign slow_track to
 the zillions you have already, just forget about the
 group_name='slow_track' and start schedulers with this command line
 web2py.py -K appname,appname:fast_track
 Then assign to fast_track only the ones you want to exec first and,
 assuming that fast_track has less tasks in queue, they will be executed
 before the zillion ones in the main group.

 Clear ?


 On Saturday, October 20, 2012 3:01:24 AM UTC+2, Adi wrote:

 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 nip...@gmail.com wrote:

 it's missing the outer loop.


 Should work.
 _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


 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).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
  --

   http://vimeo.com/24653283



-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-20 Thread apps in tables

Hi Alan,

I really appreciate if you can write an example that access wiki_page 
without the use of auth_wiki interface. (just one wiki_page is enough)

Regards,

Ashraf

-- 





[web2py] Re: Web2Py on OpenShift

2012-10-20 Thread apps in tables
Hi Andrew and Massimo,

I will try boto and let you know .

regards,

Ashraf


-- 





[web2py] Re: fake_migrate help

2012-10-20 Thread lyn2py
Thanks Massimo, I have looked at the error log files, and found this 
traceback:

__db_meta_setup: 
/home/www-data/web2py/applications/nea/cache/cache.shelve.db: unexpected 
file type or format
ERROR:web2py:Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 209, in restricted
exec ccode in environment
  File applications/myapp/compiled/models/db2.py, line 36, in module
  File /home/www-data/web2py/gluon/tools.py, line 1497, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
  File /home/www-data/web2py/gluon/dal.py, line 7095, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File /home/www-data/web2py/gluon/dal.py, line 7126, in lazy_define_table
polymodel=polymodel)
  File /home/www-data/web2py/gluon/dal.py, line 896, in create_table
logfile = self.file_open(table._loggername, 'a')
  File /home/www-data/web2py/gluon/dal.py, line 646, in file_open
fileobj = portalocker.LockedFile(filename,mode)
  File /home/www-data/web2py/gluon/portalocker.py, line 121, in __init__
self.file = open(filename,mode.replace('w','a'))
IOError: [Errno 2] No such file or directory: 
'/home/www-data/web2py/applications/app/databases/sql.log'

Hope it helps!


On Saturday, October 20, 2012 8:21:10 PM UTC+8, Massimo Di Pierro wrote:

 When you get an unkown error there is a traceback in the console or apache 
 logs. Can I see the traceback?

 On Saturday, 20 October 2012 04:04:22 UTC-5, lyn2py wrote:

 I performed as Massimo's suggestion,
 fake_migrate_all=True,migrate_enabled=True

 But I ran into an Internal Error: Unknown. (no ticket).



 On Thursday, October 18, 2012 8:17:23 PM UTC+8, Massimo Di Pierro wrote:

 You mean you do not see the .table files?

 Try:
 fake_migrate_all=True,migrate_enabled=True
 could be an error in the book.

 On Thursday, 18 October 2012 01:29:42 UTC-5, lyn2py wrote:

 Hello all, something went wrong with the database table files, and they 
 were accidentally completely removed (the whole database folder).

 I need to rebuild all the database files, so I did:
 db = DAL('postgres://',fake_migrate_all=True,migrate_enabled=
 False)

 According to the manual, this is supposed to rebuild the database table 
 files, but I still don't see the database folder appearing in the app's 
 folder.

 May I know what I should do to fix migrations?

 Thank you!



-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Adnan Smajlovic
couple things happened...

The main group worker got created even though I didn't call it... Not sure
why, but i guess because there are lot of leftover tasks queued (500k) and
some were assigned when I stopped the process.

Even though fast_tack worker started, nothing is getting picked, assigned
nor completed... I checked the time, conditions, and it should be picked...

Only main are getting assigned, but they are not getting completed, even
though they were completing when I had only main group specified, without
fast_track, and slow_track

exec python26 /opt/web-apps/web2py/web2py.py -K
crm:fast_track,crm:slow_track   /var/log/web2py-scheduler.log



On Sat, Oct 20, 2012 at 11:13 AM, Adnan Smajlovic adnan.smajlo...@gmail.com
 wrote:

 all clear :) in process of implementing.

 Is new api defined in scheduler.py, since i don't see it in there (2.1.1
 (2012-10-17 17:00:46) dev), but I'm modifying the existing code to employ
 fast_track, since order confirmations are getting behind. This will be
 really good :) Thanks again, and again...

 On Sat, Oct 20, 2012 at 10:37 AM, Niphlod niph...@gmail.com wrote:

 no prio available (it's hard to manage a task queued 3 hours ago with
 prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

 hackish way: tasks are picked up ordered by next_run_time. So, queue
 your tasks with next_runtime = request.now - datetime.timedelta(hours=1)
 kinda works.

 Right way: separate queues, important tasks and less important
 tasks.  You can create different queues assigning different group_name to
 tasks and start - at least 2 - separate scheduler processes. By default
 tasks are in the group 'main', and the scheduler worker processes those only


 Then, start one scheduler per queue with
 web2py.py -K appname:fast_track,appname:

 def task1(a, b=2):
  #need high prio

 def task2(a, b=2):
 #needs low prio

 from gluon.scheduler import Scheduler
 mysched = Scheduler(db)

 #new api
 mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
 mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

 #old api
 from gluon.serializers import json
 db.scheduler_task.validate_and_insert(function_name='task1', args=json([
 'a']), vars=json({'b':1}), group_name='fast_track')
 db.scheduler_task.validate_and_insert(function_name='task2', args=json([
 'a']), vars=json({'b':1}), group_name='slow_track')

 slow_track

 If you just need some important tasks without assignign slow_track to
 the zillions you have already, just forget about the
 group_name='slow_track' and start schedulers with this command line
 web2py.py -K appname,appname:fast_track
 Then assign to fast_track only the ones you want to exec first and,
 assuming that fast_track has less tasks in queue, they will be executed
 before the zillion ones in the main group.

 Clear ?



-- 





[web2py] Re: Ajax / cid with A helper not working

2012-10-20 Thread lyn2py
It was in my index.html file. I thought that since it was js, it wouldn't 
affect. But it turned out to override the web2py component.

To resolve, use 
$(function(){...
instead. 

On Saturday, October 20, 2012 10:17:45 PM UTC+8, Niphlod wrote:

 Where was that ? (just for future reference if anyone sees this thread)

 On Saturday, October 20, 2012 4:08:50 AM UTC+2, lyn2py wrote:

 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 requestand 
 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: delete on GAE

2012-10-20 Thread howesc
It appears that the most efficient way to delete on app engine is to:
 - build a query object, like we are doing now
 - call run with keys_only=True 
(https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
 
which returns an iterator.
 - pass that iterator to the datastore delete method 
(https://developers.google.com/appengine/docs/python/datastore/functions#delete)

this avoids the cost of loading the rows into memory, decreases the 
likelihood of timeout, and has the cost of 1 datastore small operation per 
row.  but it does prevent us from getting a count of rows deleted.

the way we do it now:
 - run count() on the query.  this has a cost (time and money) of iterating 
over all the rows that match the query on GAE (1 datastore small operation 
per row)
 - run fetch(limit=1000) and call delete() successively until no more rows. 
 this has the cost of running a full query (at least 1 datastore read 
operation per row) and loading the result set into memory and then deleting 
the results.

in my case i'm timing out on the count() call so i don't even start the 
delete.  from an efficiency standpoint i'd rather have more rows deleted 
for less cost then get a countbut this may not be acceptable for all. 
 at a minimum i think we should switch to use keys_only=True for the fetch, 
and skip the leading count() call and just sum the number of times we call 
fetch.  we may also consider catching the datastore timeout error and 
trying to handle a partial delete more gracefully (or continue to let the 
user catch the error).

what is the right approach for web2py?  if the approach with count is 
correct, could i propose a gae bulk_delete method that does not return 
count but uses my first method?

thanks for the input!

cfh

On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian



-- 





[web2py] Re: Loading modules fails - web2py 2.1.1(and earlier) / python 2.7.1 / Mac OS X

2012-10-20 Thread Luciano Laporta Podazza
Hello Massimo!, comments inline.

On Saturday, October 20, 2012 11:43:43 AM UTC-3, Massimo Di Pierro wrote:

 I am very puzzled but this. It should not be necessary. Does the code 
 below work for you?

 $ python web2py.py -S welcome 
 (InteractiveConsole)
  import simplejson


If I use web2py.app(Mac OS) it doesn't work:

Silver-2:Resources keniobats$ pwd
/Users/keniobats/Downloads/web2py/web2py.app/Contents/Resources
Silver-2:Resources keniobats$ python web2py.py -S welcome
Traceback (most recent call last):
  File web2py.py, line 16, in module
import gluon.widget
ImportError: No module named gluon.widget
Silver-2:Resources keniobats$ 

If I use the source version it works well:

Silver-2:web2py 2 keniobats$ python web2py.py -S welcome
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.0.9 (2012-09-13 23:51:30) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
WARNING:web2py:import IPython error; use default python shell
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
darwin
Type help, copyright, credits or license for more information.
(InteractiveConsole)
 import simplejson
 



 


 Do you have a module called simplejson in yourapp/modules/? 


I have nothing but my facebook.py module there.
 


 From a normal python shell, shat happens if you do?

  import simplejson


Silver-2:~ keniobats$ pwd
/Users/keniobats
Silver-2:~ keniobats$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
darwin
Type help, copyright, credits or license for more information.
 import simplejson
 

It works as usual :)

Hope it helps, thanks Massimo!

-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Adnan Smajlovic
i can confirm that size of the queued records has something to do with
delay to process different queues... once i deleted all outstanding records
from main group, fast_track group started working as expected... sorry for
a long thread, but i think it's a very neat idea to load scheduler with
lots of records which will be processed in a back-end process, while
fast-track works in it's own (faster) pace...

On Sat, Oct 20, 2012 at 12:03 PM, Adnan Smajlovic adnan.smajlo...@gmail.com
 wrote:

 couple things happened...

 The main group worker got created even though I didn't call it... Not sure
 why, but i guess because there are lot of leftover tasks queued (500k) and
 some were assigned when I stopped the process.

 Even though fast_tack worker started, nothing is getting picked,
 assigned nor completed... I checked the time, conditions, and it should be
 picked...

 Only main are getting assigned, but they are not getting completed, even
 though they were completing when I had only main group specified, without
 fast_track, and slow_track

 exec python26 /opt/web-apps/web2py/web2py.py -K
 crm:fast_track,crm:slow_track   /var/log/web2py-scheduler.log



 On Sat, Oct 20, 2012 at 11:13 AM, Adnan Smajlovic 
 adnan.smajlo...@gmail.com wrote:

 all clear :) in process of implementing.

 Is new api defined in scheduler.py, since i don't see it in there (2.1.1
 (2012-10-17 17:00:46) dev), but I'm modifying the existing code to
 employ fast_track, since order confirmations are getting behind. This will
 be really good :) Thanks again, and again...

 On Sat, Oct 20, 2012 at 10:37 AM, Niphlod niph...@gmail.com wrote:

 no prio available (it's hard to manage a task queued 3 hours ago
 with prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

 hackish way: tasks are picked up ordered by next_run_time. So, queue
 your tasks with next_runtime = request.now - datetime.timedelta(hours=1)
 kinda works.

 Right way: separate queues, important tasks and less important
 tasks.  You can create different queues assigning different group_name to
 tasks and start - at least 2 - separate scheduler processes. By default
 tasks are in the group 'main', and the scheduler worker processes those only


 Then, start one scheduler per queue with
 web2py.py -K appname:fast_track,appname:

 def task1(a, b=2):
  #need high prio

 def task2(a, b=2):
 #needs low prio

 from gluon.scheduler import Scheduler
 mysched = Scheduler(db)

 #new api
 mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
 mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

 #old api
 from gluon.serializers import json
 db.scheduler_task.validate_and_insert(function_name='task1', args=json([
 'a']), vars=json({'b':1}), group_name='fast_track')
 db.scheduler_task.validate_and_insert(function_name='task2', args=json([
 'a']), vars=json({'b':1}), group_name='slow_track')

 slow_track

 If you just need some important tasks without assignign slow_track to
 the zillions you have already, just forget about the
 group_name='slow_track' and start schedulers with this command line
 web2py.py -K appname,appname:fast_track
 Then assign to fast_track only the ones you want to exec first and,
 assuming that fast_track has less tasks in queue, they will be executed
 before the zillion ones in the main group.

 Clear ?



-- 





[web2py] appadmin upload from iPhone gives empty record.

2012-10-20 Thread Richard
Hi,

I want to use Web2Py as much as possible. For a holiday blog I want to 
upload photo's from my iPhone using appadmin.
From my windows PC this works file. I get a file location and a file which 
i can view.

But an upload from my iPhone gives no error, a new record is created but 
without image.file which must contain a link to the upload photo.

I use the easy db definition:

db.define_table(
'loc',
Field('location'),
format = '%(location)s'
)

db.define_table(
   'image',
   Field('loc', 'reference loc'),
   Field('title', unique=True),
   Field('file', 'upload'),
   format = '%(title)s'
   )

Does anybody has a clu?

Richard.

-- 





[web2py] Re: fake_migrate help

2012-10-20 Thread villas
Sorry if it sounds obvious,  but I suppose you have checked that you can 
write to that dir and the permissions are correct?  It is best to have dirs 
and files belonging to the same user that your webservice uses.  e.g.  I 
chown my files www-data:www-data

BTW  I remove|rename my databases/*.table files prior to running 
fake_migrate_all,  as it seems that it does not like to overwrite what is 
already there (which is not surprising),  although I don't think this point 
has anything much to do with your ticket.


On Saturday, October 20, 2012 4:53:46 PM UTC+1, lyn2py wrote:

 Thanks Massimo, I have looked at the error log files (production site), 
 and found this traceback:

 __db_meta_setup: 
 /home/www-data/web2py/applications/app/cache/cache.shelve.db: unexpected 
 file type or format
 ERROR:web2py:Traceback (most recent call last):
   File /home/www-data/web2py/gluon/restricted.py, line 209, in restricted
 exec ccode in environment
   File applications/myapp/compiled/models/db2.py, line 36, in module
   File /home/www-data/web2py/gluon/tools.py, line 1497, in define_tables
 format='%(first_name)s %(last_name)s (%(id)s)'))
   File /home/www-data/web2py/gluon/dal.py, line 7095, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/www-data/web2py/gluon/dal.py, line 7126, in 
 lazy_define_table
 polymodel=polymodel)
   File /home/www-data/web2py/gluon/dal.py, line 896, in create_table
 logfile = self.file_open(table._loggername, 'a')
   File /home/www-data/web2py/gluon/dal.py, line 646, in file_open
 fileobj = portalocker.LockedFile(filename,mode)
   File /home/www-data/web2py/gluon/portalocker.py, line 121, in __init__
 self.file = open(filename,mode.replace('w','a'))
 IOError: [Errno 2] No such file or directory: 
 '/home/www-data/web2py/applications/app/databases/sql.log'

 Hope it helps!


 On Saturday, October 20, 2012 8:21:10 PM UTC+8, Massimo Di Pierro wrote:

 When you get an unkown error there is a traceback in the console or 
 apache logs. Can I see the traceback?

 On Saturday, 20 October 2012 04:04:22 UTC-5, lyn2py wrote:

 I performed as Massimo's suggestion,
 fake_migrate_all=True,migrate_enabled=True

 But I ran into an Internal Error: Unknown. (no ticket).



 On Thursday, October 18, 2012 8:17:23 PM UTC+8, Massimo Di Pierro wrote:

 You mean you do not see the .table files?

 Try:
 fake_migrate_all=True,migrate_enabled=True
 could be an error in the book.

 On Thursday, 18 October 2012 01:29:42 UTC-5, lyn2py wrote:

 Hello all, something went wrong with the database table files, and 
 they were accidentally completely removed (the whole database folder).

 I need to rebuild all the database files, so I did:
 db = DAL('postgres://',fake_migrate_all=True,migrate_enabled=
 False)

 According to the manual, this is supposed to rebuild the database 
 table files, but I still don't see the database folder appearing in the 
 app's folder.

 May I know what I should do to fix migrations?

 Thank you!



-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-20 Thread villas
It's easy to access the table  wiki_page using DAL as usual.

Make a python commandline for your app...
python web2py.py -S yourapp -M

Type these two lines into your python commandline.
auth.wiki(resolve=False)
db().select(db.wiki_page.body).first().body

Otherwise, access via a function:
def mywiki():
auth.wiki(resolve=False)
mywikipagefields = db().select(db.wiki_page.ALL).first()
return dict(mywikipagefields = mywikipagefields)

The wiki_page definition is in gluon/tools.py
table_definitions = [
('wiki_page',{
'args':[
Field('slug',
  requires=[IS_SLUG(),
IS_NOT_IN_DB(db,'wiki_page.slug')],
  readable=False,writable=False),
Field('title',unique=True),
Field('body','text',notnull=True),
Field('tags','list:string'),
Field('can_read','list:string',
  writable=perms,
  readable=perms,
  default=[Wiki.everybody]),
Field('can_edit', 'list:string',
  writable=perms,readable=perms,
  default=[Wiki.everybody]),
Field('changelog'),
Field('html','text',compute=render,
  readable=False, writable=False),
auth.signature],
  'vars':{'format':'%(title)s'}}),


On Saturday, October 20, 2012 4:15:39 PM UTC+1, apps in tables wrote:


 Hi Alan,

 I really appreciate if you can write an example that access wiki_page 
 without the use of auth_wiki interface. (just one wiki_page is enough)

 Regards,

 Ashraf


-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Niphlod
You're right, there's a bug: for zillions of queued tasks at the same 
priority (i.e. got queued first) the bunch we assign on every loop 
doesn't take into account that there might be 10 or 20 tasks to assign and 
execute on a faster pace in the following bunch(es). Nice catch! 
reviewing the logic right now.

BTW: mysched.queue_task is available only in trunk, it was just a teaser 
:P  

On Saturday, October 20, 2012 7:27:55 PM UTC+2, Adi wrote:

 i can confirm that size of the queued records has something to do with 
 delay to process different queues... once i deleted all outstanding records 
 from main group, fast_track group started working as expected... sorry for 
 a long thread, but i think it's a very neat idea to load scheduler with 
 lots of records which will be processed in a back-end process, while 
 fast-track works in it's own (faster) pace... 

 On Sat, Oct 20, 2012 at 12:03 PM, Adnan Smajlovic 
 adnan.s...@gmail.comjavascript:
  wrote:

 couple things happened... 

 The main group worker got created even though I didn't call it... Not 
 sure why, but i guess because there are lot of leftover tasks queued (500k) 
 and some were assigned when I stopped the process. 

 Even though fast_tack worker started, nothing is getting picked, 
 assigned nor completed... I checked the time, conditions, and it should be 
 picked... 

 Only main are getting assigned, but they are not getting completed, even 
 though they were completing when I had only main group specified, without 
 fast_track, and slow_track

 exec python26 /opt/web-apps/web2py/web2py.py -K 
 crm:fast_track,crm:slow_track   /var/log/web2py-scheduler.log 



 On Sat, Oct 20, 2012 at 11:13 AM, Adnan Smajlovic 
 adnan.s...@gmail.comjavascript:
  wrote:

 all clear :) in process of implementing. 

 Is new api defined in scheduler.py, since i don't see it in there (2.1.1 
 (2012-10-17 17:00:46) dev), but I'm modifying the existing code to 
 employ fast_track, since order confirmations are getting behind. This will 
 be really good :) Thanks again, and again...

 On Sat, Oct 20, 2012 at 10:37 AM, Niphlod nip...@gmail.comjavascript:
  wrote:

 no prio available (it's hard to manage a task queued 3 hours ago 
 with prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

 hackish way: tasks are picked up ordered by next_run_time. So, queue 
 your tasks with next_runtime = request.now - datetime.timedelta(hours=1) 
 kinda works. 

 Right way: separate queues, important tasks and less important 
 tasks.  You can create different queues assigning different group_name to 
 tasks and start - at least 2 - separate scheduler processes. By default 
 tasks are in the group 'main', and the scheduler worker processes those 
 only


 Then, start one scheduler per queue with
 web2py.py -K appname:fast_track,appname:

 def task1(a, b=2):
  #need high prio

 def task2(a, b=2):
 #needs low prio

 from gluon.scheduler import Scheduler
 mysched = Scheduler(db)

 #new api
 mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
 mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

 #old api
 from gluon.serializers import json
 db.scheduler_task.validate_and_insert(function_name='task1', args=json
 (['a']), vars=json({'b':1}), group_name='fast_track')
 db.scheduler_task.validate_and_insert(function_name='task2', args=json
 (['a']), vars=json({'b':1}), group_name='slow_track')

 slow_track

 If you just need some important tasks without assignign slow_track to 
 the zillions you have already, just forget about the 
 group_name='slow_track' and start schedulers with this command line
 web2py.py -K appname,appname:fast_track
 Then assign to fast_track only the ones you want to exec first and, 
 assuming that fast_track has less tasks in queue, they will be executed 
 before the zillion ones in the main group.

 Clear ?

  


-- 





[web2py] Re: Version 2.1.1 error: Table' object has no attribute '_id'

2012-10-20 Thread villas
Hi Omi
I don't think composite primary keys have ever been supported,  so I 
suppose you would be on your own with that design strategy and who knows 
how it worked!   :)
D


On Friday, October 19, 2012 10:38:21 PM UTC+1, Omi Chiba wrote:

 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
 

[web2py] Re: web2py love

2012-10-20 Thread Adi
Totally agreed... i stopped developing years ago, but web2py brought me 
back and gave confidence, and courage to do this kind of large scale rapid 
development just by myself... 

Thank you Massimo and all other true experts on your generous contribution 
and help... 

What makes this fantastic development platform so strong is that it stays 
secured, by standards, self-sufficient, lean, while adopting new features, 
and latest trends practically on a daily basis :) Impressive!!!


On Saturday, October 20, 2012 7:23:12 AM UTC-4, rif wrote:

 Constrained by some performance requirements I am developing a web app 
 using Go http://golang.org/, Gorilla http://www.gorillatoolkit.org/, The 
 Goods http://thegoods.biz/ and MongoDB http://labix.org/mgo.

 While I enjoy the beauty of go and the lightweight feeling of minimal 
 libraries I stop from time to time to re-appreciate web2py for all the help 
 it provides.

 All the little things like: painless crud, csrf, auth, form validation, 
 many little/unknown checks that we have come to take for granted came from 
 hours of work done by someone else for us.

 Thank you Massimo and web2py team and receive all our love!


-- 





[web2py] Re: comparing two database tables

2012-10-20 Thread villas
I do not think that your problem is clearly defined enough for anyone to 
answer.  
Do you perhaps mean the max processed_seq in each table?



On Saturday, October 20, 2012 10:53:28 AM UTC+1, praveen krishna wrote:

 Hii,
  I have two tables 
 db.define_table('plugin_seq',
 Field('filename',readable=False,writable=False),
 Field('raw_seq','text'),
 Field('processed_seq', 'text'),
 Field('reverse_seq','text')
  
 )

 db.define_table('primer_seq',Field('filename',readable=False,writable=False),
 Field('raw_seq','text'),
 Field('processed_seq', 'text'),
 )



 I want to compare the processed_seq field in the two tables what can be 
 possible approach I have tried by creating two forms for each table but its 
 not working.


-- 





Re: [web2py] Re: comparing two database tables

2012-10-20 Thread praveen krishna
Actually  processed_seq refers to a list of strings in plugin_seq table and
in primer_seq it has list of substrings . I want find all the substrings in
the list which are in processed_seq field of plugin_seq table .I had
 written the code when I have single substring but I am unable to implement
this a list of substrings when I load them in database.

On Sat, Oct 20, 2012 at 8:54 PM, villas villa...@gmail.com wrote:

 I do not think that your problem is clearly defined enough for anyone to
 answer.
 Do you perhaps mean the max processed_seq in each table?




 On Saturday, October 20, 2012 10:53:28 AM UTC+1, praveen krishna wrote:

 Hii,
  I have two tables
 db.define_table('plugin_seq',
 Field('filename',readable=**False,writable=False),
 Field('raw_seq','text'),
 Field('processed_seq', 'text'),
 Field('reverse_seq','text')

 )
 db.define_table('primer_seq',**Field('filename',readable=**
 False,writable=False),
 Field('raw_seq','text'),
 Field('processed_seq', 'text'),
 )



 I want to compare the processed_seq field in the two tables what can be
 possible approach I have tried by creating two forms for each table but its
 not working.

  --





-- 





[web2py] Re: auth.wiki() '_create' doesn't redirect properly

2012-10-20 Thread villas
Hi Alan
I was only talking about the specific feature of putting this into a view:  
{{=auth.wiki('slug')}}
I really like auth.wiki(),  but being used in that way (inside a view) it 
misbehaves, as I described.
If it doesn't find a wiki page,  I would sometimes prefer it to fail 
silently and return  or None, for example.
I especially don't want a broken redirect.
Regards, D


On Friday, October 19, 2012 5:43:17 PM UTC+1, Alan Etkin wrote:

  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] how to loop through tables with 1M records?

2012-10-20 Thread Niphlod
just sent the patch to Massimo. If you're in a hurry, as soon as it is 
committed just replace your gluon/scheduler.py with the one from trunk 

Thanks for pointing out this misbehaviour of the scheduler.

On Saturday, October 20, 2012 8:25:12 PM UTC+2, Niphlod wrote:

 You're right, there's a bug: for zillions of queued tasks at the same 
 priority (i.e. got queued first) the bunch we assign on every loop 
 doesn't take into account that there might be 10 or 20 tasks to assign and 
 execute on a faster pace in the following bunch(es). Nice catch! 
 reviewing the logic right now.

 BTW: mysched.queue_task is available only in trunk, it was just a teaser 
 :P  

 On Saturday, October 20, 2012 7:27:55 PM UTC+2, Adi wrote:

 i can confirm that size of the queued records has something to do with 
 delay to process different queues... once i deleted all outstanding records 
 from main group, fast_track group started working as expected... sorry for 
 a long thread, but i think it's a very neat idea to load scheduler with 
 lots of records which will be processed in a back-end process, while 
 fast-track works in it's own (faster) pace... 

 On Sat, Oct 20, 2012 at 12:03 PM, Adnan Smajlovic 
 adnan.s...@gmail.comwrote:

 couple things happened... 

 The main group worker got created even though I didn't call it... Not 
 sure why, but i guess because there are lot of leftover tasks queued (500k) 
 and some were assigned when I stopped the process. 

 Even though fast_tack worker started, nothing is getting picked, 
 assigned nor completed... I checked the time, conditions, and it should be 
 picked... 

 Only main are getting assigned, but they are not getting completed, even 
 though they were completing when I had only main group specified, without 
 fast_track, and slow_track

 exec python26 /opt/web-apps/web2py/web2py.py -K 
 crm:fast_track,crm:slow_track   /var/log/web2py-scheduler.log 



 On Sat, Oct 20, 2012 at 11:13 AM, Adnan Smajlovic 
 adnan.s...@gmail.comwrote:

 all clear :) in process of implementing. 

 Is new api defined in scheduler.py, since i don't see it in there (2.1.1 
 (2012-10-17 17:00:46) dev), but I'm modifying the existing code to 
 employ fast_track, since order confirmations are getting behind. This will 
 be really good :) Thanks again, and again...

 On Sat, Oct 20, 2012 at 10:37 AM, Niphlod nip...@gmail.com wrote:

 no prio available (it's hard to manage a task queued 3 hours ago 
 with prio 7 comes before of after one with prio 8 queued 2 hours ago ?).

 hackish way: tasks are picked up ordered by next_run_time. So, queue 
 your tasks with next_runtime = request.now - datetime.timedelta(hours=1) 
 kinda works. 

 Right way: separate queues, important tasks and less important 
 tasks.  You can create different queues assigning different group_name 
 to 
 tasks and start - at least 2 - separate scheduler processes. By default 
 tasks are in the group 'main', and the scheduler worker processes those 
 only


 Then, start one scheduler per queue with
 web2py.py -K appname:fast_track,appname:

 def task1(a, b=2):
  #need high prio

 def task2(a, b=2):
 #needs low prio

 from gluon.scheduler import Scheduler
 mysched = Scheduler(db)

 #new api
 mysched.queue_task(task1, ['a'], {'b': 1}, group_name='fast_track')
 mysched.queue_task(task2, ['a'], {'b' : 1}, group_name='slow_track')

 #old api
 from gluon.serializers import json
 db.scheduler_task.validate_and_insert(function_name='task1', args=json
 (['a']), vars=json({'b':1}), group_name='fast_track')
 db.scheduler_task.validate_and_insert(function_name='task2', args=json
 (['a']), vars=json({'b':1}), group_name='slow_track')

 slow_track

 If you just need some important tasks without assignign slow_track 
 to the zillions you have already, just forget about the 
 group_name='slow_track' and start schedulers with this command line
 web2py.py -K appname,appname:fast_track
 Then assign to fast_track only the ones you want to exec first and, 
 assuming that fast_track has less tasks in queue, they will be executed 
 before the zillion ones in the main group.

 Clear ?

  


-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Niphlod



 The main group worker got created even though I didn't call it... Not sure 
 why, but i guess because there are lot of leftover tasks queued (500k) and 
 some were assigned when I stopped the process. 

 Remind that a group_name for tasks is required for the scheduler to work. 
However, the default value is 'main', so when you do
db.scheduler_task.validate_and_insert(function_name='test') 
what is really happening is 
db.scheduler_task.validate_and_insert(function_name='test', 
group_name='main')

If you start a scheduler with default values, it processes tasks with 
group_name = 'main', so when you do
web2py.py -K crm
what is really happening is
web2py.py -K crm:main

This is meant to avoid the hassle of group_name(ing) tasks for users that 
don't need different group_names but allow power-users (like you :P) with 
the added flexibility of having different ones.

-- 





[web2py] Re: fake_migrate help

2012-10-20 Thread Massimo Di Pierro
To me it looks like you do not have the folder

/home/www-data/web2py/applications/app/databases

of you do not have the right permissions on the folder

On Saturday, 20 October 2012 10:53:46 UTC-5, lyn2py wrote:

 Thanks Massimo, I have looked at the error log files (production site), 
 and found this traceback:

 __db_meta_setup: 
 /home/www-data/web2py/applications/app/cache/cache.shelve.db: unexpected 
 file type or format
 ERROR:web2py:Traceback (most recent call last):
   File /home/www-data/web2py/gluon/restricted.py, line 209, in restricted
 exec ccode in environment
   File applications/myapp/compiled/models/db2.py, line 36, in module
   File /home/www-data/web2py/gluon/tools.py, line 1497, in define_tables
 format='%(first_name)s %(last_name)s (%(id)s)'))
   File /home/www-data/web2py/gluon/dal.py, line 7095, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File /home/www-data/web2py/gluon/dal.py, line 7126, in 
 lazy_define_table
 polymodel=polymodel)
   File /home/www-data/web2py/gluon/dal.py, line 896, in create_table
 logfile = self.file_open(table._loggername, 'a')
   File /home/www-data/web2py/gluon/dal.py, line 646, in file_open
 fileobj = portalocker.LockedFile(filename,mode)
   File /home/www-data/web2py/gluon/portalocker.py, line 121, in __init__
 self.file = open(filename,mode.replace('w','a'))
 IOError: [Errno 2] No such file or directory: 
 '/home/www-data/web2py/applications/app/databases/sql.log'

 Hope it helps!


 On Saturday, October 20, 2012 8:21:10 PM UTC+8, Massimo Di Pierro wrote:

 When you get an unkown error there is a traceback in the console or 
 apache logs. Can I see the traceback?

 On Saturday, 20 October 2012 04:04:22 UTC-5, lyn2py wrote:

 I performed as Massimo's suggestion,
 fake_migrate_all=True,migrate_enabled=True

 But I ran into an Internal Error: Unknown. (no ticket).



 On Thursday, October 18, 2012 8:17:23 PM UTC+8, Massimo Di Pierro wrote:

 You mean you do not see the .table files?

 Try:
 fake_migrate_all=True,migrate_enabled=True
 could be an error in the book.

 On Thursday, 18 October 2012 01:29:42 UTC-5, lyn2py wrote:

 Hello all, something went wrong with the database table files, and 
 they were accidentally completely removed (the whole database folder).

 I need to rebuild all the database files, so I did:
 db = DAL('postgres://',fake_migrate_all=True,migrate_enabled=
 False)

 According to the manual, this is supposed to rebuild the database 
 table files, but I still don't see the database folder appearing in the 
 app's folder.

 May I know what I should do to fix migrations?

 Thank you!



-- 





Re: [web2py] Re: Version 2.1.1 error: Table' object has no attribute '_id'

2012-10-20 Thread ochiba77
Yeah, I think you're right.
I already fix my app so it's good now!!

Sent from my Verizon Wireless BlackBerry

-Original Message-
From: villas villa...@gmail.com
Sender: web2py@googlegroups.com
Date: Sat, 20 Oct 2012 11:44:47 
To: web2py@googlegroups.com
Reply-To: web2py@googlegroups.com
Subject: [web2py] Re: Version 2.1.1 error: Table' object has no attribute '_id'

Hi Omi
I don't think composite primary keys have ever been supported,  so I 
suppose you would be on your own with that design strategy and who knows 
how it worked!   :)
D


On Friday, October 19, 2012 10:38:21 PM UTC+1, Omi Chiba wrote:

 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),
 

[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
How about adding a gae only parameter to the gae adapter_args that tells it 
to skip fetch?

On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:

 It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
 https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
  
 which returns an iterator.
  - pass that iterator to the datastore delete method (
 https://developers.google.com/appengine/docs/python/datastore/functions#delete
 )

 this avoids the cost of loading the rows into memory, decreases the 
 likelihood of timeout, and has the cost of 1 datastore small operation per 
 row.  but it does prevent us from getting a count of rows deleted.

 the way we do it now:
  - run count() on the query.  this has a cost (time and money) of 
 iterating over all the rows that match the query on GAE (1 datastore small 
 operation per row)
  - run fetch(limit=1000) and call delete() successively until no more 
 rows.  this has the cost of running a full query (at least 1 datastore read 
 operation per row) and loading the result set into memory and then deleting 
 the results.

 in my case i'm timing out on the count() call so i don't even start the 
 delete.  from an efficiency standpoint i'd rather have more rows deleted 
 for less cost then get a countbut this may not be acceptable for all. 
  at a minimum i think we should switch to use keys_only=True for the fetch, 
 and skip the leading count() call and just sum the number of times we call 
 fetch.  we may also consider catching the datastore timeout error and 
 trying to handle a partial delete more gracefully (or continue to let the 
 user catch the error).

 what is the right approach for web2py?  if the approach with count is 
 correct, could i propose a gae bulk_delete method that does not return 
 count but uses my first method?

 thanks for the input!

 cfh

 On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian



-- 





[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
I meant to skip count.

On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote:

 How about adding a gae only parameter to the gae adapter_args that tells 
 it to skip fetch?

 On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:

 It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
 https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
  
 which returns an iterator.
  - pass that iterator to the datastore delete method (
 https://developers.google.com/appengine/docs/python/datastore/functions#delete
 )

 this avoids the cost of loading the rows into memory, decreases the 
 likelihood of timeout, and has the cost of 1 datastore small operation per 
 row.  but it does prevent us from getting a count of rows deleted.

 the way we do it now:
  - run count() on the query.  this has a cost (time and money) of 
 iterating over all the rows that match the query on GAE (1 datastore small 
 operation per row)
  - run fetch(limit=1000) and call delete() successively until no more 
 rows.  this has the cost of running a full query (at least 1 datastore read 
 operation per row) and loading the result set into memory and then deleting 
 the results.

 in my case i'm timing out on the count() call so i don't even start the 
 delete.  from an efficiency standpoint i'd rather have more rows deleted 
 for less cost then get a countbut this may not be acceptable for all. 
  at a minimum i think we should switch to use keys_only=True for the fetch, 
 and skip the leading count() call and just sum the number of times we call 
 fetch.  we may also consider catching the datastore timeout error and 
 trying to handle a partial delete more gracefully (or continue to let the 
 user catch the error).

 what is the right approach for web2py?  if the approach with count is 
 correct, could i propose a gae bulk_delete method that does not return 
 count but uses my first method?

 thanks for the input!

 cfh

 On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your 
 proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long 
 time to get to this and now my GAE delete is just timing out.  Reading the 
 GAE docs, there appears to be some improvements that we can make to the 
 query delete method on GAE that will make it faster and cheaper.  what we 
 lose then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() 
 that does not return a count break the web2py API contract, or break 
 anyone's applications?

 thanks,

 christian



-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-20 Thread Alan Etkin
 I really appreciate if you can write an example that access wiki_page 
without the use of auth_wiki interface. (just one wiki_page is 
 enough)

Posted this same answer somewhere (perhaps I just emailed it to apps in 
tables, who knows)

I made a 
web2pyslicehttp://www.web2pyslices.com/slice/show/1565/wikifying-web2py-appswith
 tips for using the new wiki feature (including villas first example 
for retrieving a page body)

-- 





[web2py] Re: about constraints on fields of table

2012-10-20 Thread villas
In my experience a time field is more or less useless and you may as well 
store the time as a string.  I think everyone else may feel the same,  
which is why IS_TIME still has no format validation even after 5 years.

If you don't want to store as a string,  then if I were you,  I would store 
as datetime and just have the same default date in every datetime field. It 
isn't difficult to discard the unwanted date.

However,  maybe others have a different view...

On Wednesday, October 17, 2012 6:52:58 PM UTC+1, dantuluri jaganadha raju 
wrote:

 I kept field('aaa', requires=IS_DATE(format='%H:%M')) . and when I try 
 to open database administration and that particular table I am getting 
 error 
 str' object has no attribute 'year'. and more over I want only time as 
 input to a field

Thank in advance.

 On Friday, October 12, 2012 10:44:23 AM UTC+5:30, dantuluri jaganadha raju 
 wrote:

 Hi,
  I want to accept only 9 digit number as input to one field and 
 other's are invalid. and in another field I want to accept time format of 
 form (hours:minutes to hours:minutes).
  
Thank you in advance...



-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-20 Thread villas
It's good to have some extra wiki info available to get people started.  
LOL looks like you already made yourself an interesting blog there too! 
D

On Saturday, October 20, 2012 9:51:46 PM UTC+1, Alan Etkin wrote:

  I really appreciate if you can write an example that access wiki_page 
 without the use of auth_wiki interface. (just one wiki_page is 
  enough)

 Posted this same answer somewhere (perhaps I just emailed it to apps in 
 tables, who knows)

 I made a 
 web2pyslicehttp://www.web2pyslices.com/slice/show/1565/wikifying-web2py-appswith
  tips for using the new wiki feature (including villas first example 
 for retrieving a page body)



-- 





[web2py] Re: about constraints on fields of table

2012-10-20 Thread Niphlod
+1, although what IS_TIME does (e.g. 0-24 for hours, 1-12 if am-pm is 
there, 0-60 for minutes, etc) fills all possible requirements for a 
single input.



 and in another field I want to accept time format of form (hours:minutes 
 to hours:minutes).



What the user asked for I think is a duration, not time:
- totally different concept
- needs a custom validator
- can only be stored as a string (or an integer storing the difference 
bewteen in seconds)
- and must be parsed externally to return a timedelta

On Saturday, October 20, 2012 10:53:56 PM UTC+2, villas wrote:

 In my experience a time field is more or less useless and you may as well 
 store the time as a string.  I think everyone else may feel the same,  
 which is why IS_TIME still has no format validation even after 5 years.

 If you don't want to store as a string,  then if I were you,  I would 
 store as datetime and just have the same default date in every datetime 
 field. It isn't difficult to discard the unwanted date.

 However,  maybe others have a different view...



-- 





[web2py] Re: Loading modules fails - web2py 2.1.1(and earlier) / python 2.7.1 / Mac OS X

2012-10-20 Thread Massimo Di Pierro
I just tried this (using OSX binary distribution -nightly built) and I 
cannot reproduce it. Could you try it?

Massimo

On Saturday, 20 October 2012 11:32:55 UTC-5, Luciano Laporta Podazza wrote:

 Hello Massimo!, comments inline.

 On Saturday, October 20, 2012 11:43:43 AM UTC-3, Massimo Di Pierro wrote:

 I am very puzzled but this. It should not be necessary. Does the code 
 below work for you?

 $ python web2py.py -S welcome 
 (InteractiveConsole)
  import simplejson


 If I use web2py.app(Mac OS) it doesn't work:

 Silver-2:Resources keniobats$ pwd
 /Users/keniobats/Downloads/web2py/web2py.app/Contents/Resources
 Silver-2:Resources keniobats$ python web2py.py -S welcome
 Traceback (most recent call last):
   File web2py.py, line 16, in module
 import gluon.widget
 ImportError: No module named gluon.widget
 Silver-2:Resources keniobats$ 

 If I use the source version it works well:

 Silver-2:web2py 2 keniobats$ python web2py.py -S welcome
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2012
 Version 2.0.9 (2012-09-13 23:51:30) stable
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
 PostgreSQL(pg8000), IMAP(imaplib)
 WARNING:web2py:import IPython error; use default python shell
 Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
 [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
 darwin
 Type help, copyright, credits or license for more information.
 (InteractiveConsole)
  import simplejson
  



  


 Do you have a module called simplejson in yourapp/modules/? 


 I have nothing but my facebook.py module there.
  


 From a normal python shell, shat happens if you do?

  import simplejson


 Silver-2:~ keniobats$ pwd
 /Users/keniobats
 Silver-2:~ keniobats$ python
 Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
 [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
 darwin
 Type help, copyright, credits or license for more information.
  import simplejson
  

 It works as usual :)

 Hope it helps, thanks Massimo!


-- 





[web2py] Re: appadmin upload from iPhone gives empty record.

2012-10-20 Thread Massimo Di Pierro
Can you somehow log request.vars.file on upload? The issue is to determine 
whether the file is there or not.

On Saturday, 20 October 2012 12:42:55 UTC-5, Richard wrote:

 Hi,

 I want to use Web2Py as much as possible. For a holiday blog I want to 
 upload photo's from my iPhone using appadmin.
 From my windows PC this works file. I get a file location and a file which 
 i can view.

 But an upload from my iPhone gives no error, a new record is created but 
 without image.file which must contain a link to the upload photo.

 I use the easy db definition:

 db.define_table(
 'loc',
 Field('location'),
 format = '%(location)s'
 )

 db.define_table(
'image',
Field('loc', 'reference loc'),
Field('title', unique=True),
Field('file', 'upload'),
format = '%(title)s'
)

 Does anybody has a clu?

 Richard.


-- 





Re: [web2py] Re: Loading modules fails - web2py 2.1.1(and earlier) / python 2.7.1 / Mac OS X

2012-10-20 Thread Luciano Laporta Podazza
On Sat, Oct 20, 2012 at 7:35 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I just tried this (using OSX binary distribution -nightly built) and I
 cannot reproduce it. Could you try it?


Sure!, I'll do it right now and get back to you.



 Massimo


 On Saturday, 20 October 2012 11:32:55 UTC-5, Luciano Laporta Podazza wrote:

 Hello Massimo!, comments inline.

 On Saturday, October 20, 2012 11:43:43 AM UTC-3, Massimo Di Pierro wrote:

 I am very puzzled but this. It should not be necessary. Does the code
 below work for you?

 $ python web2py.py -S welcome
 (InteractiveConsole)
  import simplejson


 If I use web2py.app(Mac OS) it doesn't work:

 Silver-2:Resources keniobats$ pwd
 /Users/keniobats/Downloads/**web2py/web2py.app/Contents/**Resources
 Silver-2:Resources keniobats$ python web2py.py -S welcome
 Traceback (most recent call last):
   File web2py.py, line 16, in module
 import gluon.widget
 ImportError: No module named gluon.widget
 Silver-2:Resources keniobats$

 If I use the source version it works well:

 Silver-2:web2py 2 keniobats$ python web2py.py -S welcome
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2012
 Version 2.0.9 (2012-09-13 23:51:30) stable
 Database drivers available: SQLite(sqlite3), MySQL(pymysql),
 PostgreSQL(pg8000), IMAP(imaplib)
 WARNING:web2py:import IPython error; use default python shell
 Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
 [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
 darwin
 Type help, copyright, credits or license for more information.
 (InteractiveConsole)
  import simplejson
 






 Do you have a module called simplejson in yourapp/modules/?


 I have nothing but my facebook.py module there.



 From a normal python shell, shat happens if you do?

  import simplejson


 Silver-2:~ keniobats$ pwd
 /Users/keniobats
 Silver-2:~ keniobats$ python
 Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
 [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
 darwin
 Type help, copyright, credits or license for more information.
  import simplejson
 

 It works as usual :)

 Hope it helps, thanks Massimo!

  --







-- 
Atte
Luciano Laporta Podazza

-- 





[web2py] Geolocation

2012-10-20 Thread Michael Gheith
Hello web2py community!

I have a question:

I know how to get the user's geolocation:

script
if(navigator.geolocation) 
{
navigator.geolocation.getCurrentPosition(printLocation);

function printLocation(position) 
{
alert(lat:  +position.coords.latitude +  lon:  + 
position.coords.longitude);
}
}
/script


So my question is this:  what's the BEST way to get position.coords.latitude, 
and position.coords.longitude to a controller function?

-- 





[web2py] Re: Geolocation

2012-10-20 Thread Massimo Di Pierro
You can try something like

jQuery.post({'url':'{{=URL('youraction')}}','data':'a='+position.coords.latitude
 
+ b + position.coords.longitude)});



On Saturday, 20 October 2012 17:42:15 UTC-5, Michael Gheith wrote:

 Hello web2py community!

 I have a question:

 I know how to get the user's geolocation:

 script
 if(navigator.geolocation) 
 {
 navigator.geolocation.getCurrentPosition(printLocation);

 function printLocation(position) 
 {
 alert(lat:  +position.coords.latitude +  lon:  + 
 position.coords.longitude);
 }
 }
 /script


 So my question is this:  what's the BEST way to get position.coords.latitude, 
 and position.coords.longitude to a controller function?



-- 





[web2py] SQLFORM.grid search field

2012-10-20 Thread Tito Garrido
Since start with, contains is not translatable should we give it as an
option? Is there a way to leave just the first search field and hide the
other options?

Regards,

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] Re: Geolocation

2012-10-20 Thread Michael Gheith
Awesome.  Thank you so much Massimo!

On Saturday, October 20, 2012 5:52:24 PM UTC-5, Massimo Di Pierro wrote:

 You can try something like

 jQuery.post({'url':'{{=URL('youraction')}}','data':'a='+position.coords.latitude
  
 + b + position.coords.longitude)});



 On Saturday, 20 October 2012 17:42:15 UTC-5, Michael Gheith wrote:

 Hello web2py community!

 I have a question:

 I know how to get the user's geolocation:

 script
 if(navigator.geolocation) 
 {
 navigator.geolocation.getCurrentPosition(printLocation);

 function printLocation(position) 
 {
 alert(lat:  +position.coords.latitude +  lon:  + 
 position.coords.longitude);
 }
 }
 /script


 So my question is this:  what's the BEST way to get 
 position.coords.latitude, and position.coords.longitude to a controller 
 function?



-- 





Re: [web2py] web2py integration with apache alongside PHP

2012-10-20 Thread Simon Carr
Hi Kenneth,

Sorry for the delay in getting back to you. Yes, if you could send me a 
copy of your vhosts file it might be very useful. 

Regards
Simon

On Saturday, 13 October 2012 09:11:03 UTC+1, Kenneth wrote:

  Hi,

 the is no problems running both PHP and web2py side by side. If you're 
 running Apache the easiest way of setting up web2py is to use a subdomain, 
 like web2py.yourdomain.com, and vhosts in Apache. 

 If you'd like a copy of one of my vhost files for a web2py site let me 
 know and I'll send you one. 


 Kenneth

  I currently have a VPS which I am hosting active sites for my customers 
 in PHP. In future I would like to write apps for my customers in web2py and 
 host them on the same server. From what I have seen it seems possible, but 
 I can't find any clear instructions.  

  Can someone point me to a link that describes the process in an easy to 
 understand way. Also Can anyone point out what risks I have to consider 
 with regard to my customers current websites running in PHP.

  Thanks
 Simon
 -- 
  
  
  


  

-- 





[web2py] auth.wiki search is case sensitive, only works with all lower-case?

2012-10-20 Thread HittingSmoke
I was about to submit this as an issue but I figured since it's 
experimental still I should ask if there's something more behind this 
behavior that I'm not understanding.

I made a wiki page with tags. The tags start with a capital letter 
(Youtube) because I'm anal about such things. When I click the tag link at 
the bottom of the wiki article I get a search page that reports no results.

However if I manually search and use all lower case (youtube) all articles 
tagged Youtube show up in the search results.

I'm guessing this is a bug, and if so I'll submit it as such. I just wanted 
to clarify.

-- 





[web2py] Re: auth.wiki search is case sensitive, only works with all lower-case?

2012-10-20 Thread Massimo Di Pierro
I agree there is a bug. Question: should tags youtube and Youtube be 
treated as different? Should capitalization be retained?

For now I fixed iit in trunk so that is always stores tages in wiki_tags in 
lower case and treats youtube and Youtube as equivalent even if it retain 
the original capitalization in the page tag field. Please check it out.

Massimo

On Saturday, 20 October 2012 19:25:44 UTC-5, HittingSmoke wrote:

 I was about to submit this as an issue but I figured since it's 
 experimental still I should ask if there's something more behind this 
 behavior that I'm not understanding.

 I made a wiki page with tags. The tags start with a capital letter 
 (Youtube) because I'm anal about such things. When I click the tag link at 
 the bottom of the wiki article I get a search page that reports no results.

 However if I manually search and use all lower case (youtube) all articles 
 tagged Youtube show up in the search results.

 I'm guessing this is a bug, and if so I'll submit it as such. I just 
 wanted to clarify.


-- 





[web2py] web2py shell window problem

2012-10-20 Thread Jscriptor09
Hi
 
I am trying to learn web2py using the online book.
 
Page 45 provide instruction on how to use the interactive shell
 
However, the coomands are not getting executed.
 
For a minor line command 
a=3
print type(a)
 
I get this
web2py Shell (2, 1, 1, datetime.datetime(2012, 10, 15, 12, 44, 40), 
'stable')In [1] : a=3
In [2] : print type(a)
in the upper window as opposed to something like this for a regular Python 
Dos window:
 
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] 
on win32
Type help, copyright, credits or license for more information.
 a=3
 print a
3


Anythough on how to use the interactive window inweb2py would be 
appreciated.   I hate to move on to next chapter before getting this right.
 
I am using IE9
 
thanks
Mike
 

-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Adnan Smajlovic
will try to replacing scheduler.py in production and load some serious data
again, since all is setup there for the full process, so we can have a real
test :)

I understand the concept with main being the default group, but wasn't sure
if I was doing something wrong. All clear now :) Thanks for fixing it, and
will let you know results soon.


On Sat, Oct 20, 2012 at 4:10 PM, Niphlod niph...@gmail.com wrote:



 The main group worker got created even though I didn't call it... Not
 sure why, but i guess because there are lot of leftover tasks queued (500k)
 and some were assigned when I stopped the process.

 Remind that a group_name for tasks is required for the scheduler to work.
 However, the default value is 'main', so when you do
 db.scheduler_task.validate_and_insert(function_name='test')
 what is really happening is
 db.scheduler_task.validate_and_insert(function_name='test',
 group_name='main')

 If you start a scheduler with default values, it processes tasks with
 group_name = 'main', so when you do
 web2py.py -K crm
 what is really happening is
 web2py.py -K crm:main

 This is meant to avoid the hassle of group_name(ing) tasks for users that
 don't need different group_names but allow power-users (like you :P) with
 the added flexibility of having different ones.

 --



-- 





Re: [web2py] Re: delete on GAE

2012-10-20 Thread Christian Foster Howes

sure.  i'll make a patch soon...

thanks for the input!

cfh

On 10/20/12 13:29 , Massimo Di Pierro wrote:

I meant to skip count.

On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote:


How about adding a gae only parameter to the gae adapter_args that tells
it to skip fetch?

On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:


It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
which returns an iterator.
  - pass that iterator to the datastore delete method (
https://developers.google.com/appengine/docs/python/datastore/functions#delete
)

this avoids the cost of loading the rows into memory, decreases the
likelihood of timeout, and has the cost of 1 datastore small operation per
row.  but it does prevent us from getting a count of rows deleted.

the way we do it now:
  - run count() on the query.  this has a cost (time and money) of
iterating over all the rows that match the query on GAE (1 datastore small
operation per row)
  - run fetch(limit=1000) and call delete() successively until no more
rows.  this has the cost of running a full query (at least 1 datastore read
operation per row) and loading the result set into memory and then deleting
the results.

in my case i'm timing out on the count() call so i don't even start the
delete.  from an efficiency standpoint i'd rather have more rows deleted
for less cost then get a countbut this may not be acceptable for all.
  at a minimum i think we should switch to use keys_only=True for the fetch,
and skip the leading count() call and just sum the number of times we call
fetch.  we may also consider catching the datastore timeout error and
trying to handle a partial delete more gracefully (or continue to let the
user catch the error).

what is the right approach for web2py?  if the approach with count is
correct, could i propose a gae bulk_delete method that does not return
count but uses my first method?

thanks for the input!

cfh

On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:


Delete should return the number of deleted records. What is your
proposal?

On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:


Hi all,

I'm trying to clean up old expired sessions.but i waited a long
time to get to this and now my GAE delete is just timing out.  Reading the
GAE docs, there appears to be some improvements that we can make to the
query delete method on GAE that will make it faster and cheaper.  what we
lose then is the count of the number of rows deleted.

my question is, does having a db(db.table.something==True).delete()
that does not return a count break the web2py API contract, or break
anyone's applications?

thanks,

christian







--





[web2py] Re: is it possible to run web2py parallel to php on apache port 80?

2012-10-20 Thread Simon Carr
Hi Massimo,

I have run your script on a test box (linux mint) and it worked just fine. 
It got me running web2py with Apache.

Can you elaborate on what I need to do in order to also get php working. I 
copied that code you wrote Location /php/Location into the apache 
configuration file. I then visited http://localhost/php and I put a php 
file in /home/php, but I get the error 'invalid request'.

Many thanks
Simon

On Sunday, 29 July 2012 20:22:29 UTC+1, Massimo Di Pierro wrote:

 Yes but I have not done it. My understanding is that you can use a 
 configuration such as described here:


 https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-ubuntu.sh#L80

 and within the same virtualhost you map some paths to the php folder

 Location /php
   php_admin_value open_basedir /home/php/
   php_admin_value upload_tmp_dir /tmp
 /Location



 On Sunday, July 29, 2012 1:18:37 PM UTC-5, Robin Manoli wrote:

 Hey,
 I'm wondering if it is possible to run web2py on the same port as other 
 php-websites run. I have a normally configured LAMP, and I can install the 
 required apache mod. Then the question is if a web2py app can run parallel, 
 just as different php/html sites do with different domain names, using port 
 80?

 Thanks for your help



-- 





Re: [web2py] how to loop through tables with 1M records?

2012-10-20 Thread Adnan Smajlovic
hmm... seems like we still have the same problem, unless i was supposed to
copy more files than just scheduler.py

loaded around 12,000 records into slow_track, while fast_track has very
few, but some should be executed by now...

3 workers are properly running (main, slow_track, fast_track), but no tasks
are being executed at this point. restarted apache, stopped and started
scheduler several times.

that's the situation at this point... not sure if i could test something
more specific to figure out what is going on?


On Sat, Oct 20, 2012 at 9:05 PM, Adnan Smajlovic
adnan.smajlo...@gmail.comwrote:

 will try to replacing scheduler.py in production and load some serious
 data again, since all is setup there for the full process, so we can have a
 real test :)

 I understand the concept with main being the default group, but wasn't
 sure if I was doing something wrong. All clear now :) Thanks for fixing it,
 and will let you know results soon.



 On Sat, Oct 20, 2012 at 4:10 PM, Niphlod niph...@gmail.com wrote:



 The main group worker got created even though I didn't call it... Not
 sure why, but i guess because there are lot of leftover tasks queued (500k)
 and some were assigned when I stopped the process.

 Remind that a group_name for tasks is required for the scheduler to
 work.
 However, the default value is 'main', so when you do
 db.scheduler_task.validate_and_insert(function_name='test')
 what is really happening is
 db.scheduler_task.validate_and_insert(function_name='test',
 group_name='main')

 If you start a scheduler with default values, it processes tasks with
 group_name = 'main', so when you do
 web2py.py -K crm
 what is really happening is
 web2py.py -K crm:main

 This is meant to avoid the hassle of group_name(ing) tasks for users that
 don't need different group_names but allow power-users (like you :P) with
 the added flexibility of having different ones.



-- 





[web2py] Re: auth.wiki search is case sensitive, only works with all lower-case?

2012-10-20 Thread HittingSmoke
Personally I think it should retain case in the tag but all searching 
should not be case sensitive. Retaining case is good for readability and 
navigation.

On Saturday, October 20, 2012 5:39:54 PM UTC-7, Massimo Di Pierro wrote:

 I agree there is a bug. Question: should tags youtube and Youtube be 
 treated as different? Should capitalization be retained?

 For now I fixed iit in trunk so that is always stores tages in wiki_tags 
 in lower case and treats youtube and Youtube as equivalent even if it 
 retain the original capitalization in the page tag field. Please check it 
 out.

 Massimo

 On Saturday, 20 October 2012 19:25:44 UTC-5, HittingSmoke wrote:

 I was about to submit this as an issue but I figured since it's 
 experimental still I should ask if there's something more behind this 
 behavior that I'm not understanding.

 I made a wiki page with tags. The tags start with a capital letter 
 (Youtube) because I'm anal about such things. When I click the tag link at 
 the bottom of the wiki article I get a search page that reports no results.

 However if I manually search and use all lower case (youtube) all 
 articles tagged Youtube show up in the search results.

 I'm guessing this is a bug, and if so I'll submit it as such. I just 
 wanted to clarify.



--