Re: [web2py] Re: How to build a modular menu

2012-07-16 Thread Johann Spies
Thanks Jaap and Cliff.
It was helpful.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Need a little help with DAL

2012-07-16 Thread pbreit
Looks like it is comparing them as strings. As others noted, need to see 
code.

-- 





[web2py] Re: pg8000 '%' not supported in quoted string

2012-07-16 Thread KMax
Ок. I will post it here.

вторник, 17 июля 2012 г., 3:36:09 UTC+7 пользователь Derek написал:
>
> So escape it. In Python, % usually refers to a variable that follows the 
> string. If you want a literal percent sign, then you need to double it. %%.
> Seems like gluon is not escaping it properly. If you can post your whole 
> traceback, I could help you to find out what file you need to add the extra 
> escaping.
>
> On Monday, July 16, 2012 4:34:07 AM UTC-7, KMax wrote:
>>
>> Hello,
>>  Seems like an issue for me, pg8000 cant insert into db char '%'.
>>  As a result inserting string = 'We did it for 100%' throw an exception.
>>  
>>  '%'' not 
>> supported in quoted string
>>
>>  pg8000 checks for '%' in an argument, so...
>>
>> Thank you.
>> --
>> Maxim
>>
>

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-16 Thread Anthony
Can you elaborate?

On Tuesday, July 17, 2012 12:24:37 AM UTC-4, amit wrote:
>
> Old thread, but this would trigger a race condition in case of multiple 
> concurrent users. 
>
> On Friday, June 17, 2011 5:12:27 AM UTC+8, JayShaffstall wrote:
>>
>> I'd been thinking I needed to do that between form creation and the
>> accepts call, but you're right, it works even after that point.  I
>> make the call to auth.register, and then modify the readonly
>> attribute, and it works fine.
>>
>> Thanks!
>> Jay
>>
>

-- 





[web2py] Re: Funny observed behaviour in custom form

2012-07-16 Thread Anthony
By default, form.accepts() does the insert automatically (unless you set 
dbio=False), and your redirect doesn't happen until after the insert.

Anthony

On Tuesday, July 17, 2012 12:38:02 AM UTC-4, Pystar wrote:
>
> I have a controller that presents a form, but I put a constraint that if 
> the user is not logged on (checked using auth.is_logged_in()) the entered 
> form data should not be inserted but the user should be directed to the 
> login form. But to my surprise, if the user is redirected to the logged in 
> form and without logging in, returns back to the index page, the data would 
> have been inserted into the database which shouldnt be so. What am I doing 
> wrong here?
>
> Code snippet
>
> def index():
> form = SQLFORM(db.post)
> if form.accepts(request.vars, session, hideerror=True, 
> keepvalues=False):
> if auth.is_logged_in():
> pass
> else:
> session.flash="You have to be logged on to post stuff!"
> redirect(URL(f="user", args="login"))
> elif form.errors:
> redirect(URL(f="index"))
> rows = db().select(db.post.ALL, orderby=db.post.timestamp)
> return locals()
>

-- 





[web2py] How to start a thread upon starting of webserver?

2012-07-16 Thread Amit
Hi,
I have one timer thread which has to start once when web sever starts very 
first time and stop when web server stops, means it should be running 
continuously irrespective of how many users interacting with the 
application so there is only one instance of this thread running though out 
life of the application , it is common for all users who are accessing the 
application.

How to achieve it in web2py?

-- 





[web2py] Funny observed behaviour in custom form

2012-07-16 Thread Pystar
I have a controller that presents a form, but I put a constraint that if 
the user is not logged on (checked using auth.is_logged_in()) the entered 
form data should not be inserted but the user should be directed to the 
login form. But to my surprise, if the user is redirected to the logged in 
form and without logging in, returns back to the index page, the data would 
have been inserted into the database which shouldnt be so. What am I doing 
wrong here?

Code snippet

def index():
form = SQLFORM(db.post)
if form.accepts(request.vars, session, hideerror=True, 
keepvalues=False):
if auth.is_logged_in():
pass
else:
session.flash="You have to be logged on to post stuff!"
redirect(URL(f="user", args="login"))
elif form.errors:
redirect(URL(f="index"))
rows = db().select(db.post.ALL, orderby=db.post.timestamp)
return locals()

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-16 Thread amit
Old thread, but this would trigger a race condition in case of multiple 
concurrent users. 

On Friday, June 17, 2011 5:12:27 AM UTC+8, JayShaffstall wrote:
>
> I'd been thinking I needed to do that between form creation and the
> accepts call, but you're right, it works even after that point.  I
> make the call to auth.register, and then modify the readonly
> attribute, and it works fine.
>
> Thanks!
> Jay
>

-- 





[web2py] Re: response.JSON Decimal problem

2012-07-16 Thread Vineet
I grabbed the latest serializers.py from trunk & the problem is solved.

Thanks,

Vineet

-- 





Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Massimo Di Pierro
Try replace

 request.body = copystream_progress(request) ### stores request body   
  

with

try:
request.body = copystream_progress(request) ### stores request body 
except IOError:
raise HTTP(400,"Bad Request - HTTP body is incomplete")

in main.py. Does the problem goes away? I am afraid any response we 
generate will propagator to the web server and it will log some error on 
failure to respond to the client.

On Monday, 16 July 2012 21:28:14 UTC-5, Bruce Wade wrote:
>
> I personally think if we are just going to leave it as it, then we should 
> not have it create an error ticket as I have had plenty of tickets created 
> by this.
>
> On Mon, Jul 16, 2012 at 7:13 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> The more I think about this the more I am convinced this is not of 
>> concern.
>>
>> It is very well possible that a slow client sends you the header of a 
>> request, then closes the connection before finishing (perhaps the user 
>> killed the page, or stopped the browser while doing an upload or something 
>> slow).
>>
>> At some point web2py fails because of this and apache logs it. Where 
>> web2py fails depends on the exact timing but it likely to fail while 
>> copying the input stream. Which is the error you get.
>>
>> I think it correct to log these events.
>>
>> We could catch this specific error and have a more descriptive error but 
>> - while this is the place which is the most likely to fail - the failure 
>> could be somewhere else and we would not be catching the same error.
>>
>> I do not think this should be changed and I do not think this should be a 
>> concern. It tells you some uses have a slow connection.
>>
>> What do others think?
>>
>>
>> On Monday, July 16, 2012 7:12:16 PM UTC-5, Brian M wrote:
>>>
>>> I'm on Version 1.99.4 (2011-12-22 11:20:45) stable.  Yeah it is a bit 
>>> old - at this point waiting for 2.0 stable to come out.
>>>
>>> On Monday, July 16, 2012 9:58:53 AM UTC-5, Massimo Di Pierro wrote:

 Which web2py version? The error is from copying the request body into a 
 tmp object in web2py. Looks like the request declares a size in the header 
 but it is shorter (truncated).



 On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>
> I'm having ongoing problems with IOErrors from one of my web2py apps 
> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
> maybe happening at a lower level before it even gets to my app code?
>
> Traceback (most recent call last):
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in wsgibase
> parse_get_post_vars(request, environ)
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in 
> parse_get_post_vars
> request.body = copystream_progress(request) ### stores request body
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in 
> copystream_progress
> copystream(source, dest, size, chunk_size)
> File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 374, in 
> copystream
> data = src.read(size)
> IOError: request data read error
>
  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

-- 





Re: [web2py] Re: how to delete records from table older than 1 day?

2012-07-16 Thread Amit
Thanks Niphold, its working as intended :)

On Mon, Jul 16, 2012 at 3:55 PM, Niphlod  wrote:

> Why write such a query when DAL allows you to use a more (portable,
> concise) pythonic way ?
>
> import datetime
> yesterday = request.now - datetime.timedelta(days=1)
> db(db.employee.created_on < yesterday).delete()
>
>
>
> On Monday, July 16, 2012 12:12:56 PM UTC+2, Amit wrote:
>>
>> Hi,
>> I have created table Employe with following fields:
>> db.define_table(
>>'Employee',
>>Field('created_on','datetime', default=request.now),
>>Field('emp_id'),
>>Field('emp_age'),
>>Field('emp_address),
>> )
>>  inserting data into the table is working fine but when i am trying to
>> delete data one day older using below command:
>>
>> db.executesql('DELETE FROM db.Employee WHERE created_on < date_sub(now(),
>> INTERVAL 1 DAY);')
>>
>> It's not working and i am not getting any error also, so can anybody help
>> me resolve this issue.
>> NOTE: I am using Sqlite database.
>>
>>
>>

-- 





[web2py] Re: How to build a modular menu

2012-07-16 Thread Cliff Kachinske
submenu = []
response.menu = [
(T('Home'), False, URL('default', 'index'),  submenu),
]


if needsubmenu:
  sub_submenu = []
  submenu.append([
(T('A submenu item'), False, URL('mygreatapp', blah), sub_submenu),
# more menu items
 ])


if needsub_submenu:
  subsubmenu.append([
 (T('A subsubmenu item') ...Blah),
 #etc
  ])



On Monday, July 16, 2012 8:18:17 AM UTC-4, Johann Spies wrote:
>
> I want to break up the following code to  make it more modular, but I 
> could so far not get it right:
>
> r
> esponse.menu = [
> (T('Home'), URL('default', 'index') == URL(), URL('default', 'index'), 
> []),
> ]
>
> akb_menu = [(T('Africa Knowledgebase'), False, None,
>  [ (T('Articles'), False, None,
>   [
> (T('Add article'), False, URL(request.application, 
> 'articles', 'kryskrywers')),
>
> ]),
>(T('Journals'), False, None,
> [
> (T('List all journals'), False, URL(request.
> application, 'journal', 'journals')),
> ]),
>(T('Authors'), False, None,
> [
>  (T('Add author'), False, URL(request.application, 
> 'authors', 'add_author')),
> ]),
>
>(T('Publications statistics'), False, URL(request.
> application, 'default', 'sa_pubstats')),
> ]
> )
>]
>  )
> ]
>
>
> response.menu += akb_menu
>
>  I want to get the same result as the above menu using this approach:
>
>
> response.menu = [
> (T('Home'), URL('default', 'index') == URL(), URL('default', 'index'), 
> []),
> ]
> akb_menu = [(T('Africa Knowledgebase'), False, None,)]
>
>
> art_menu =   [ (T('Articles'), False, None,
> [
> (T('Add article'), False, URL(request.application, 
> 'articles', 'kryskrywers')),
>
> ])]
>
> auth_menu =   [ (T('Authors'), False, None,
> [
>  (T('Add author'), False, URL(request.application, 
> 'authors', 'add_author')),
> ])]
>
> jrn_menu =   [(T('Journals'), False, None,
> [
> (T('List all journals'), False, URL(request.
> application, 'journal', 'journals')),
> ])]
>
> stat_menu = [(T('Publications statistics'), False, URL(request.application
> , 'default', 'sa_pubstats'))]
> for mn in [art_menu, auth_menu, jrn_menu, stat_menu]:
> akb_menu += mn
>
>
>
> response.menu += akb_menu
>
> Can somebody help me to see where  I made the mistake please.
>
> Regards
> Johann.
>
>

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread Bruce Wade
Yeah I use both approaches, model-less + model folders so I don't have to
import in the actual controllers. I also just use functions instead of
classes to prevent all the extra overhead.

On Mon, Jul 16, 2012 at 2:07 PM, wdtatenh  wrote:

> Thanks very much.  I'm thinking that I'm probably going to have to go to a
> model-less app because this is going to be much bigger given the breadth of
> what I'm trying to accomplish.
>
>
> On Monday, July 16, 2012 4:52:56 PM UTC-4, Derek wrote:
>
>> There should be no benefit to moving them to multiple model files. It
>> would have the same performance (or perhaps slower).
>>
>> The models file is processed on every page load, so it can get expensive
>> if you have a lot of tables defined in it.
>> I'm sure Bruno can chime in here, but here is his recipe for model-less
>> apps...
>> http://www.web2pyslices.com/**slice/show/1479/model-less-**
>> apps-using-data-models-and-**modules-in-web2py
>>
>>
>> On Monday, July 16, 2012 1:45:23 PM UTC-7, wdtatenh wrote:
>>>
>>> I've got to move a bunch of stuff around to speed up my site
>>> particularly on the controller folder.  My question is that I have nearly
>>> 50+ tables defined in my db.py file.  Is there any benefit to splitting
>>> these tables into multiple model files?  The tables belong to a single
>>> database and most use the auth_user table as a referenced table.
>>>
>>> I'm assuming that they're all going to get read in regardless,
>>> therefore, splitting things up into multiple model files wouldn't gain me
>>> anything or am I wrong?
>>>
>>> Thanks in advance.
>>>
>>  --
>
>
>
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruce Wade
I personally think if we are just going to leave it as it, then we should
not have it create an error ticket as I have had plenty of tickets created
by this.

On Mon, Jul 16, 2012 at 7:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The more I think about this the more I am convinced this is not of concern.
>
> It is very well possible that a slow client sends you the header of a
> request, then closes the connection before finishing (perhaps the user
> killed the page, or stopped the browser while doing an upload or something
> slow).
>
> At some point web2py fails because of this and apache logs it. Where
> web2py fails depends on the exact timing but it likely to fail while
> copying the input stream. Which is the error you get.
>
> I think it correct to log these events.
>
> We could catch this specific error and have a more descriptive error but -
> while this is the place which is the most likely to fail - the failure
> could be somewhere else and we would not be catching the same error.
>
> I do not think this should be changed and I do not think this should be a
> concern. It tells you some uses have a slow connection.
>
> What do others think?
>
>
> On Monday, July 16, 2012 7:12:16 PM UTC-5, Brian M wrote:
>>
>> I'm on Version 1.99.4 (2011-12-22 11:20:45) stable.  Yeah it is a bit old
>> - at this point waiting for 2.0 stable to come out.
>>
>> On Monday, July 16, 2012 9:58:53 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> Which web2py version? The error is from copying the request body into a
>>> tmp object in web2py. Looks like the request declares a size in the header
>>> but it is shorter (truncated).
>>>
>>>
>>>
>>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:

 I'm having ongoing problems with IOErrors from one of my web2py apps
 deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
 maybe happening at a lower level before it even gets to my app code?

 Traceback (most recent call last):
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in wsgibase
 parse_get_post_vars(request, environ)
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in
 parse_get_post_vars
 request.body = copystream_progress(request) ### stores request body
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in
 copystream_progress
 copystream(source, dest, size, chunk_size)
 File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 374, in
 copystream
 data = src.read(size)
 IOError: request data read error

>>>  --
>
>
>
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





[web2py] Re: Help! IOErrors

2012-07-16 Thread Massimo Di Pierro
The more I think about this the more I am convinced this is not of concern.

It is very well possible that a slow client sends you the header of a 
request, then closes the connection before finishing (perhaps the user 
killed the page, or stopped the browser while doing an upload or something 
slow).

At some point web2py fails because of this and apache logs it. Where web2py 
fails depends on the exact timing but it likely to fail while copying the 
input stream. Which is the error you get.

I think it correct to log these events.

We could catch this specific error and have a more descriptive error but - 
while this is the place which is the most likely to fail - the failure 
could be somewhere else and we would not be catching the same error.

I do not think this should be changed and I do not think this should be a 
concern. It tells you some uses have a slow connection.

What do others think?


On Monday, July 16, 2012 7:12:16 PM UTC-5, Brian M wrote:
>
> I'm on Version 1.99.4 (2011-12-22 11:20:45) stable.  Yeah it is a bit old 
> - at this point waiting for 2.0 stable to come out.
>
> On Monday, July 16, 2012 9:58:53 AM UTC-5, Massimo Di Pierro wrote:
>>
>> Which web2py version? The error is from copying the request body into a 
>> tmp object in web2py. Looks like the request declares a size in the header 
>> but it is shorter (truncated).
>>
>>
>>
>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>>
>>> I'm having ongoing problems with IOErrors from one of my web2py apps 
>>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
>>> maybe happening at a lower level before it even gets to my app code?
>>>
>>> Traceback (most recent call last):
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
>>> parse_get_post_vars(request, environ)
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
>>> parse_get_post_vars
>>> request.body = copystream_progress(request) ### stores request body
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
>>> copystream_progress
>>> copystream(source, dest, size, chunk_size)
>>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in 
>>> copystream
>>> data = src.read(size)
>>> IOError: request data read error
>>>
>>

-- 





[web2py] Re: Jeditable and SQLTables

2012-07-16 Thread Simon Ashley
Thanks Brent,

Sorry for the delay - first chance to delve into this again. Still no 
luck. Have tried various combinations but unable to get jeditable fire in 
this setup. 
Do you have a quick example that works (just a cut and paste one would do)?

TIA.

-- 





Re: [web2py] Help! IOErrors

2012-07-16 Thread Massimo Di Pierro
You are right. rocket does not help. I cannot think of any recent that may 
have fixed this but, before we spend time debugging this, it would be 
better if you could at least run stable 1.99.7 or better trunk.

On Monday, July 16, 2012 6:28:25 PM UTC-5, Brian M wrote:
>
> Bruce - Yeah, I doubt this is file permissions - it doesn't happen on 
> every request, just occasionally though seemingly over time more 
> frequently.  Most often seen on ajax requests but occasionally on "regular" 
> page requests too (though since there are many more ajax requests coming in 
> it makes sense more errors would be encountered from them even if it isn't 
> actually a cause).  
>
> As far as sessions - I do session.forget() first thing in the controller 
> function that handles the ajax requests, so sessions shouldn't be an 
> issue.  Traffic is very low anyway - peak would only be a handful of 
> requests a second.
>
> Massimo - I don't know that upgrading to the version of rocket in trunk 
> will really help anything - I'm using Apache and mod_wsgi so rocket isn't 
> even involved, right?
>
> On Monday, July 16, 2012 9:14:43 AM UTC-5, Bruce Wade wrote:
>>
>> I also get these errors randomly on nginx+uwsgi+ubuntu so I really don't 
>> think it is a file permissions problem as it happens randomly.
>>
>> On Mon, Jul 16, 2012 at 12:25 AM, Johann Spies wrote:
>>
>>> On 13 July 2012 23:27, Brian M wrote:
>>>
 I'm having ongoing problems with IOErrors from one of my web2py apps 
 deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
 maybe happening at a lower level before it even gets to my app code?

 Traceback (most recent call last):
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
 parse_get_post_vars(request, environ)
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
 parse_get_post_vars
 request.body = copystream_progress(request) ### stores request body
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
 copystream_progress
 copystream(source, dest, size, chunk_size)
 File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in 
 copystream
 data = src.read(size)
 IOError: request data read error

>>>
>>> I have never worked on Windows with Apache but this looks like either 
>>> incorrect ownership of the web2py files or just a permission problem.
>>>
>>> Make sure the user that owns Apache process is the one that owns the 
>>> web2py tree or at least has full access to it.
>>>
>>> Regards
>>> Johann 
>>>
>>> -- 
>>> Because experiencing your loyal love is better than life itself, 
>>> my lips will praise you.  (Psalm 63:3)
>>>
>>>
>>
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.com - Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>

-- 





[web2py] Re: IntegrityError: column email is not unique

2012-07-16 Thread Massimo Di Pierro
For the time being... remove unique=True and use 
requires=(IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email'))

On Monday, July 16, 2012 9:01:54 PM UTC-5, Massimo Di Pierro wrote:
>
> This is a bug. The archive function creates a an auxiliary table to store 
> copies of the current record. 
> It reproduces the same table structure as your table including 
> (incorrectly) the unique attribute. 
> This fails when you insert ore than one revision.
>
> Please open a ticket on google code. This is also an issue with the more 
> modern approach 
>
> auth.enable_record_versioning(db)
>
>
> On Monday, July 16, 2012 4:54:54 PM UTC-5, Remco K wrote:
>>
>> Hi everyone,
>>
>> I got stuck in creating an update form for an auth_user.
>>
>> In the auth_user table i made an extra field:
>>
>> Field('email', length=128, default='', unique=True, notnull=True),
>>
>> Now everytime i try to update the user information (the last name) i get 
>> the error:
>>
>> IntegrityError: column email is not unique
>>
>> I try to combine updating the user information with creating an archive 
>> entry for the previous entry:
>>
>> _id = db.auth_user(request.args(0)) or redirect(URL('index'))
>> form = SQLFORM(db.auth_user, _id)
>> if form.process(onsuccess=auth.archive).accepted:
>>
>> This method works for an other table which doesnt have an Field with 
>> Unique=True but not for this table with this Unique=True value.
>>
>> Someone who can help me out a bit?
>>
>> Thanks in advance!
>> Remco
>
>

-- 





[web2py] Re: IntegrityError: column email is not unique

2012-07-16 Thread Massimo Di Pierro
This is a bug. The archive function creates a an auxiliary table to store 
copies of the current record. 
It reproduces the same table structure as your table including 
(incorrectly) the unique attribute. 
This fails when you insert ore than one revision.

Please open a ticket on google code. This is also an issue with the more 
modern approach 

auth.enable_record_versioning(db)


On Monday, July 16, 2012 4:54:54 PM UTC-5, Remco K wrote:
>
> Hi everyone,
>
> I got stuck in creating an update form for an auth_user.
>
> In the auth_user table i made an extra field:
>
> Field('email', length=128, default='', unique=True, notnull=True),
>
> Now everytime i try to update the user information (the last name) i get 
> the error:
>
> IntegrityError: column email is not unique
>
> I try to combine updating the user information with creating an archive 
> entry for the previous entry:
>
> _id = db.auth_user(request.args(0)) or redirect(URL('index'))
> form = SQLFORM(db.auth_user, _id)
> if form.process(onsuccess=auth.archive).accepted:
>
> This method works for an other table which doesnt have an Field with 
> Unique=True but not for this table with this Unique=True value.
>
> Someone who can help me out a bit?
>
> Thanks in advance!
> Remco

-- 





[web2py] Re: error : socket.gethostbyname(http_host)] : gaierror: [Errno -2] Name or service not known

2012-07-16 Thread Massimo Di Pierro
Never heard of this before. Fixed in trunk. Thanks for reporting it.

On Monday, July 16, 2012 4:25:01 PM UTC-5, Carlos wrote:
>
> Hi,
>
> Every now and then, I see the following error in my server logs:
>  
>  ERROR:web2py:Traceback (most recent call last):
>  File "/home/www-data/web2py/gluon/main.py", line 401, in wsgibase
>socket.gethostbyname(http_host)]
>gaierror: [Errno -2] Name or service not known
>
> So far today I'm getting 10+ of these errors (although not from any of my 
> requests, but other users').
>
> How can this error be fixed?.
>
> I'm using latest web2py, ubuntu 10.04, postgresql, nginx, uwsgi-python.
>
> Thanks,
>
>Carlos
>
>

-- 





[web2py] Web2py expert needed for start-up

2012-07-16 Thread Pepe C
Hi, 

We have a set of applications on web2py and we are looking for an expert 
that can help us to operate and develop them.  This is a long-term role 
taking ~10 hours a week, although we do have a bunch of additional work to 
get done in the next few weeks. 

Responsibilities include:

   - Development of new web services 
   - Web2py administration and deployment 
   - Polishing and addressing bugs in the existing code

Experience with Jquery mobile plugin or mobile layouts would be a big plus.

In your replies please tell us about your portfolio, your availability for 
the next two months and your hourly rate.

Thanks!

-- 





[web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread wdtatenh
Thanks very much.  I'm thinking that I'm probably going to have to go to a 
model-less app because this is going to be much bigger given the breadth of 
what I'm trying to accomplish.

On Monday, July 16, 2012 4:52:56 PM UTC-4, Derek wrote:
>
> There should be no benefit to moving them to multiple model files. It 
> would have the same performance (or perhaps slower).
>
> The models file is processed on every page load, so it can get expensive 
> if you have a lot of tables defined in it.
> I'm sure Bruno can chime in here, but here is his recipe for model-less 
> apps...
>
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
>  
>
> On Monday, July 16, 2012 1:45:23 PM UTC-7, wdtatenh wrote:
>>
>> I've got to move a bunch of stuff around to speed up my site particularly 
>> on the controller folder.  My question is that I have nearly 50+ tables 
>> defined in my db.py file.  Is there any benefit to splitting these tables 
>> into multiple model files?  The tables belong to a single database and most 
>> use the auth_user table as a referenced table.  
>>
>> I'm assuming that they're all going to get read in regardless, therefore, 
>> splitting things up into multiple model files wouldn't gain me anything or 
>> am I wrong?
>>
>> Thanks in advance.
>>
>

-- 





[web2py] Re: A blog app with no models - to include in /appliances

2012-07-16 Thread Massimo DiPierro
Can you please resend me the updated w2p file and a screenshot?

On Jul 16, 2012, at 4:31 PM, Bruno Rocha wrote:

> Hi,
> 
> I just found that my example of Model Less Blog is not listed in 
> web2py.com/appliances
> 
> This app can be a start point for those who want to test and improve the 
> Model less approach
> 
> This is a simple blog app, all logic is under /modules and there are no model 
> files.
> 
> download the w2p: 
> https://github.com/downloads/rochacbruno/web2py_model_less_app/web2py.app.modellessapp.w2p
> 
> code: https://github.com/rochacbruno/web2py_model_less_app
> 
> Article: 
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
> 
> I really expect to have some "official" support/documentation and best 
> practices for this kind of solution in web2py docs.
> 
> 
> Bruno Cezar Rocha
> http://www.CursoDePython.com.br
> 
>   rochacbruno  blouweb
> Blog: Generate a thumbnail that fits in a box
> Get a signature like this. Click here.
> 

-- 





[web2py] Re: How to update fields from different tables in a single form

2012-07-16 Thread Anthony
Does this help: 
http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables

On Monday, July 16, 2012 8:56:24 PM UTC-4, mrtn wrote:
>
>
> Hi,
>
> I have a field (say 'field_a') from table 'A', and a field ('field_b') 
> from table 'B', and the two tables are linked such that they share a field. 
> Now I want to create a single form in a view which updates both 'field_a' 
> and 'field_b' in one submission. What is the proper way of doing this in 
> web2py?
>
> Do I need to use a SQLFORM factory or something else? Thanks.
>

-- 





[web2py] How to update fields from different tables in a single form

2012-07-16 Thread mrtn

Hi,

I have a field (say 'field_a') from table 'A', and a field ('field_b') from 
table 'B', and the two tables are linked such that they share a field. Now 
I want to create a single form in a view which updates both 'field_a' and 
'field_b' in one submission. What is the proper way of doing this in web2py?

Do I need to use a SQLFORM factory or something else? Thanks.

-- 





[web2py] Re: How to build a modular menu

2012-07-16 Thread JaapP


Hi Johan,

following code works for me to insert some items from the db into a submenu:

response.menu = [

('Home', False, URL('default','index'), []),

]

if auth.is_logged_in():
locaties = db(db.locatie.apotheek_id==auth.user.apotheek_id).select()
if locaties:
locaties_lijst = []
for locatie in locaties:
locaties_lijst.append( (locatie.naam, False, 
URL(c='rapporten',f='boekingsverslag',args=locatie.id),[]) )
locaties_lijst.append( ('Compleet', False, 
URL(c='rapporten',f='boekingsverslag_compleet'),[]) )
response.menu += (( ('Rapporten', False, URL(),[
  ('Saldo\'s', False, 
URL('rapporten','saldos'),[]),
  ('Boekingsverslag', False, URL(), 
locaties_lijst)
  ]),
  ('Beheer', URL(), False,[
  ('geld locaties', False, URL(), [
  ('overzicht', False, 
URL('beheer','locaties_overzicht')),
  ('toevoegen', False, 
URL('beheer','locatie_toevoegen'))])
])
 ))






-- 





[web2py] Re: web2py on EC2

2012-07-16 Thread lyn2py
I tried and it said, command not found. I did:
sudo ./setup-web2py-ubuntu.sh

Or how should the command be?

Thanks for the help!


On Tuesday, July 17, 2012 2:11:33 AM UTC+8, rdodev wrote:
>
> Run with 'sudo' in front.
>
> On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:
>>
>> Hi,
>>
>> I have browsed a few older threads on this but didn't manage to find an 
>> answer. Hope I can get help here.
>>
>> I started an instance with Ubuntu image, per the instructions here:
>> http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2
>>
>> And got stuck at this command:
>> ./setup-web2py-ubuntu.sh
>>
>> because "Permission Denied"... what should I do?
>>
>> Here is a snippet of the output:
>>
>>> installing useful packages
>>>
>>> ==
>>>
>>> E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
 Permission denied)
>>>
>>> E: Unable to lock directory /var/lib/apt/lists/
>>>
>>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)
>>>
>>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
 root?
>>>
>>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)
>>>
>>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
 root?
>>>
>>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)
>>>
>>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
 root?
>>>
>>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
 denied)
>>>
>>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
 root?
>>>
>>>

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread wdtatenh
Thanks very much for this information.  I need to examine it more closely 
but it looks darn good. I'm hoping with this change and re-organizing my 
controllers, then my site will speed up significantly.  At present, it is 
slower than raw maple syrup and I can't afford to stay with web2py if I 
can't redesign my site so the speed increases significantly.  

On Monday, July 16, 2012 5:20:42 PM UTC-4, rochacbruno wrote:
>
> You can also download a modelless app here: 
> https://github.com/rochacbruno/web2py_model_less_app/downloads
>
> I am using this approach for all my apps ( But I know we have things to 
> improve)
>
>
>

-- 





[web2py] Re: Help! IOErrors

2012-07-16 Thread Brian M
I'm on Version 1.99.4 (2011-12-22 11:20:45) stable.  Yeah it is a bit old - 
at this point waiting for 2.0 stable to come out.

On Monday, July 16, 2012 9:58:53 AM UTC-5, Massimo Di Pierro wrote:
>
> Which web2py version? The error is from copying the request body into a 
> tmp object in web2py. Looks like the request declares a size in the header 
> but it is shorter (truncated).
>
>
>
> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>
>> I'm having ongoing problems with IOErrors from one of my web2py apps 
>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
>> maybe happening at a lower level before it even gets to my app code?
>>
>> Traceback (most recent call last):
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
>> parse_get_post_vars(request, environ)
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
>> parse_get_post_vars
>> request.body = copystream_progress(request) ### stores request body
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
>> copystream_progress
>> copystream(source, dest, size, chunk_size)
>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in copystream
>> data = src.read(size)
>> IOError: request data read error
>>
>

-- 





Re: [web2py] Help! IOErrors

2012-07-16 Thread Brian M
Bruce - Yeah, I doubt this is file permissions - it doesn't happen on every 
request, just occasionally though seemingly over time more frequently.  
Most often seen on ajax requests but occasionally on "regular" page 
requests too (though since there are many more ajax requests coming in it 
makes sense more errors would be encountered from them even if it isn't 
actually a cause).  

As far as sessions - I do session.forget() first thing in the controller 
function that handles the ajax requests, so sessions shouldn't be an 
issue.  Traffic is very low anyway - peak would only be a handful of 
requests a second.

Massimo - I don't know that upgrading to the version of rocket in trunk 
will really help anything - I'm using Apache and mod_wsgi so rocket isn't 
even involved, right?

On Monday, July 16, 2012 9:14:43 AM UTC-5, Bruce Wade wrote:
>
> I also get these errors randomly on nginx+uwsgi+ubuntu so I really don't 
> think it is a file permissions problem as it happens randomly.
>
> On Mon, Jul 16, 2012 at 12:25 AM, Johann Spies wrote:
>
>> On 13 July 2012 23:27, Brian M wrote:
>>
>>> I'm having ongoing problems with IOErrors from one of my web2py apps 
>>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
>>> maybe happening at a lower level before it even gets to my app code?
>>>
>>> Traceback (most recent call last):
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
>>> parse_get_post_vars(request, environ)
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
>>> parse_get_post_vars
>>> request.body = copystream_progress(request) ### stores request body
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
>>> copystream_progress
>>> copystream(source, dest, size, chunk_size)
>>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in 
>>> copystream
>>> data = src.read(size)
>>> IOError: request data read error
>>>
>>
>> I have never worked on Windows with Apache but this looks like either 
>> incorrect ownership of the web2py files or just a permission problem.
>>
>> Make sure the user that owns Apache process is the one that owns the 
>> web2py tree or at least has full access to it.
>>
>> Regards
>> Johann 
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread Bruce Wade
Split models folder into multiple folders 1 per controller then define
tables used for each controler.. for more fine control add folders inside
the folders you just created with one per controller action and define only
tables used for that action.
On Jul 16, 2012 2:47 PM, "Anthony"  wrote:

> There should be no benefit to moving them to multiple model files. It
>> would have the same performance (or perhaps slower).
>>
>> The models file is processed on every page load, so it can get expensive
>> if you have a lot of tables defined in it.
>> I'm sure Bruno can chime in here, but here is his recipe for model-less
>> apps...
>> http://www.web2pyslices.com/**slice/show/1479/model-less-**
>> apps-using-data-models-and-**modules-in-web2py
>>
>>
>
> I've mentioned this before -- note that Bruno's "model-less" approach is
> also heavily class-based. There's nothing wrong with that, but it's worth
> noting that you do not have to take such a class-based approach when moving
> your model definitions to modules. You can simply create one or more
> functions in your modules and move all of your db.define_table calls to
> those functions, just as you would in a standard model file.
>
> Likewise, you could also use Bruno's class-based approach even in standard
> model files. In fact, you might get some of the speed benefits of the
> module approach even with standard model files by moving define_table calls
> into classes or functions within the model file, and only calling them (and
> therefore actually defining the tables) when needed in the controller
> (i.e., lazy table definitions).
>
> You should also be aware of conditional model execution, as described in
> the second set of bullets here:
> http://web2py.com/books/default/chapter/29/4#Workflow.
>
> Anthony
>
> --
>
>
>
>

-- 





[web2py] Re: Can't import external modules

2012-07-16 Thread DonH
Yes, I was running the web2py for OS X.  I have switched to the web2py 
source version and it now works.  Thanks for the help!

-- Don


On Monday, July 16, 2012 9:57:15 AM UTC-4, Massimo Di Pierro wrote:
>
> Are you running the web2py for OSX? That ships with its own python 
> interpreter and ignores any other python and module you may have installed. 
> I suggest you use web2py source since you already have python installed.
>
> On Sunday, 15 July 2012 14:26:11 UTC-5, DonH wrote:
>>
>> I have installed an external module (several .py files in a directory) 
>> that I want to import into my web2py app.  I'm running on OS X and have 
>> installed Python 2.7.  When I run Python from terminal, I can import the 
>> modules successfully, but when I attempt to import them in my web2py app, 
>> they cannot be found.  The ticket indicates that the Python version is 
>> 2.5.1 running from the web2py app, so I'm not clear how I can import these 
>> modules.  Copying them into the app/modules folder does not seem to work 
>> either.
>>
>> Can I either
>> - change the web2py Python version to run my local python 2.7? 
>> - place the modules somewhere in the app directory structure to be found?
>> - a different solution?
>>
>> Thanks for any help!
>> -- Don
>>
>

-- 





[web2py] IntegrityError: column email is not unique

2012-07-16 Thread Remco K
Hi everyone,

I got stuck in creating an update form for an auth_user.

In the auth_user table i made an extra field:

Field('email', length=128, default='', unique=True, notnull=True),

Now everytime i try to update the user information (the last name) i get 
the error:

IntegrityError: column email is not unique

I try to combine updating the user information with creating an archive 
entry for the previous entry:

_id = db.auth_user(request.args(0)) or redirect(URL('index'))
form = SQLFORM(db.auth_user, _id)
if form.process(onsuccess=auth.archive).accepted:

This method works for an other table which doesnt have an Field with 
Unique=True but not for this table with this Unique=True value.

Someone who can help me out a bit?

Thanks in advance!
Remco

-- 





[web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread Anthony

>
> There should be no benefit to moving them to multiple model files. It 
> would have the same performance (or perhaps slower).
>
> The models file is processed on every page load, so it can get expensive 
> if you have a lot of tables defined in it.
> I'm sure Bruno can chime in here, but here is his recipe for model-less 
> apps...
>
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
>  
>

I've mentioned this before -- note that Bruno's "model-less" approach is 
also heavily class-based. There's nothing wrong with that, but it's worth 
noting that you do not have to take such a class-based approach when moving 
your model definitions to modules. You can simply create one or more 
functions in your modules and move all of your db.define_table calls to 
those functions, just as you would in a standard model file.

Likewise, you could also use Bruno's class-based approach even in standard 
model files. In fact, you might get some of the speed benefits of the 
module approach even with standard model files by moving define_table calls 
into classes or functions within the model file, and only calling them (and 
therefore actually defining the tables) when needed in the controller 
(i.e., lazy table definitions).

You should also be aware of conditional model execution, as described in 
the second set of bullets here: 
http://web2py.com/books/default/chapter/29/4#Workflow.

Anthony

-- 





[web2py] Re: A blog app with no models - to include in /appliances

2012-07-16 Thread Bruno Rocha
Also, I will change the way datamodels are defined, I learned a good trick
from my use of Django.

*Instead of:*

class Post(object):
 tablename = "post"

 def set_propertieds(self):
  self.fields = [
 Field("name"),
 Field("email"),
 ]

*We can do:*

class Post(object):
name = Field("name")
email = Field("email")

class Meta:
 tablename = "post"

I think the second option is more confortable in therms of O.O

-- 





[web2py] Re: Scheduler: help us test it while learning

2012-07-16 Thread Pystar
I downloaded the app, tried to upload and install it but it always gives an 
error message "failed to install app". I also renamed it but no changes

On Sunday, July 15, 2012 9:02:01 PM UTC+1, Niphlod wrote:
>
> Maybe if you tell what issues you have we'll be able to help you .
>
>
>
> On Sunday, July 15, 2012 9:58:55 PM UTC+2, Pystar wrote:
>>
>> I am having issues installing the app in the web2py 2.0.0 dev version
>>
>> On Thursday, July 12, 2012 9:36:38 PM UTC+1, Niphlod wrote:
>>>
>>> Hello everybody, in the last month several changes were commited to the 
>>> scheduler, in order to improve it.
>>> Table schemas were changed, to add some features that were missed by 
>>> some users.
>>> On the verge of releasing web2py v.2.0.0, and seeing that the scheduler 
>>> potential is often missed by regular web2py users, I created a test app 
>>> with two main objectives: documenting the new scheduler and test the 
>>> features.
>>>
>>> App is available on github (
>>> https://github.com/niphlod/w2p_scheduler_tests). All you need is 
>>> download the trunk version of web2py, download the app and play with it.
>>>
>>> Current features:
>>> - one-time-only tasks
>>> - recurring tasks
>>> - possibility to schedule functions at a given time
>>> - possibility to schedule recurring tasks with a stop_time
>>> - can operate distributed among machines, given a database reachable for 
>>> all workers
>>> - group_names to "divide" tasks among different workers
>>> - group_names can also influence the "percentage" of assigned tasks to 
>>> similar workers
>>> - simple integration using modules for "embedded" tasks (i.e. you can 
>>> use functions defined in modules directly in your app or have them 
>>> processed in background)
>>> - configurable heartbeat to reduce latency: with sane defaults and not 
>>> t many tasks queued normally a queued task doesn't exceed 5 seconds 
>>> execution times
>>> - option to start it, process all available tasks and then die 
>>> automatically
>>> - integrated tracebacks
>>> - monitorable as state is saved on the db
>>> - integrated app environment if started as web2py.py -K
>>> - stop processes immediately (set them to "KILL")
>>> - stop processes gracefully (set them to "TERMINATE")
>>> - disable processes (set them to "DISABLED")
>>> - functions that doesn't return results do not generate a scheduler_run 
>>> entry
>>> - added a discard_results parameter that doesn't store results "no 
>>> matter what"
>>> - added a uuid record to tasks to simplify checkings of "unique" tasks
>>> - task_name is not required anymore
>>> - you can skip passing the function to the scheduler istantiation: 
>>> functions can be dinamically retrieved in the app's environment
>>>
>>> So, your mission is:
>>> - test the scheduler with the app and familiarize with it
>>> Secondary mission is:
>>> - report any bug you find here or on github (
>>> https://github.com/niphlod/w2p_scheduler_tests/issues)
>>> - propose new examples to be embedded in the app, or correct the current 
>>> docs (English is not my mother tongue) 
>>>
>>> Once approved, docs will be probably embedded in the book (
>>> http://web2py.com/book)
>>>
>>> Feel free to propose features you'd like to see in the scheduler, I have 
>>> some time to spend implementing it.
>>>
>>>
>>>
>>>

-- 





[web2py] error : socket.gethostbyname(http_host)] : gaierror: [Errno -2] Name or service not known

2012-07-16 Thread Carlos
Hi,

Every now and then, I see the following error in my server logs:
 
 ERROR:web2py:Traceback (most recent call last):
 File "/home/www-data/web2py/gluon/main.py", line 401, in wsgibase
   socket.gethostbyname(http_host)]
   gaierror: [Errno -2] Name or service not known

So far today I'm getting 10+ of these errors (although not from any of my 
requests, but other users').

How can this error be fixed?.

I'm using latest web2py, ubuntu 10.04, postgresql, nginx, uwsgi-python.

Thanks,

   Carlos

-- 





Re: [web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread Bruno Rocha
You can also download a modelless app here:
https://github.com/rochacbruno/web2py_model_less_app/downloads

I am using this approach for all my apps ( But I know we have things to
improve)

On Mon, Jul 16, 2012 at 5:52 PM, Derek  wrote:

> There should be no benefit to moving them to multiple model files. It
> would have the same performance (or perhaps slower).
>
> The models file is processed on every page load, so it can get expensive
> if you have a lot of tables defined in it.
> I'm sure Bruno can chime in here, but here is his recipe for model-less
> apps...
>
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
>
>
>
> On Monday, July 16, 2012 1:45:23 PM UTC-7, wdtatenh wrote:
>>
>> I've got to move a bunch of stuff around to speed up my site particularly
>> on the controller folder.  My question is that I have nearly 50+ tables
>> defined in my db.py file.  Is there any benefit to splitting these tables
>> into multiple model files?  The tables belong to a single database and most
>> use the auth_user table as a referenced table.
>>
>> I'm assuming that they're all going to get read in regardless, therefore,
>> splitting things up into multiple model files wouldn't gain me anything or
>> am I wrong?
>>
>> Thanks in advance.
>>
>  --
>
>
>
>

-- 





[web2py] Re: response.JSON Decimal problem

2012-07-16 Thread Massimo Di Pierro
fixed. please try it

On Monday, 16 July 2012 14:56:16 UTC-5, Derek wrote:
>
> Jsondecoder does not accept Decimal objects. Take a look at 
> serializers.py. You could try converting to float.
>
> See here for workarounds...
>
> http://stackoverflow.com/questions/1960516/python-json-serialize-a-decimal-object
>  
>
> On Monday, July 16, 2012 7:34:25 AM UTC-7, Vineet wrote:
>>
>> Hi !
>> From a controller, I am trying to return a jsonified resultset (obtained 
>> by executing sql directly).
>>
>> resultset = ( ('201207020920', Decimal('5308.20'), Decimal('5308.20'), 
>> Decimal('5288.00'), Decimal('5292.40'), ...)
>>
>> ## convertd it to list of lists
>>
>> list_of_tuples = list(resultset)
>> list_of_lists = [list(i) for i in list_of_tuples]
>>
>> ## Since an error is thrown as under--
>>
>> TypeError: Decimal('5308.20') is not JSON serializable
>>
>>
>> ## convertd all list items decimal to str ---
>>
>> for x in list_of_lists:
>> for y in x:
>> y = str(y)
>> print y, 'type of this y is ', type(y)
>>
>> ## confirmed that all are of type 'str'
>>
>> D = dict(list_of_lists = list_of_lists)
>> return response.json(D)
>>
>> Still, the same error is thrown as under--
>>
>> TypeError: Decimal('5308.20') is not JSON serializable
>>
>> How do I fix this?
>>
>> Thanks,
>>
>> Vineet
>>
>>

-- 





[web2py] Re: Recommendations on model file size (database tables)

2012-07-16 Thread Derek
There should be no benefit to moving them to multiple model files. It would 
have the same performance (or perhaps slower).

The models file is processed on every page load, so it can get expensive if 
you have a lot of tables defined in it.
I'm sure Bruno can chime in here, but here is his recipe for model-less 
apps...
http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
 

On Monday, July 16, 2012 1:45:23 PM UTC-7, wdtatenh wrote:
>
> I've got to move a bunch of stuff around to speed up my site particularly 
> on the controller folder.  My question is that I have nearly 50+ tables 
> defined in my db.py file.  Is there any benefit to splitting these tables 
> into multiple model files?  The tables belong to a single database and most 
> use the auth_user table as a referenced table.  
>
> I'm assuming that they're all going to get read in regardless, therefore, 
> splitting things up into multiple model files wouldn't gain me anything or 
> am I wrong?
>
> Thanks in advance.
>

-- 





[web2py] Re: Auth.register() questions

2012-07-16 Thread Massimo Di Pierro
The register function, as all the functions in auch which return a form, 
call process internally. Therefore if you fo

form = auth.register()
form.process()

you would be calling process twice with undesired consequences. Moreover if 
the process() called inside it successful and the form was accepted you may 
have a redirect (raise HTTP) and therefore the function never returns.

I think this is what you want:

def register():
def onvalidation(form):
if form.errors: # form has errors
session.flash = 'Registration form processed, please check your 
email'
def onaccept(form): # form accepted
response.flash = 'Registration form contains error(s)'
auth.settings.register_onvalidation.append(onvalidation)
auth.settings.register_onaccept.append(onaccept)
form = auth.register()
if not form.vars: # form not sumitted
response.flash = 'Please fill in the registration form'
return dict(form=form)

Anyway if all you want is set errors, you should use auth.messages.*

2.
open a web2py shell with

python web2py.py -S welcome -M -N

then experiment yourself

   form = auth.register()
   print form
   form['_class'] = 'test'
   print form
   form.element('input[name=myfield]')['_class'] = 'test' # jquery syntax
   print form

On Monday, 16 July 2012 13:30:06 UTC-5, cyan wrote:
>
>
> I have a couple of questions about the provided Auth.register() function 
> (I suppose they also apply to other Auth functions in general):
>
> 1. In a controller, if I do:
>
> def register():
> return dict(form=auth.register())
>
> with the following settings in a model:
>
> auth.settings.registration_requires_verification = True
> auth.settings.register_next = URL (...)
>
> Everything works as expected, i.e. the verification email is sent after 
> the registration form is processed, and the user gets re-directed to a 
> different page. However, as soon as I do sth like:
>
> def register():
> form = auth.register()
>
> if form.process().accepted:
> session.flash = 'Registration form processed, please check your 
> email'
> elif form.errors:
> response.flash = 'Registration form contains error(s)'
> else:
> response.flash = 'Please fill in the registration form'
>
> return dict(form=form)
>
> *Both verification email and re-direction stop working even though the 
> form processed successfully* (a record is inserted, the form clears 
> itself, and a flash message 'Success!' appears). I wonder what causes this 
> breakdown? I am using the trunk version of web2py.
>
>
> 2. How much customization can we do with the form returned by 
> auth.register()? I know we can add add fields to it (a few different ways), 
> but there are many other things one may want to adjust. For example, I am 
> able to do sth like:
>
> form.element(_type='submit')['_class'] = '...'
>
> to change the class of its elements. How do we change the class for the 
> whole form? How do we change the label for each field? How do we adjust the 
> position of each field? How do we position the whole form on the page? etc.
>
> Thanks in advance! 
>
>
>
>

-- 





Re: [web2py] How to update the cached value?

2012-07-16 Thread Derek
Right. My point was that you shouldn't concern yourself with getting stale 
values from the database because you cached them, and they changed short of 
the refresh interval. I have a website that caches things for 15 minutes, 
and I just tell my users that they won't see changes (on certain things) 
until 15 minutes have passed. For example, they add a new contact, the new 
contact won't be shown in the list of contacts until after 15 minutes, 
because that contact list is huge, and having to get it from the database 
every time can be slow. Now they can pass around links to the new contacts 
if they absolutely need to share it before that 15 minutes has passed, but 
otherwise, if they wait it will show up. If the 15 minute wait was getting 
too slow for them, I can of course decrease the cache time. My site has two 
layer cache as well, so not only is the data cached in ram for 15 minutes, 
but it's also cached on the browser by setting the caching options in the 
header. 95% of the time, the server can just send a 304 message.

On Friday, July 13, 2012 2:12:28 PM UTC-7, Anthony wrote:
>
> Right, you are using a ram cache, so you would have to explicitly 
>> invalidate the cached items if you want to update them. I would not rely on 
>> the time_expire to handle that for you, unless you are really not too 
>> concerned about it.
>
>
> To be clear, the cached value will reliably get updated whenever the time 
> since the previous save exceeds the current value of time_expire, so you 
> can rely on time_expire to update based on the interval it specifies. 
> Nevertheless, there may be times you want to update the cached value based 
> on something other than the time that has expired since the last update. 
> That is possible as well, though a separate issue.
>
> Anthony
>

-- 





[web2py] Recommendations on model file size (database tables)

2012-07-16 Thread wdtatenh
I've got to move a bunch of stuff around to speed up my site particularly 
on the controller folder.  My question is that I have nearly 50+ tables 
defined in my db.py file.  Is there any benefit to splitting these tables 
into multiple model files?  The tables belong to a single database and most 
use the auth_user table as a referenced table.  

I'm assuming that they're all going to get read in regardless, therefore, 
splitting things up into multiple model files wouldn't gain me anything or 
am I wrong?

Thanks in advance.

-- 





[web2py] Re: Restful authentication and CORS

2012-07-16 Thread rdodev
Massimo, 

I believe Alec already has one he linked to:  Keep an eye on this issue: 
http://code.google.com/p/web2py/issues/detail?id=872 so I'm assuming you 
don't need another one for essentially the same feature request.

:)

On Monday, July 16, 2012 4:41:11 PM UTC-4, Massimo Di Pierro wrote:
>
> Please open a ticket.
>
> On Monday, 16 July 2012 13:09:29 UTC-5, rdodev wrote:
>>
>> Massimo, 
>>
>> As Alec mentioned above, if not RESTful, OAuth and jsonrpc/jsonp would 
>> work as well. So if this is the preferred approach to non-browser/mobile 
>> authentication I could definitely work with that.
>>
>> Thanks. 
>>
>> On Monday, July 16, 2012 1:59:30 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Can you descrive in some details the API's you would like to have?
>>> If there is agreement it would not much to add them.
>>>
>>>
>>> On Monday, 16 July 2012 10:18:55 UTC-5, rdodev wrote:

 I'm developing a web2py app that will be used as the back-end for a 
 mobile app. The mobile app will be making API calls to the service for 
 anything ranging from login/authentication to CRUD operations. The auth 
 model that comes baked into web2py would suffice, except that it's not 
 RESTful and it's mostly geared to work with a web browser (sessions, 
 cookies, etc.). Is there a way to set the auth module to behave RESTfully?

 Another issue is that some of the mobile clients might be running on a 
 webView (phoneGap) and thus issuing requests to out back end would result 
 in a same-origin policy denial. Is there a way to setup CORS in web2py (or 
 should we set that up through apache/wsgi instead?)

 Thanks.

>>>

-- 





[web2py] Re: Restful authentication and CORS

2012-07-16 Thread Massimo Di Pierro
Please open a ticket.

On Monday, 16 July 2012 13:09:29 UTC-5, rdodev wrote:
>
> Massimo, 
>
> As Alec mentioned above, if not RESTful, OAuth and jsonrpc/jsonp would 
> work as well. So if this is the preferred approach to non-browser/mobile 
> authentication I could definitely work with that.
>
> Thanks. 
>
> On Monday, July 16, 2012 1:59:30 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Can you descrive in some details the API's you would like to have?
>> If there is agreement it would not much to add them.
>>
>>
>> On Monday, 16 July 2012 10:18:55 UTC-5, rdodev wrote:
>>>
>>> I'm developing a web2py app that will be used as the back-end for a 
>>> mobile app. The mobile app will be making API calls to the service for 
>>> anything ranging from login/authentication to CRUD operations. The auth 
>>> model that comes baked into web2py would suffice, except that it's not 
>>> RESTful and it's mostly geared to work with a web browser (sessions, 
>>> cookies, etc.). Is there a way to set the auth module to behave RESTfully?
>>>
>>> Another issue is that some of the mobile clients might be running on a 
>>> webView (phoneGap) and thus issuing requests to out back end would result 
>>> in a same-origin policy denial. Is there a way to setup CORS in web2py (or 
>>> should we set that up through apache/wsgi instead?)
>>>
>>> Thanks.
>>>
>>

-- 





[web2py] Re: pg8000 '%' not supported in quoted string

2012-07-16 Thread Derek
So escape it. In Python, % usually refers to a variable that follows the 
string. If you want a literal percent sign, then you need to double it. %%.
Seems like gluon is not escaping it properly. If you can post your whole 
traceback, I could help you to find out what file you need to add the extra 
escaping.

On Monday, July 16, 2012 4:34:07 AM UTC-7, KMax wrote:
>
> Hello,
>  Seems like an issue for me, pg8000 cant insert into db char '%'.
>  As a result inserting string = 'We did it for 100%' throw an exception.
>  
>  '%'' not 
> supported in quoted string
>
>  pg8000 checks for '%' in an argument, so...
>
> Thank you.
> --
> Maxim
>

-- 





Re: [web2py] KeyError on pyfpdf

2012-07-16 Thread thinkwell
No, the "em" still raises an AttributeError. In the post above, I've 
included all the code to duplicate the problem...

On Monday, July 16, 2012 4:17:48 PM UTC-4, Derek wrote:
>
> Try to use "em", see if you still get the same problem.
>
> 1em = 12pt
>
> http://www.getallfix.com/2011/11/convert-empxpt-and-in-css/ 
>
> On Monday, July 16, 2012 1:08:13 PM UTC-7, thinkwell wrote:
>>
>> Well, me again. I decided that I wanted to use points as measurements 
>> instead of percentages, so now it barfs with an AttributeError.
>>
>>
>> from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
>> from gluon.html import *
>>
>>
>> pets = TABLE(_width="720pt")
>> pets.append(TR(TH('Dogs', _width="72pt", 
>> _align="left"),TH("Cats",_width="72pt", 
>> _align="left"),TH('Snakes',_width="72pt", _align="left")))
>> pets.append(TR('Collies','Tabby','Python', _width="60pt"))
>> pets.append(TR('Akitas', 'Persian', 'Garter'))
>> pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes'))
>>
>>
>> class MyFPDF(FPDF, HTMLMixin):
>> pass
>>
>> pdf=MyFPDF()
>> #First page
>> pdf.add_page()
>> pdf.write_html(pets.xml())
>> pdf.output('html2.pdf','F')
>>
>>
>> This is clearly unremarkable HTML, but no, I get tracebacks like so:
>>
>> Traceback (most recent call last):
>>   File "pyfpdf_test.py", line 73, in 
>> pdf.write_html(pets.xml())
>>   File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
>> line 388, in write_html
>> h2p.feed(text)
>>   File "/usr/lib/python2.7/HTMLParser.py", line 114, in feed
>> self.goahead(0)
>>   File "/usr/lib/python2.7/HTMLParser.py", line 158, in goahead
>> k = self.parse_starttag(i)
>>   File "/usr/lib/python2.7/HTMLParser.py", line 324, in parse_starttag
>> self.handle_starttag(tag, attrs)
>>   File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
>> line 241, in handle_starttag
>> self.pdf.set_x(self.table_offset)
>> AttributeError: HTML2FPDF instance has no attribute 'table_offset'
>>
>> I find this remarkable; this ordinary HTML; web2py encourages the use of 
>> HTML helpers. web2py is easy to use, requires few dependencies, etc. etc. 
>> But what a *fight* to create a simple table-based PDF! :-( And I'm still 
>> experimenting in the layout stage. My final report will be much larger and 
>> include nested tables *(that are already rendering fine in HTML, but not 
>> in pyfpdf / html2pdf)*.
>>
>> Should I bite the bullet and install Reportlab? It'll be harder to get 
>> started, more complicated to install & maintain (this will have to go on 
>> multiple machines). The idea of a simple web2py project was very attractive 
>> for these reasons.
>>
>> Are others out there creating PDFs from HTML with pyfpdf & html2pdf??
>>
>

-- 





[web2py] Re: Want to build a site like flattr on web2py/python?

2012-07-16 Thread lukedc
Thank you very much for that response. Very helpful. thank you so much once 
again, Luke

On Monday, July 16, 2012 12:57:03 PM UTC-5, Massimo Di Pierro wrote:
>
> Is has been done (in web2py): http://www.ekjaa.org/Ekjaa/default/index
>
> They do not have legal permission to accept payments outside of India. 
> Contact them. Perhaps they are willing to share the code and or parter with 
> you.
>
> Massimo
>
> On Monday, 16 July 2012 10:20:11 UTC-5, lukedc wrote:
>>
>> Can it be done? And what will I need to know?
>>
>> I am learning Python now, will be learning web2py soon. The site will 
>> take points from people, and then use the points given to determine how 
>> much money to give to the websites. Can I do all this with web2py?
>>
>> Also, what will I need to learn? I only know Python now, will be learning 
>> HTML and CSS. What else will I need to learn? thank you so much, Luke
>> Can it be done? And what will I need to know?
>>
>> I am learning Python now, will be learning web2py soon. The site will 
>> take points from people, and then use the points given to determine how 
>> much money to give to the websites. Can I do all this with web2py?
>>
>> Also, what will I need to learn? I only know Python now, will be learning 
>> HTML and CSS. What else will I need to learn? thank you so much, Luke
>>
>> 
>>
>

-- 





Re: [web2py] KeyError on pyfpdf

2012-07-16 Thread Derek
Try to use "em", see if you still get the same problem.

1em = 12pt

http://www.getallfix.com/2011/11/convert-empxpt-and-in-css/ 

On Monday, July 16, 2012 1:08:13 PM UTC-7, thinkwell wrote:
>
> Well, me again. I decided that I wanted to use points as measurements 
> instead of percentages, so now it barfs with an AttributeError.
>
>
> from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
> from gluon.html import *
>
>
> pets = TABLE(_width="720pt")
> pets.append(TR(TH('Dogs', _width="72pt", 
> _align="left"),TH("Cats",_width="72pt", 
> _align="left"),TH('Snakes',_width="72pt", _align="left")))
> pets.append(TR('Collies','Tabby','Python', _width="60pt"))
> pets.append(TR('Akitas', 'Persian', 'Garter'))
> pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes'))
>
>
> class MyFPDF(FPDF, HTMLMixin):
> pass
>
> pdf=MyFPDF()
> #First page
> pdf.add_page()
> pdf.write_html(pets.xml())
> pdf.output('html2.pdf','F')
>
>
> This is clearly unremarkable HTML, but no, I get tracebacks like so:
>
> Traceback (most recent call last):
>   File "pyfpdf_test.py", line 73, in 
> pdf.write_html(pets.xml())
>   File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
> line 388, in write_html
> h2p.feed(text)
>   File "/usr/lib/python2.7/HTMLParser.py", line 114, in feed
> self.goahead(0)
>   File "/usr/lib/python2.7/HTMLParser.py", line 158, in goahead
> k = self.parse_starttag(i)
>   File "/usr/lib/python2.7/HTMLParser.py", line 324, in parse_starttag
> self.handle_starttag(tag, attrs)
>   File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
> line 241, in handle_starttag
> self.pdf.set_x(self.table_offset)
> AttributeError: HTML2FPDF instance has no attribute 'table_offset'
>
> I find this remarkable; this ordinary HTML; web2py encourages the use of 
> HTML helpers. web2py is easy to use, requires few dependencies, etc. etc. 
> But what a *fight* to create a simple table-based PDF! :-( And I'm still 
> experimenting in the layout stage. My final report will be much larger and 
> include nested tables *(that are already rendering fine in HTML, but not 
> in pyfpdf / html2pdf)*.
>
> Should I bite the bullet and install Reportlab? It'll be harder to get 
> started, more complicated to install & maintain (this will have to go on 
> multiple machines). The idea of a simple web2py project was very attractive 
> for these reasons.
>
> Are others out there creating PDFs from HTML with pyfpdf & html2pdf??
>

-- 





Re: [web2py] KeyError on pyfpdf

2012-07-16 Thread thinkwell
Well, me again. I decided that I wanted to use points as measurements 
instead of percentages, so now it barfs with an AttributeError.


from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
from gluon.html import *


pets = TABLE(_width="720pt")
pets.append(TR(TH('Dogs', _width="72pt", 
_align="left"),TH("Cats",_width="72pt", 
_align="left"),TH('Snakes',_width="72pt", _align="left")))
pets.append(TR('Collies','Tabby','Python', _width="60pt"))
pets.append(TR('Akitas', 'Persian', 'Garter'))
pets.append(TR('German Shepherds', 'Alley Cats', 'Rattlesnakes'))


class MyFPDF(FPDF, HTMLMixin):
pass

pdf=MyFPDF()
#First page
pdf.add_page()
pdf.write_html(pets.xml())
pdf.output('html2.pdf','F')


This is clearly unremarkable HTML, but no, I get tracebacks like so:

Traceback (most recent call last):
  File "pyfpdf_test.py", line 73, in 
pdf.write_html(pets.xml())
  File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
line 388, in write_html
h2p.feed(text)
  File "/usr/lib/python2.7/HTMLParser.py", line 114, in feed
self.goahead(0)
  File "/usr/lib/python2.7/HTMLParser.py", line 158, in goahead
k = self.parse_starttag(i)
  File "/usr/lib/python2.7/HTMLParser.py", line 324, in parse_starttag
self.handle_starttag(tag, attrs)
  File "/home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.py", 
line 241, in handle_starttag
self.pdf.set_x(self.table_offset)
AttributeError: HTML2FPDF instance has no attribute 'table_offset'

I find this remarkable; this ordinary HTML; web2py encourages the use of 
HTML helpers. web2py is easy to use, requires few dependencies, etc. etc. 
But what a *fight* to create a simple table-based PDF! :-( And I'm still 
experimenting in the layout stage. My final report will be much larger and 
include nested tables *(that are already rendering fine in HTML, but not in 
pyfpdf / html2pdf)*.

Should I bite the bullet and install Reportlab? It'll be harder to get 
started, more complicated to install & maintain (this will have to go on 
multiple machines). The idea of a simple web2py project was very attractive 
for these reasons.

Are others out there creating PDFs from HTML with pyfpdf & html2pdf??

-- 





[web2py] Re: response.JSON Decimal problem

2012-07-16 Thread Derek
Jsondecoder does not accept Decimal objects. Take a look at serializers.py. 
You could try converting to float.

See here for workarounds...
http://stackoverflow.com/questions/1960516/python-json-serialize-a-decimal-object
 

On Monday, July 16, 2012 7:34:25 AM UTC-7, Vineet wrote:
>
> Hi !
> From a controller, I am trying to return a jsonified resultset (obtained 
> by executing sql directly).
>
> resultset = ( ('201207020920', Decimal('5308.20'), Decimal('5308.20'), 
> Decimal('5288.00'), Decimal('5292.40'), ...)
>
> ## convertd it to list of lists
>
> list_of_tuples = list(resultset)
> list_of_lists = [list(i) for i in list_of_tuples]
>
> ## Since an error is thrown as under--
>
> TypeError: Decimal('5308.20') is not JSON serializable
>
>
> ## convertd all list items decimal to str ---
>
> for x in list_of_lists:
> for y in x:
> y = str(y)
> print y, 'type of this y is ', type(y)
>
> ## confirmed that all are of type 'str'
>
> D = dict(list_of_lists = list_of_lists)
> return response.json(D)
>
> Still, the same error is thrown as under--
>
> TypeError: Decimal('5308.20') is not JSON serializable
>
> How do I fix this?
>
> Thanks,
>
> Vineet
>
>

-- 





Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Niphlod
You're right, it's 1 query per request more (2 if session is updated), but 
it's a pkey lookup (and eventually an update) vs scan a dir, open file, 
lock it, read it, (eventually save) and close it. 

Without available perftest I tend to agree that file-based session in 
separate folders is better for environment where web2py is launched on 
multiple machines against a single database server (as I intended your 
setup actually is), but for single instances with the application server 
being the same of the database server, I'd rather not place my bet.

BTW: I'm using postgres

PS: remember to trash expired session in any case

On Monday, July 16, 2012 8:52:13 PM UTC+2, Bruce Wade wrote:
>
> Storing them in the database will slow down your website depending on 
> which database, how many users and how many sessions you create. On a heavy 
> hit site the DB is going to slow down a lot.
>
> I am trying to figure out a way how to handle sessions on the client site 
> as secure as possible so the servers don't get hit hard
>
> On Mon, Jul 16, 2012 at 11:44 AM, Niphlod  wrote:
>
>> I'm storing sessions on database for my app with no apparent problems 
>> (1.99.7 stable) for storing them in redis, currently there is no way 
>> (sorry). 
>> When I implemented cache in redis it seemed that I was the only one using 
>> a redis stack along web2py...generally redis adoption is quite sparse in 
>> web2py world, and the only implemented thing is the cache backend.
>> Anyway if there are demands in this sense, I could write something up, 
>> but some changes to how sessions are handled in web2py (namely in 
>> gluon.main.wsgibase) are needed.
>>
>>
>>
>>
>> On Monday, July 16, 2012 6:58:54 PM UTC+2, rochacbruno wrote:
>>>
>>>
>>> I tested putting sessions in database, but for some strange reason, when 
>>> sessions are in db, user are not redirect to login._next after the login, 
>>> and other issues. Also I think sessions in db gets a bit slower.
>>>
>>> I am planning to test sessions in redis.
>>>
>>>
>>> On Mon, Jul 16, 2012 at 1:01 PM, Bruce Wade wrote:
>>>
 That I/o warning shouldn't take down your site I have the same issue 
 with linode. I think sessions need to be done differently especially on 
 high load sites with a load balancer sometimes I find over 400,000 files 
 in 
 the session folder on each server × 4
  On Jul 16, 2012 8:14 AM, "Bruno Rocha"  wrote:

> I am having a related problem.
>
> "Your Linode, blouserver, has exceeded the notification threshold 
> (1000) for disk io rate by averaging 1382.77 for the last 2 hours: 
>
> I receive this message every 2 hour, so my nginx get bas gateway and I 
> need to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get 
> the site running again.
>
>
>
> On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> This may be related to a bug in rocket that was not catching 
>> timouterror and occasionally sending/receiving incomplete requests.
>>
>> Try upgrade rocket.py yo trunk. You can leave everything unchanged. 
>> Let us know if the error go away.
>>
>> It is also possible that the request is actually invalid (the browser 
>> declares a different size than it sends). Perhaps because of network 
>> issues. Perhaps web2py could report a better (clearer error). Do you 
>> think 
>> it should be logged or silently ignore and the request dropped?
>>
>> Massimo
>>
>>
>> On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>>>
>>> I am using the latest stable still.
>>>
>>> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Which web2py version? The error is from copying the request body 
 into a tmp object in web2py. Looks like the request declares a size in 
 the 
 header but it is shorter (truncated).



 On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>
> I'm having ongoing problems with IOErrors from one of my web2py 
> apps deployed on Windows with Apache & mod_wsgi.  Looks to me like 
> the 
> error maybe happening at a lower level before it even gets to my app 
> code?
>
> Traceback (most recent call last):
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in 
> wsgibase
> parse_get_post_vars(request, environ)
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in 
> parse_get_post_vars
> request.body = copystream_progress(request) ### stores request body
> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in 
> copystream_progress
> copystream(source, dest, size, chunk_size)
> File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 

Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruce Wade
Storing them in the database will slow down your website depending on which
database, how many users and how many sessions you create. On a heavy hit
site the DB is going to slow down a lot.

I am trying to figure out a way how to handle sessions on the client site
as secure as possible so the servers don't get hit hard

On Mon, Jul 16, 2012 at 11:44 AM, Niphlod  wrote:

> I'm storing sessions on database for my app with no apparent problems
> (1.99.7 stable) for storing them in redis, currently there is no way
> (sorry).
> When I implemented cache in redis it seemed that I was the only one using
> a redis stack along web2py...generally redis adoption is quite sparse in
> web2py world, and the only implemented thing is the cache backend.
> Anyway if there are demands in this sense, I could write something up, but
> some changes to how sessions are handled in web2py (namely in
> gluon.main.wsgibase) are needed.
>
>
>
>
> On Monday, July 16, 2012 6:58:54 PM UTC+2, rochacbruno wrote:
>>
>>
>> I tested putting sessions in database, but for some strange reason, when
>> sessions are in db, user are not redirect to login._next after the login,
>> and other issues. Also I think sessions in db gets a bit slower.
>>
>> I am planning to test sessions in redis.
>>
>>
>> On Mon, Jul 16, 2012 at 1:01 PM, Bruce Wade  wrote:
>>
>>> That I/o warning shouldn't take down your site I have the same issue
>>> with linode. I think sessions need to be done differently especially on
>>> high load sites with a load balancer sometimes I find over 400,000 files in
>>> the session folder on each server × 4
>>>  On Jul 16, 2012 8:14 AM, "Bruno Rocha"  wrote:
>>>
 I am having a related problem.

 "Your Linode, blouserver, has exceeded the notification threshold
 (1000) for disk io rate by averaging 1382.77 for the last 2 hours:

 I receive this message every 2 hour, so my nginx get bas gateway and I
 need to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get
 the site running again.



 On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
 massimo.dipie...@gmail.com> wrote:

> This may be related to a bug in rocket that was not catching
> timouterror and occasionally sending/receiving incomplete requests.
>
> Try upgrade rocket.py yo trunk. You can leave everything unchanged.
> Let us know if the error go away.
>
> It is also possible that the request is actually invalid (the browser
> declares a different size than it sends). Perhaps because of network
> issues. Perhaps web2py could report a better (clearer error). Do you think
> it should be logged or silently ignore and the request dropped?
>
> Massimo
>
>
> On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>>
>> I am using the latest stable still.
>>
>> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Which web2py version? The error is from copying the request body
>>> into a tmp object in web2py. Looks like the request declares a size in 
>>> the
>>> header but it is shorter (truncated).
>>>
>>>
>>>
>>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:

 I'm having ongoing problems with IOErrors from one of my web2py
 apps deployed on Windows with Apache & mod_wsgi.  Looks to me like the
 error maybe happening at a lower level before it even gets to my app 
 code?

 Traceback (most recent call last):
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in
 wsgibase
 parse_get_post_vars(request, environ)
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in
 parse_get_post_vars
 request.body = copystream_progress(request) ### stores request body
 File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in
 copystream_progress
 copystream(source, dest, size, chunk_size)
 File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 374,
 in copystream
 data = src.read(size)
 IOError: request data read error

>>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**bruc**elwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**co**m - 
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>

>>  --
>
>
>
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Niphlod
I'm storing sessions on database for my app with no apparent problems 
(1.99.7 stable) for storing them in redis, currently there is no way 
(sorry). 
When I implemented cache in redis it seemed that I was the only one using a 
redis stack along web2py...generally redis adoption is quite sparse in 
web2py world, and the only implemented thing is the cache backend.
Anyway if there are demands in this sense, I could write something up, but 
some changes to how sessions are handled in web2py (namely in 
gluon.main.wsgibase) are needed.



On Monday, July 16, 2012 6:58:54 PM UTC+2, rochacbruno wrote:
>
>
> I tested putting sessions in database, but for some strange reason, when 
> sessions are in db, user are not redirect to login._next after the login, 
> and other issues. Also I think sessions in db gets a bit slower.
>
> I am planning to test sessions in redis.
>
>
> On Mon, Jul 16, 2012 at 1:01 PM, Bruce Wade  wrote:
>
>> That I/o warning shouldn't take down your site I have the same issue with 
>> linode. I think sessions need to be done differently especially on high 
>> load sites with a load balancer sometimes I find over 400,000 files in the 
>> session folder on each server × 4
>>  On Jul 16, 2012 8:14 AM, "Bruno Rocha"  wrote:
>>
>>> I am having a related problem.
>>>
>>> "Your Linode, blouserver, has exceeded the notification threshold 
>>> (1000) for disk io rate by averaging 1382.77 for the last 2 hours: 
>>>
>>> I receive this message every 2 hour, so my nginx get bas gateway and I 
>>> need to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get 
>>> the site running again.
>>>
>>>
>>>
>>> On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 This may be related to a bug in rocket that was not catching 
 timouterror and occasionally sending/receiving incomplete requests.

 Try upgrade rocket.py yo trunk. You can leave everything unchanged. Let 
 us know if the error go away.

 It is also possible that the request is actually invalid (the browser 
 declares a different size than it sends). Perhaps because of network 
 issues. Perhaps web2py could report a better (clearer error). Do you think 
 it should be logged or silently ignore and the request dropped?

 Massimo


 On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>
> I am using the latest stable still.
>
> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Which web2py version? The error is from copying the request body into 
>> a tmp object in web2py. Looks like the request declares a size in the 
>> header but it is shorter (truncated).
>>
>>
>>
>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>>
>>> I'm having ongoing problems with IOErrors from one of my web2py apps 
>>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
>>> maybe happening at a lower level before it even gets to my app code?
>>>
>>> Traceback (most recent call last):
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in 
>>> wsgibase
>>> parse_get_post_vars(request, environ)
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
>>> parse_get_post_vars
>>> request.body = copystream_progress(request) ### stores request body
>>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
>>> copystream_progress
>>> copystream(source, dest, size, chunk_size)
>>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in 
>>> copystream
>>> data = src.read(size)
>>> IOError: request data read error
>>>
>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/**brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.**com  - 
> Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>
>>>  
>

-- 





[web2py] Auth.register() questions

2012-07-16 Thread cyan

I have a couple of questions about the provided Auth.register() function (I 
suppose they also apply to other Auth functions in general):

1. In a controller, if I do:

def register():
return dict(form=auth.register())

with the following settings in a model:

auth.settings.registration_requires_verification = True
auth.settings.register_next = URL (...)

Everything works as expected, i.e. the verification email is sent after the 
registration form is processed, and the user gets re-directed to a 
different page. However, as soon as I do sth like:

def register():
form = auth.register()
# then do sth with the form
return dict(form=form)

Both verification email and re-direction stop working even though the form 
processed successfully. I wonder what causes this breakdown? I am using the 
trunk version of web2py.


2. How much customization can we do with the form returned by 
auth.register()? I know we can add add fields to it (a few different ways), 
but can we modify its class? For example, I am able to do sth like:

form.element(_type='submit')['_class'] = '...'

to change the class of its elements. How do we change the class for the 
whole form? How do we position each field? How do we position the whole 
form on the page? etc.

Thanks in advance! 





[web2py] Re: web2py on EC2

2012-07-16 Thread rdodev
Run with 'sudo' in front.

On Monday, July 16, 2012 1:46:28 PM UTC-4, lyn2py wrote:
>
> Hi,
>
> I have browsed a few older threads on this but didn't manage to find an 
> answer. Hope I can get help here.
>
> I started an instance with Ubuntu image, per the instructions here:
> http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2
>
> And got stuck at this command:
> ./setup-web2py-ubuntu.sh
>
> because "Permission Denied"... what should I do?
>
> Here is a snippet of the output:
>
>> installing useful packages
>>
>> ==
>>
>> E: Could not open lock file /var/lib/apt/lists/lock - open (13: 
>>> Permission denied)
>>
>> E: Unable to lock directory /var/lib/apt/lists/
>>
>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>>> denied)
>>
>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>>> root?
>>
>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>>> denied)
>>
>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>>> root?
>>
>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>>> denied)
>>
>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>>> root?
>>
>> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>>> denied)
>>
>> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>>> root?
>>
>>

[web2py] Re: Restful authentication and CORS

2012-07-16 Thread rdodev
Massimo, 

As Alec mentioned above, if not RESTful, OAuth and jsonrpc/jsonp would work 
as well. So if this is the preferred approach to non-browser/mobile 
authentication I could definitely work with that.

Thanks. 

On Monday, July 16, 2012 1:59:30 PM UTC-4, Massimo Di Pierro wrote:
>
> Can you descrive in some details the API's you would like to have?
> If there is agreement it would not much to add them.
>
>
> On Monday, 16 July 2012 10:18:55 UTC-5, rdodev wrote:
>>
>> I'm developing a web2py app that will be used as the back-end for a 
>> mobile app. The mobile app will be making API calls to the service for 
>> anything ranging from login/authentication to CRUD operations. The auth 
>> model that comes baked into web2py would suffice, except that it's not 
>> RESTful and it's mostly geared to work with a web browser (sessions, 
>> cookies, etc.). Is there a way to set the auth module to behave RESTfully?
>>
>> Another issue is that some of the mobile clients might be running on a 
>> webView (phoneGap) and thus issuing requests to out back end would result 
>> in a same-origin policy denial. Is there a way to setup CORS in web2py (or 
>> should we set that up through apache/wsgi instead?)
>>
>> Thanks.
>>
>

[web2py] Re: Restful authentication and CORS

2012-07-16 Thread Massimo Di Pierro
Can you descrive in some details the API's you would like to have?
If there is agreement it would not much to add them.


On Monday, 16 July 2012 10:18:55 UTC-5, rdodev wrote:
>
> I'm developing a web2py app that will be used as the back-end for a mobile 
> app. The mobile app will be making API calls to the service for anything 
> ranging from login/authentication to CRUD operations. The auth model that 
> comes baked into web2py would suffice, except that it's not RESTful and 
> it's mostly geared to work with a web browser (sessions, cookies, etc.). Is 
> there a way to set the auth module to behave RESTfully?
>
> Another issue is that some of the mobile clients might be running on a 
> webView (phoneGap) and thus issuing requests to out back end would result 
> in a same-origin policy denial. Is there a way to setup CORS in web2py (or 
> should we set that up through apache/wsgi instead?)
>
> Thanks.
>


[web2py] Re: Want to build a site like flattr on web2py/python?

2012-07-16 Thread Massimo Di Pierro
Is has been done (in web2py): http://www.ekjaa.org/Ekjaa/default/index

They do not have legal permission to accept payments outside of India. 
Contact them. Perhaps they are willing to share the code and or parter with 
you.

Massimo

On Monday, 16 July 2012 10:20:11 UTC-5, lukedc wrote:
>
> Can it be done? And what will I need to know?
>
> I am learning Python now, will be learning web2py soon. The site will take 
> points from people, and then use the points given to determine how much 
> money to give to the websites. Can I do all this with web2py?
>
> Also, what will I need to learn? I only know Python now, will be learning 
> HTML and CSS. What else will I need to learn? thank you so much, Luke
> Can it be done? And what will I need to know?
>
> I am learning Python now, will be learning web2py soon. The site will take 
> points from people, and then use the points given to determine how much 
> money to give to the websites. Can I do all this with web2py?
>
> Also, what will I need to learn? I only know Python now, will be learning 
> HTML and CSS. What else will I need to learn? thank you so much, Luke
>
> 
>


Re: [web2py] solicitation for help with public health project for lip reading

2012-07-16 Thread Jason Brower

Sounds fun!  Let's talk more about it.
skype:super-jason
or just use my email...

On 07/16/2012 01:23 AM, web-dev-m wrote:
I am working on many projects, and I figured I would ask for help on 
here to see if anyone wants to help with this.


We are currently working on a project to help hearing impaired people 
learn to read lips better.  When hearing impaired people learn to 
speak, they must rely on lip reading more than the average person in 
order to improve their vocabulary.  As a result, many hearing impaired 
people have vocabulary and reading abilities many grade levels below 
the average person.  We are working on a web2py solution to this 
problem.  The basic setup of the site is as follows:


Users will come to the site and be able to navigate a categorical list 
of uploaded words. This program will display videos of people saying 
words, along with their definition, and use in a sentence. Ideally, 
users will be able to read the words into their computer microphone 
and get feedback on computer recognition of their pronunciation.


Users can also add entries wikipedia style. On the back end, a select 
group of users is defined which can allow user entries to be displayed 
to the public.  These users can also edit the uploaded videos/their 
definitions/and sentences.


If you have any interest in helping make this project a success, 
please let me know.  If you want to take over development of this 
project, we are also willing to pay up to $1500 for a nice looking, 
complete solution.





Re: [web2py] KeyError on pyfpdf

2012-07-16 Thread thinkwell
Thanks Mariano & Alan. Adding width to TD or TH tags did resolve the 
problem using the original html.py file without the fix implemented.*(Mariano, 
I tried installing your script and at this point it still fails when no 
width is specified. Another little issue, os.startfile() seems to be a 
Windows-only method.)*

So now, things are operational again. Looking forward to Mariano's html.py 
improvements.


On Sunday, July 15, 2012 3:04:04 PM UTC-4, Mariano Reingart wrote:
>
> On Sat, Jul 14, 2012 at 5:06 PM, thinkwell wrote: 
> > Hello everyone, 
> > 
> > I'm experimenting with pyfpdf with HTML formatting, but it's not going 
> so 
> > well. Is a bit buggy. For example, this code generates a KeyError: 
> 'width'. 
> > 
> > {from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
> > from gluon.html import * 
> > 
> > header = HEAD('html2pdf', _align='center') 
> > 
> > pets = TABLE(_border=1, _width="100%") 
> > pets.append(TR(TH('Dogs'),TH("Cats"),TH('Snakes'))) 
> > pets.append(TR('Collies','Tabby','Python')) 
> > pets.append(TR('Akitas', 'Persian', 'Garter')) 
> > 
> > 
> > class MyFPDF(FPDF, HTMLMixin): 
> > pass 
> > 
> > html2 = pets.xml() 
> > 
> > print html2 
> > 
> > pdf=MyFPDF() 
> > #First page 
> > pdf.add_page() 
> > pdf.write_html(html2) 
> > pdf.output('html2.pdf','F')} 
> > 
> > I 
> > {/usr/lib/python2.7/HTMLParser.pyc in goahead(self, end) 
> > 156 if startswith('<', i): 
> > 157 if starttagopen.match(rawdata, i): # < + letter 
> > --> 158 k = self.parse_starttag(i) 
> > 159 elif startswith(" > 160 k = self.parse_endtag(i) 
> > 
> > /usr/lib/python2.7/HTMLParser.pyc in parse_starttag(self, i) 
> > 322 self.handle_startendtag(tag, attrs) 
> > 323 else: 
> > --> 324 self.handle_starttag(tag, attrs) 
> > 325 if tag in self.CDATA_CONTENT_ELEMENTS: 
> > 326 self.set_cdata_mode(tag) 
> > 
> > /home/dave/PythonTraining/web2py/gluon/contrib/pyfpdf/html.pyc in 
> > handle_starttag(self, tag, attrs) 
> > 245 self.td = dict([(k.lower(), v) for k,v in 
> > attrs.items()]) 
> > 246 self.th = True 
> > --> 247 if self.td.has_key('width'): 
> > 248 self.table_col_width.append(self.td['width']) 
> > 249 if tag=='thead': 
> > 
> > KeyError: 'width' 
> > } 
> > 
> > I tried changing line 247 to - 
> > {if self.td.has_key('width'):} 
> > 
> > But the KeyError is still getting raised. :-( 
>
> You need to restart the webservice to apply changes in gluon 
>
> > Is  generating reports from HTML not recommended? In addition to this 
> > KeyError, I've frequently gotten "list out of range" exceptions raised 
> as 
> > well, on what seem like the most vanilla of experiments. 
>
> Current html2pdf conversion will not work properly if you don't use 
> explicit widths for table cells. 
> You can see the supported tags and a working example here: 
>
> http://code.google.com/p/pyfpdf/wiki/WriteHTML 
>
> Actually, I'm working in a better html2pdf render, using helpers and 
> web2pyHTMLParser: 
>
> http://code.google.com/p/pyfpdf/source/browse/fpdf/html.py 
>
> Hopefully, web2py helpers will improve the rendering mechanisms 
>
> Best regards, 
>
> Mariano Reingart 
> http://www.sistemasagiles.com.ar 
> http://reingart.blogspot.com 
>


[web2py] web2py on EC2

2012-07-16 Thread lyn2py
Hi,

I have browsed a few older threads on this but didn't manage to find an 
answer. Hope I can get help here.

I started an instance with Ubuntu image, per the instructions here:
http://www.scribd.com/doc/26436821/Howto-deploy-Web2py-on-amazon-Ec2

And got stuck at this command:
./setup-web2py-ubuntu.sh

because "Permission Denied"... what should I do?

Here is a snippet of the output:

> installing useful packages
>
> ==
>
> E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission 
>> denied)
>
> E: Unable to lock directory /var/lib/apt/lists/
>
> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>> denied)
>
> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>> root?
>
> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>> denied)
>
> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>> root?
>
> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>> denied)
>
> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>> root?
>
> E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission 
>> denied)
>
> E: Unable to lock the administration directory (/var/lib/dpkg/), are you 
>> root?
>
>

Re: [web2py] Restful authentication and CORS

2012-07-16 Thread Alec Taylor
On Tuesday, July 17, 2012 2:20:08 AM UTC+10, David Marko wrote:
>
> +1 from me having this. Btw. On client side i'm using AngularJS and 
> Trigger.io (instead of PhoneGap)


I've been looking around, and will have one of the following setups:

   - *AngularJS * with 
*BarristerRPC
   *
   - *BackboneJS * with 
*Backbone.Rpc
   *
   - *JQuery mobile*  with 
*jquery-jsonrpc*(or plain 
JSON.stringify)
   
All within a *PhoneGap * (*Apache 
Cordova
*) app using the* Facebook connect 
plugin
* for authentication (for graceful downgrade from Facebook mobile 
appto Facebook 
website auth ).

I should have a PoC  on 
August 2 with a full backend written in web2py and two frontends (one in 
web2py views; the other in one of the above frameworks).
Subsequently I'll release it under a full open-source license onto 
Bitbucket. I'll post to the web2py list with link + slides when the repo is 
live  


Re: [web2py] Restful authentication and CORS

2012-07-16 Thread Alec Taylor
On Tue, Jul 17, 2012 at 2:20 AM, David Marko  wrote:
> +1 from me having this. Btw. On client side i'm using AngularJS and
Trigger.io (instead of PhoneGap)

I've been looking around, and will have one of the following setups:

   - *AngularJS * with
*BarristerRPC
   *
   - *BackboneJS * with
*Backbone.Rpc
   *
   - *JQuery mobile*  with
*jquery-jsonrpc*(or plain
JSON.stringify)

All within a *PhoneGap * (*Apache
Cordova
*) app using the* Facebook connect
plugin
* for authentication (for graceful downgrade from Facebook mobile
appto Facebook
website auth ).

I should have a PoC  on
August 2 with a full backend written in web2py and two frontends (one in
web2py views; the other in one of the above frameworks).

Subsequently I'll release it under a full open-source license onto
Bitbucket. I'll post to the web2py list with link + slides when the repo is
live [?]
<<001.png>>

Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruno Rocha
I tested putting sessions in database, but for some strange reason, when
sessions are in db, user are not redirect to login._next after the login,
and other issues. Also I think sessions in db gets a bit slower.

I am planning to test sessions in redis.


On Mon, Jul 16, 2012 at 1:01 PM, Bruce Wade  wrote:

> That I/o warning shouldn't take down your site I have the same issue with
> linode. I think sessions need to be done differently especially on high
> load sites with a load balancer sometimes I find over 400,000 files in the
> session folder on each server × 4
>  On Jul 16, 2012 8:14 AM, "Bruno Rocha"  wrote:
>
>> I am having a related problem.
>>
>> "Your Linode, blouserver, has exceeded the notification threshold (1000)
>> for disk io rate by averaging 1382.77 for the last 2 hours:
>>
>> I receive this message every 2 hour, so my nginx get bas gateway and I
>> need to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get
>> the site running again.
>>
>>
>>
>> On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> This may be related to a bug in rocket that was not catching timouterror
>>> and occasionally sending/receiving incomplete requests.
>>>
>>> Try upgrade rocket.py yo trunk. You can leave everything unchanged. Let
>>> us know if the error go away.
>>>
>>> It is also possible that the request is actually invalid (the browser
>>> declares a different size than it sends). Perhaps because of network
>>> issues. Perhaps web2py could report a better (clearer error). Do you think
>>> it should be logged or silently ignore and the request dropped?
>>>
>>> Massimo
>>>
>>>
>>> On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:

 I am using the latest stable still.

 On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
 massimo.dipie...@gmail.com> wrote:

> Which web2py version? The error is from copying the request body into
> a tmp object in web2py. Looks like the request declares a size in the
> header but it is shorter (truncated).
>
>
>
> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>
>> I'm having ongoing problems with IOErrors from one of my web2py apps
>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
>> maybe happening at a lower level before it even gets to my app code?
>>
>> Traceback (most recent call last):
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in
>> wsgibase
>> parse_get_post_vars(request, environ)
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in
>> parse_get_post_vars
>> request.body = copystream_progress(request) ### stores request body
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in
>> copystream_progress
>> copystream(source, dest, size, chunk_size)
>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in
>> copystream
>> data = src.read(size)
>> IOError: request data read error
>>
>


 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/**brucelwade
 http://www.wadecybertech.com
 http://www.fittraineronline.**com  -
 Fitness Personal Trainers Online
 http://www.warplydesigned.com


>>


Re: [web2py] Restful authentication and CORS

2012-07-16 Thread David Marko
+1 from me having this. Btw. On client side i'm using AngularJS and Trigger.io 
(instead of PhoneGap)


Re: [web2py] Restful authentication and CORS

2012-07-16 Thread Alec Taylor
Hi rdodev,

I'm doing the exact same thing (well similar concept... using PhoneGap
and remote auth, but using JSONRPC and OAuth2 instead of REST and
regular auth)

Keep an eye on this issue: http://code.google.com/p/web2py/issues/detail?id=872

When the dev's get the time they'll be adding in digest auth support.

All the best,

Alec Taylor

On Tue, Jul 17, 2012 at 1:18 AM, rdodev  wrote:
> I'm developing a web2py app that will be used as the back-end for a mobile
> app. The mobile app will be making API calls to the service for anything
> ranging from login/authentication to CRUD operations. The auth model that
> comes baked into web2py would suffice, except that it's not RESTful and it's
> mostly geared to work with a web browser (sessions, cookies, etc.). Is there
> a way to set the auth module to behave RESTfully?
>
> Another issue is that some of the mobile clients might be running on a
> webView (phoneGap) and thus issuing requests to out back end would result in
> a same-origin policy denial. Is there a way to setup CORS in web2py (or
> should we set that up through apache/wsgi instead?)
>
> Thanks.


[web2py] Restful authentication and CORS

2012-07-16 Thread rdodev
I'm developing a web2py app that will be used as the back-end for a mobile 
app. The mobile app will be making API calls to the service for anything 
ranging from login/authentication to CRUD operations. The auth model that 
comes baked into web2py would suffice, except that it's not RESTful and 
it's mostly geared to work with a web browser (sessions, cookies, etc.). Is 
there a way to set the auth module to behave RESTfully?

Another issue is that some of the mobile clients might be running on a 
webView (phoneGap) and thus issuing requests to out back end would result 
in a same-origin policy denial. Is there a way to setup CORS in web2py (or 
should we set that up through apache/wsgi instead?)

Thanks.


Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruce Wade
That I/o warning shouldn't take down your site I have the same issue with
linode. I think sessions need to be done differently especially on high
load sites with a load balancer sometimes I find over 400,000 files in the
session folder on each server × 4
On Jul 16, 2012 8:14 AM, "Bruno Rocha"  wrote:

> I am having a related problem.
>
> "Your Linode, blouserver, has exceeded the notification threshold (1000)
> for disk io rate by averaging 1382.77 for the last 2 hours:
>
> I receive this message every 2 hour, so my nginx get bas gateway and I
> need to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get
> the site running again.
>
>
>
> On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> This may be related to a bug in rocket that was not catching timouterror
>> and occasionally sending/receiving incomplete requests.
>>
>> Try upgrade rocket.py yo trunk. You can leave everything unchanged. Let
>> us know if the error go away.
>>
>> It is also possible that the request is actually invalid (the browser
>> declares a different size than it sends). Perhaps because of network
>> issues. Perhaps web2py could report a better (clearer error). Do you think
>> it should be logged or silently ignore and the request dropped?
>>
>> Massimo
>>
>>
>> On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>>>
>>> I am using the latest stable still.
>>>
>>> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Which web2py version? The error is from copying the request body into a
 tmp object in web2py. Looks like the request declares a size in the header
 but it is shorter (truncated).



 On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>
> I'm having ongoing problems with IOErrors from one of my web2py apps
> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
> maybe happening at a lower level before it even gets to my app code?
>
> Traceback (most recent call last):
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in
> wsgibase
> parse_get_post_vars(request, environ)
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in
> parse_get_post_vars
> request.body = copystream_progress(request) ### stores request body
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in
> copystream_progress
> copystream(source, dest, size, chunk_size)
> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in
> copystream
> data = src.read(size)
> IOError: request data read error
>

>>>
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade
>>> http://www.wadecybertech.com
>>> http://www.fittraineronline.**com  -
>>> Fitness Personal Trainers Online
>>> http://www.warplydesigned.com
>>>
>>>
>


[web2py] Want to build a site like flattr on web2py/python?

2012-07-16 Thread lukedc
Can it be done? And what will I need to know?

I am learning Python now, will be learning web2py soon. The site will take 
points from people, and then use the points given to determine how much 
money to give to the websites. Can I do all this with web2py?

Also, what will I need to learn? I only know Python now, will be learning 
HTML and CSS. What else will I need to learn? thank you so much, Luke
Can it be done? And what will I need to know?

I am learning Python now, will be learning web2py soon. The site will take 
points from people, and then use the points given to determine how much 
money to give to the websites. Can I do all this with web2py?

Also, what will I need to learn? I only know Python now, will be learning 
HTML and CSS. What else will I need to learn? thank you so much, Luke



Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruno Rocha
I am having a related problem.

"Your Linode, blouserver, has exceeded the notification threshold (1000)
for disk io rate by averaging 1382.77 for the last 2 hours:

I receive this message every 2 hour, so my nginx get bas gateway and I need
to do "rm sessions/* " and also  "/etc/init.d/uwsgi restart" to get the
site running again.



On Mon, Jul 16, 2012 at 12:07 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This may be related to a bug in rocket that was not catching timouterror
> and occasionally sending/receiving incomplete requests.
>
> Try upgrade rocket.py yo trunk. You can leave everything unchanged. Let us
> know if the error go away.
>
> It is also possible that the request is actually invalid (the browser
> declares a different size than it sends). Perhaps because of network
> issues. Perhaps web2py could report a better (clearer error). Do you think
> it should be logged or silently ignore and the request dropped?
>
> Massimo
>
>
> On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>>
>> I am using the latest stable still.
>>
>> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Which web2py version? The error is from copying the request body into a
>>> tmp object in web2py. Looks like the request declares a size in the header
>>> but it is shorter (truncated).
>>>
>>>
>>>
>>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:

 I'm having ongoing problems with IOErrors from one of my web2py apps
 deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
 maybe happening at a lower level before it even gets to my app code?

 Traceback (most recent call last):
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
 parse_get_post_vars(request, environ)
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in
 parse_get_post_vars
 request.body = copystream_progress(request) ### stores request body
 File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in
 copystream_progress
 copystream(source, dest, size, chunk_size)
 File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in
 copystream
 data = src.read(size)
 IOError: request data read error

>>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com  -
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


[web2py] Re: Sending emails through Amazon SES

2012-07-16 Thread rdodev
Oh yes, there is: check out boto. They're fairly active and the product is 
fairly mature. I've helped them with the docs and we use use boto on most 
of our products.



On Monday, July 16, 2012 10:15:19 AM UTC-4, murtaza52 wrote:
>
>
> I can do this by just using the SMTP interface of AWS as no python wrapper 
> is available for its API!
>
> On Monday, July 16, 2012 5:51:22 PM UTC+5:30, murtaza52 wrote:
>>
>> Hi,
>>
>> I would like to send emails using Amazon SES that have attachments. Any 
>> pointers on how I could do that. 
>>
>> We are deploying on GAE, but need to send emails from non google domains, 
>> thus using Amazon SES. The python libs that I have seen till now only allow 
>> emails to be sent without attachments. 
>>
>> Thanks,
>> Murtaza
>>
>

Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Massimo Di Pierro
This may be related to a bug in rocket that was not catching timouterror 
and occasionally sending/receiving incomplete requests.

Try upgrade rocket.py yo trunk. You can leave everything unchanged. Let us 
know if the error go away.

It is also possible that the request is actually invalid (the browser 
declares a different size than it sends). Perhaps because of network 
issues. Perhaps web2py could report a better (clearer error). Do you think 
it should be logged or silently ignore and the request dropped?

Massimo

On Monday, 16 July 2012 10:00:14 UTC-5, Bruce Wade wrote:
>
> I am using the latest stable still.
>
> On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Which web2py version? The error is from copying the request body into a 
>> tmp object in web2py. Looks like the request declares a size in the header 
>> but it is shorter (truncated).
>>
>>
>>
>> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>>
>>> I'm having ongoing problems with IOErrors from one of my web2py apps 
>>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
>>> maybe happening at a lower level before it even gets to my app code?
>>>
>>> Traceback (most recent call last):
>>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in wsgibase
>>> parse_get_post_vars(request, environ)
>>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in 
>>> parse_get_post_vars
>>> request.body = copystream_progress(request) ### stores request body
>>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in 
>>> copystream_progress
>>> copystream(source, dest, size, chunk_size)
>>> File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 374, in 
>>> copystream
>>> data = src.read(size)
>>> IOError: request data read error
>>>
>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

Re: [web2py] Re: Help! IOErrors

2012-07-16 Thread Bruce Wade
I am using the latest stable still.

On Mon, Jul 16, 2012 at 7:58 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Which web2py version? The error is from copying the request body into a
> tmp object in web2py. Looks like the request declares a size in the header
> but it is shorter (truncated).
>
>
>
> On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>>
>> I'm having ongoing problems with IOErrors from one of my web2py apps
>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
>> maybe happening at a lower level before it even gets to my app code?
>>
>> Traceback (most recent call last):
>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 447, in wsgibase
>> parse_get_post_vars(request, environ)
>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 275, in
>> parse_get_post_vars
>> request.body = copystream_progress(request) ### stores request body
>> File "C:\\dashboard\\web2py\\gluon\**\main.py", line 143, in
>> copystream_progress
>> copystream(source, dest, size, chunk_size)
>> File "C:\\dashboard\\web2py\\gluon\**\fileutils.py", line 374, in
>> copystream
>> data = src.read(size)
>> IOError: request data read error
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: Help! IOErrors

2012-07-16 Thread Massimo Di Pierro
Which web2py version? The error is from copying the request body into a tmp 
object in web2py. Looks like the request declares a size in the header but 
it is shorter (truncated).



On Friday, 13 July 2012 16:27:51 UTC-5, Brian M wrote:
>
> I'm having ongoing problems with IOErrors from one of my web2py apps 
> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error 
> maybe happening at a lower level before it even gets to my app code?
>
> Traceback (most recent call last):
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
> parse_get_post_vars(request, environ)
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in 
> parse_get_post_vars
> request.body = copystream_progress(request) ### stores request body
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in 
> copystream_progress
> copystream(source, dest, size, chunk_size)
> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in copystream
> data = src.read(size)
> IOError: request data read error
>


[web2py] response.JSON Decimal problem

2012-07-16 Thread Vineet
Hi !
>From a controller, I am trying to return a jsonified resultset (obtained by 
executing sql directly).

resultset = ( ('201207020920', Decimal('5308.20'), Decimal('5308.20'), 
Decimal('5288.00'), Decimal('5292.40'), ...)

## convertd it to list of lists

list_of_tuples = list(resultset)
list_of_lists = [list(i) for i in list_of_tuples]

## Since an error is thrown as under--

TypeError: Decimal('5308.20') is not JSON serializable


## convertd all list items decimal to str ---

for x in list_of_lists:
for y in x:
y = str(y)
print y, 'type of this y is ', type(y)

## confirmed that all are of type 'str'

D = dict(list_of_lists = list_of_lists)
return response.json(D)

Still, the same error is thrown as under--

TypeError: Decimal('5308.20') is not JSON serializable

How do I fix this?

Thanks,

Vineet



Re: [web2py] Help! IOErrors

2012-07-16 Thread Bruce Wade
I also get these errors randomly on nginx+uwsgi+ubuntu so I really don't
think it is a file permissions problem as it happens randomly.

On Mon, Jul 16, 2012 at 12:25 AM, Johann Spies wrote:

> On 13 July 2012 23:27, Brian M  wrote:
>
>> I'm having ongoing problems with IOErrors from one of my web2py apps
>> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
>> maybe happening at a lower level before it even gets to my app code?
>>
>> Traceback (most recent call last):
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
>> parse_get_post_vars(request, environ)
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in
>> parse_get_post_vars
>> request.body = copystream_progress(request) ### stores request body
>> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in
>> copystream_progress
>> copystream(source, dest, size, chunk_size)
>> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in copystream
>> data = src.read(size)
>> IOError: request data read error
>>
>
> I have never worked on Windows with Apache but this looks like either
> incorrect ownership of the web2py files or just a permission problem.
>
> Make sure the user that owns Apache process is the one that owns the
> web2py tree or at least has full access to it.
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: Sending emails through Amazon SES

2012-07-16 Thread murtaza52

I can do this by just using the SMTP interface of AWS as no python wrapper 
is available for its API!

On Monday, July 16, 2012 5:51:22 PM UTC+5:30, murtaza52 wrote:
>
> Hi,
>
> I would like to send emails using Amazon SES that have attachments. Any 
> pointers on how I could do that. 
>
> We are deploying on GAE, but need to send emails from non google domains, 
> thus using Amazon SES. The python libs that I have seen till now only allow 
> emails to be sent without attachments. 
>
> Thanks,
> Murtaza
>


[web2py] Re: Need a little help with DAL

2012-07-16 Thread Anthony
Can you send your exact code?

On Monday, July 16, 2012 8:35:15 AM UTC-4, Aurelijus Useckas wrote:
>
> Hi, 
>
> I have declared a table 'company' and the Field 'workers' which expects 
> the number of workers in the company:
>
> db.define_table('company',
> (...)
> Field('workers', 'integer'),
>  
> The problem arrises when I want to do some computations with this field, 
> for instance select some row. Strange stuff happens.
>
> Let's say I have 4 entries/rows:
>
>   db.compny.workers
> id 1 5
> id 2 6
> id 3 12
> id 4 40
>
> When I run a query *db.company.workers>0 *the results are fine 
> (4 displayed), 
> When I run  *db.company.workers<38 *only the id 3 (12 workers) is shown.
> *db.company.workers<100 *gives *none* results. 
> *db.company.workers>5 *gives only 6  
>
> I have absolutely no clue what is going on. Thnx
>  
>
>
>

[web2py] Re: Can't import external modules

2012-07-16 Thread Massimo Di Pierro
Are you running the web2py for OSX? That ships with its own python 
interpreter and ignores any other python and module you may have installed. 
I suggest you use web2py source since you already have python installed.

On Sunday, 15 July 2012 14:26:11 UTC-5, DonH wrote:
>
> I have installed an external module (several .py files in a directory) 
> that I want to import into my web2py app.  I'm running on OS X and have 
> installed Python 2.7.  When I run Python from terminal, I can import the 
> modules successfully, but when I attempt to import them in my web2py app, 
> they cannot be found.  The ticket indicates that the Python version is 
> 2.5.1 running from the web2py app, so I'm not clear how I can import these 
> modules.  Copying them into the app/modules folder does not seem to work 
> either.
>
> Can I either
> - change the web2py Python version to run my local python 2.7? 
> - place the modules somewhere in the app directory structure to be found?
> - a different solution?
>
> Thanks for any help!
> -- Don
>


[web2py] Re: Ajax Records Delete

2012-07-16 Thread Massimo Di Pierro
grid = SQLFORM.grid(db.Cars) does what you ask. Look at the generated code 
and the source code of the grid in sqlhtml.py

On Monday, 16 July 2012 02:38:53 UTC-5, Hassan Alnatour wrote:
>
> Dear ALL ,,
>
> I want to delete records and return them in ajax ,  i have a table like 
> this :
>
> db.define_table('Cars',
> Field('Name'),
> Field('Age')
> )
>
> and i get all the records to my page  using a for loop over the object 
> the equals db().select(db.Cars.ALL)
>
> what i want is to have a button next to every car to delete it in ajax and 
> update the records that i am viewing 
>
>
> what is the best way to do this ? 
>
>
> Best Regards,
>
>

[web2py] Re: Trunk version: admin not working

2012-07-16 Thread dederocks
Thanks for the feedback. My mistake -- access rights were missing. Sorry 
for the noise.
André

Le lundi 16 juillet 2012 09:16:46 UTC+2, dederocks a écrit :
>
> Hello, 
>
> The trunk version does not allow access to the admin interface (ticket 
> issued). Is it me only?
>
> Andre
>


Re: [web2py] How to build a modular menu

2012-07-16 Thread Richard Vézina
Johann,

I think there is miss closed bracket in the first example of what you want.

And, I am not sure that you really want a "+=" to combine your submenu,
since they get add to the first level of the menu that way, maybe you want
.append() or maybe you can "+=" but you will need some more "[]".

Richard

On Mon, Jul 16, 2012 at 8:18 AM, Johann Spies wrote:

> I want to break up the following code to  make it more modular, but I
> could so far not get it right:
>
> r
> esponse.menu = [
> (T('Home'), URL('default', 'index') == URL(), URL('default', 'index'),
> []),
> ]
>
> akb_menu = [(T('Africa Knowledgebase'), False, None,
>  [ (T('Articles'), False, None,
>   [
> (T('Add article'), False, URL(request.application,
> 'articles', 'kryskrywers')),
>
> ]),
>(T('Journals'), False, None,
> [
> (T('List all journals'), False, URL(request.
> application, 'journal', 'journals')),
> ]),
>(T('Authors'), False, None,
> [
>  (T('Add author'), False, URL(request.application,
> 'authors', 'add_author')),
> ]),
>
>(T('Publications statistics'), False, URL(request.
> application, 'default', 'sa_pubstats')),
> ]
> )
>]
>  )
> ]
>
>
> response.menu += akb_menu
>
>  I want to get the same result as the above menu using this approach:
>
>
> response.menu = [
> (T('Home'), URL('default', 'index') == URL(), URL('default', 'index'),
> []),
> ]
> akb_menu = [(T('Africa Knowledgebase'), False, None,)]
>
>
> art_menu =   [ (T('Articles'), False, None,
> [
> (T('Add article'), False, URL(request.application,
> 'articles', 'kryskrywers')),
>
> ])]
>
> auth_menu =   [ (T('Authors'), False, None,
> [
>  (T('Add author'), False, URL(request.application,
> 'authors', 'add_author')),
> ])]
>
> jrn_menu =   [(T('Journals'), False, None,
> [
> (T('List all journals'), False, URL(request.
> application, 'journal', 'journals')),
> ])]
>
> stat_menu = [(T('Publications statistics'), False, URL(request.application
> , 'default', 'sa_pubstats'))]
> for mn in [art_menu, auth_menu, jrn_menu, stat_menu]:
> akb_menu += mn
>
>
>
> response.menu += akb_menu
>
> Can somebody help me to see where  I made the mistake please.
>
> Regards
> Johann.
>
>


[web2py] Re: Need a little help with DAL

2012-07-16 Thread Niphlod
I can't reproduce the error. What db engine are you using and what web2py 
version are you running ?



On Monday, July 16, 2012 2:35:15 PM UTC+2, Aurelijus Useckas wrote:
>
> Hi, 
>
> I have declared a table 'company' and the Field 'workers' which expects 
> the number of workers in the company:
>
> db.define_table('company',
> (...)
> Field('workers', 'integer'),
>  
> The problem arrises when I want to do some computations with this field, 
> for instance select some row. Strange stuff happens.
>
> Let's say I have 4 entries/rows:
>
>   db.compny.workers
> id 1 5
> id 2 6
> id 3 12
> id 4 40
>
> When I run a query *db.company.workers>0 *the results are fine 
> (4 displayed), 
> When I run  *db.company.workers<38 *only the id 3 (12 workers) is shown.
> *db.company.workers<100 *gives *none* results. 
> *db.company.workers>5 *gives only 6  
>
> I have absolutely no clue what is going on. Thnx
>  
>
>
>

[web2py] Need a little help with DAL

2012-07-16 Thread Aurelijus Useckas
Hi, 

I have declared a table 'company' and the Field 'workers' which expects the 
number of workers in the company:

db.define_table('company',
(...)
Field('workers', 'integer'),
 
The problem arrises when I want to do some computations with this field, 
for instance select some row. Strange stuff happens.

Let's say I have 4 entries/rows:

  db.compny.workers
id 1 5
id 2 6
id 3 12
id 4 40

When I run a query *db.company.workers>0 *the results are fine 
(4 displayed), 
When I run  *db.company.workers<38 *only the id 3 (12 workers) is shown.
*db.company.workers<100 *gives *none* results. 
*db.company.workers>5 *gives only 6  

I have absolutely no clue what is going on. Thnx
 




[web2py] Sending emails through Amazon SES

2012-07-16 Thread murtaza52
Hi,

I would like to send emails using Amazon SES that have attachments. Any 
pointers on how I could do that. 

We are deploying on GAE, but need to send emails from non google domains, 
thus using Amazon SES. The python libs that I have seen till now only allow 
emails to be sent without attachments. 

Thanks,
Murtaza


[web2py] How to build a modular menu

2012-07-16 Thread Johann Spies
I want to break up the following code to  make it more modular, but I could 
so far not get it right:

r
esponse.menu = [
(T('Home'), URL('default', 'index') == URL(), URL('default', 'index'), 
[]),
]

akb_menu = [(T('Africa Knowledgebase'), False, None,
 [ (T('Articles'), False, None,
  [
(T('Add article'), False, URL(request.application, 
'articles', 'kryskrywers')),

]),
   (T('Journals'), False, None,
[
(T('List all journals'), False, URL(request.application, 
'journal', 'journals')),
]),
   (T('Authors'), False, None,
[
 (T('Add author'), False, URL(request.application, 
'authors', 'add_author')),
]),

   (T('Publications statistics'), False, URL(request.application
, 'default', 'sa_pubstats')),
]
)
   ]
 )
]


response.menu += akb_menu

 I want to get the same result as the above menu using this approach:


response.menu = [
(T('Home'), URL('default', 'index') == URL(), URL('default', 'index'), 
[]),
]
akb_menu = [(T('Africa Knowledgebase'), False, None,)]


art_menu =   [ (T('Articles'), False, None,
[
(T('Add article'), False, URL(request.application, 
'articles', 'kryskrywers')),

])]

auth_menu =   [ (T('Authors'), False, None,
[
 (T('Add author'), False, URL(request.application, 
'authors', 'add_author')),
])]

jrn_menu =   [(T('Journals'), False, None,
[
(T('List all journals'), False, URL(request.application, 
'journal', 'journals')),
])]

stat_menu = [(T('Publications statistics'), False, URL(request.application, 
'default', 'sa_pubstats'))]
for mn in [art_menu, auth_menu, jrn_menu, stat_menu]:
akb_menu += mn



response.menu += akb_menu

Can somebody help me to see where  I made the mistake please.

Regards
Johann.



[web2py] pg8000 '%' not supported in quoted string

2012-07-16 Thread KMax
Hello,
 Seems like an issue for me, pg8000 cant insert into db char '%'.
 As a result inserting string = 'We did it for 100%' throw an exception.
 
 '%'' not 
supported in quoted string

 pg8000 checks for '%' in an arguments, so...

Thank you.
--
Maxim


Re: [web2py] Re: we need testers for new functionalities

2012-07-16 Thread Vladyslav Kozlovskyy
Sorry, but I didn't find a mistake in markmin module. Probably it's a 
wiki-plugin issue. But I'm not familiar with this module yet.


With the best regards,
Vladyslav Kozlovskyy (Ukraine)

16.07.12 10:06, Vladyslav Kozlovskyy написав(ла):

I known where is a problem. I'll fix it

Vladyslav

16.07.12 06:15, villas написав(ла):

Regarding widgets,  the trunk version seems to have introduced a problem.

In the past I could do this as per the book:

``
name:mywidget
``:widget

But now this fails because of the first empty line.  I can work around it 
with this:


``name:mywidget
``:widget

I cannot see how this could have changed, so maybe it is a problem I have 
introduced into my own code,  but if anyone else has widgets failing,  please 
try my suggestion above.



On Monday, July 16, 2012 1:26:44 AM UTC+1, Massimo Di Pierro wrote:

Second. Vladyslav has done an impressive work. I still have lots of
patches from him improving many areas. I am finding hard to keep up. ;-)

I am also looking for ways to include widgets in the new wiki... Let me
know if you have suggestions.

Massimo

On Sunday, 15 July 2012 17:38:58 UTC-5, villas wrote:

I really like the new Markmin features and well done Vladyslav - I am
amazed by your results in such a short time!

New Wiki is also excellent and is a much neater integration into a
site. I have been working quite a lot with plugin_wiki and I'm
wondering whether there is some way to leverage my work on widgets, 
or some syntax planned to include a similar thing?


Many thanks for making these improvements  :)


On Sunday, July 15, 2012 5:36:19 AM UTC+1, Massimo Di Pierro wrote:

There is lots of new stuff in trunk. We need you to test it to
make sure it does not break your apps.

Here I will just mention two new features:

1) Improved MARKMIN (check out the latest examples in
gluon/contrib/markmin/markmin.html) including nested lists,
nested blockquotes, etc. Thanks to Vladyslav for this.

2) There is a minimalist built-in WIKI. Just do:

def index(): return auth.wiki()

Then use appadmin to create a 'wiki_editor' group and make
yourself member. Yes, that is all. It uses MARKMIN. Use
@{index/slug} to insert the ling to a page by slug. Pros? Cons?
Suggestions?

Checking that old apps do not break is more important than
checking for new features.









[web2py] Re: how to delete records from table older than 1 day?

2012-07-16 Thread Niphlod
Why write such a query when DAL allows you to use a more (portable, 
concise) pythonic way ?

import datetime
yesterday = request.now - datetime.timedelta(days=1)
db(db.employee.created_on < yesterday).delete()



On Monday, July 16, 2012 12:12:56 PM UTC+2, Amit wrote:
>
> Hi,
> I have created table Employe with following fields:
> db.define_table(
>'Employee',
>Field('created_on','datetime', default=request.now),
>Field('emp_id'),
>Field('emp_age'),
>Field('emp_address),
> )
>  inserting data into the table is working fine but when i am trying to 
> delete data one day older using below command:
>
> db.executesql('DELETE FROM db.Employee WHERE created_on < date_sub(now(), 
> INTERVAL 1 DAY);')
>
> It's not working and i am not getting any error also, so can anybody help 
> me resolve this issue.
> NOTE: I am using Sqlite database.
>
>
>

[web2py] how to delete records from table older than 1 day?

2012-07-16 Thread Amit
Hi,
I have created table Employe with following fields:
db.define_table(
   'Employee',
   Field('created_on','datetime', default=request.now),
   Field('emp_id'),
   Field('emp_age'),
   Field('emp_address),
)
 inserting data into the table is working fine but when i am trying to 
delete data one day older using below command:

db.executesql('DELETE FROM db.Employee WHERE created_on < date_sub(now(), 
INTERVAL 1 DAY);')

It's not working and i am not getting any error also, so can anybody help 
me resolve this issue.
NOTE: I am using Sqlite database.




[web2py] Re: 1.99.6 can't save, communications error

2012-07-16 Thread davidjensen
the configuration is web2py self install on ubuntu server


# changes user and group owners to www-data, not root
# because files copied in are root and must be www-data
# find uid, gid  by os.lstat
# os.lchown does not work in windows
def run():
import os
uid = 33
gid = 33
the_path = os.getcwd()
all_files = os.listdir(the_path)
for the_file in all_files:
os.lchown(the_file, uid, gid)

___
On Sunday, March 4, 2012 1:37:56 PM UTC-5, Lewis wrote:
>
> Anyone else?  Tried 3 different browsers and two machines.  Tried 
> restarting apache and web2py.  Still can't save.  Not fatal, but it is 
> nice to use the web editor for little changes. 
>
> Thanks. 
>
> BTW:  I am posting less not because I am working less, but because I 
> understand web2py better and everything is going very well.



Re: [web2py] Trunk version: admin not working

2012-07-16 Thread Johann Spies
On 16 July 2012 09:16, dederocks  wrote:

> Hello,
>
> The trunk version does not allow access to the admin interface (ticket
> issued). Is it me only?
>
>
>
No problem here.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Ajax Records Delete

2012-07-16 Thread Hassan Alnatour
Dear ALL ,,

I want to delete records and return them in ajax ,  i have a table like 
this :

db.define_table('Cars',
Field('Name'),
Field('Age')
)

and i get all the records to my page  using a for loop over the object 
the equals db().select(db.Cars.ALL)

what i want is to have a button next to every car to delete it in ajax and 
update the records that i am viewing 


what is the best way to do this ? 


Best Regards,



Re: [web2py] Help! IOErrors

2012-07-16 Thread Johann Spies
On 13 July 2012 23:27, Brian M  wrote:

> I'm having ongoing problems with IOErrors from one of my web2py apps
> deployed on Windows with Apache & mod_wsgi.  Looks to me like the error
> maybe happening at a lower level before it even gets to my app code?
>
> Traceback (most recent call last):
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 447, in wsgibase
> parse_get_post_vars(request, environ)
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 275, in
> parse_get_post_vars
> request.body = copystream_progress(request) ### stores request body
> File "C:\\dashboard\\web2py\\gluon\\main.py", line 143, in
> copystream_progress
> copystream(source, dest, size, chunk_size)
> File "C:\\dashboard\\web2py\\gluon\\fileutils.py", line 374, in copystream
> data = src.read(size)
> IOError: request data read error
>

I have never worked on Windows with Apache but this looks like either
incorrect ownership of the web2py files or just a permission problem.

Make sure the user that owns Apache process is the one that owns the web2py
tree or at least has full access to it.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Trunk version: admin not working

2012-07-16 Thread dederocks
Hello, 

The trunk version does not allow access to the admin interface (ticket 
issued). Is it me only?

Andre


Re: [web2py] Re: we need testers for new functionalities

2012-07-16 Thread Vladyslav Kozlovskyy

I known where is a problem. I'll fix it

Vladyslav

16.07.12 06:15, villas написав(ла):

Regarding widgets,  the trunk version seems to have introduced a problem.

In the past I could do this as per the book:

``
name:mywidget
``:widget

But now this fails because of the first empty line.  I can work around it with 
this:


``name:mywidget
``:widget

I cannot see how this could have changed, so maybe it is a problem I have 
introduced into my own code,  but if anyone else has widgets failing,  please 
try my suggestion above.



On Monday, July 16, 2012 1:26:44 AM UTC+1, Massimo Di Pierro wrote:

Second. Vladyslav has done an impressive work. I still have lots of
patches from him improving many areas. I am finding hard to keep up. ;-)

I am also looking for ways to include widgets in the new wiki... Let me
know if you have suggestions.

Massimo

On Sunday, 15 July 2012 17:38:58 UTC-5, villas wrote:

I really like the new Markmin features and well done Vladyslav - I am
amazed by your results in such a short time!

New Wiki is also excellent and is a much neater integration into a
site. I have been working quite a lot with plugin_wiki and I'm
wondering whether there is some way to leverage my work on widgets, 
or some syntax planned to include a similar thing?


Many thanks for making these improvements  :)


On Sunday, July 15, 2012 5:36:19 AM UTC+1, Massimo Di Pierro wrote:

There is lots of new stuff in trunk. We need you to test it to
make sure it does not break your apps.

Here I will just mention two new features:

1) Improved MARKMIN (check out the latest examples in
gluon/contrib/markmin/markmin.html) including nested lists, nested
blockquotes, etc. Thanks to Vladyslav for this.

2) There is a minimalist built-in WIKI. Just do:

def index(): return auth.wiki()

Then use appadmin to create a 'wiki_editor' group and make
yourself member. Yes, that is all. It uses MARKMIN. Use
@{index/slug} to insert the ling to a page by slug. Pros? Cons?
Suggestions?

Checking that old apps do not break is more important than
checking for new features.