[web2py] Re: user_id is none when session is db

2014-10-15 Thread danny
SOLVED!
I moved the session.connect(...) from the end of my db.py to the top, and 
now it's ok!

thanks,
  danny

On Wednesday, October 15, 2014 8:29:57 AM UTC+3, da...@mail.hebrew.edu 
wrote:


 I created a new application, changed db.py so that session.connect(…) uses 
 postgres,

 created a test user, and all seems ok :-(

 so the hunting is still on, what bothers me is that all works ok when 
 session is stored in file!

 it could be my pam_auth, but it has been working without a problem for a 
 long time.


 thanks,

 danny

 On Tuesday, October 14, 2014 4:46:59 PM UTC+3, Anthony wrote:

 I cannot reproduce this problem. Could you attach a minimal app the 
 reproduces the behavior?

 Anthony

 On Tuesday, October 14, 2014 9:19:59 AM UTC-4, da...@mail.hebrew.edu 
 wrote:

 sorry, some correction:

 the value of auth.user is None, auth is an object.

 which explains why auth.is_logged_in() is False even after a successful 
 login

 On Tuesday, October 14, 2014 2:25:20 PM UTC+3, Anthony wrote:

 What exactly is None (i.e., what do you mean that auth is None)? Is 
 auth defined after connecting the session?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Is it possible to restrict a user to single login instance ?

2014-10-15 Thread Mandar Vaze / मंदार वझे
All,

Let me clarify a little - since lot of answer seemed to focus on MachineA
Vs MachineB
What I need is only one valid session from UserA at given point - so two
sessions - one from Chrome and other from Firefox - both from MachineA -
should be disallowed. (Not sure if it makes problem easy or difficult)

*Theoretically* I am thinking following :

in pre-login (if I can intercept login attempt) - put a code that checks
whether user that is trying to login - has already logged in (and not
logged out yet) If yes, do not allow the login (or somehow forcely
invalidate other session - and allow this login attempt to go thru)

*But I am not sure how this maps to web2py flow/hooks etc*.
So pointers w/ specifics above would help.

Thanks,
-Mandar



On Tue, Oct 14, 2014 at 11:31 PM, Mandar Vaze mandarv...@gmail.com wrote:

 This is related to possible security issue. I've written privately to
 Massimo and Anthony (in another email on this list - they suggested that
 security issues not be discussed publicly on this list)

 Lets say UserA logs in successfully from MachineA
 now without logging out from MachineA - UserA logs in from MachineB

 Is it possible to either :
 not allow login from MachineB (show message that You are currently logged
 in from MachineA - continue to access the application from MachineA, or
 logout from MachineA... or some such message.)
 OR
 allow login from MachineB - but forcefully log out userA from MachineA
 (since login from MachineB was later)

 Either case - UserA is logged in only once from any machine/browser

 I prefer second option - cause the (legitimate) reason why UserA is
 logging in from MachineB is because s/he doesn't have access to MachineA
 (at this point)

 -Mandar

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/Z3gjaLzM65E/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Scheduler only runs 1 task from 2 queued

2014-10-15 Thread António Ramos
2014-10-14 23:06 GMT+01:00 Niphlod niph...@gmail.com:

 web2py.py -M -S appname


Niphold
You deserve a promotion too!!

thank you for your time.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Scheduler only runs 1 task from 2 queued

2014-10-15 Thread António Ramos
using your suggestion

web2py.py -M -S appname

whenever i change my code i have to exit my shell console and run it again
right?

Regards

2014-10-15 10:03 GMT+01:00 António Ramos ramstei...@gmail.com:


 2014-10-14 23:06 GMT+01:00 Niphlod niph...@gmail.com:

 web2py.py -M -S appname


 Niphold
 You deserve a promotion too!!

 thank you for your time.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Is it possible to restrict a user to single login instance ?

2014-10-15 Thread Anthony


 Let me clarify a little - since lot of answer seemed to focus on MachineA 
 Vs MachineB
 What I need is only one valid session from UserA at given point - so two 
 sessions - one from Chrome and other from Firefox - both from MachineA - 
 should be disallowed. (Not sure if it makes problem easy or difficult)


You still need to be able to distinguish one machine/browser from another 
in order to know whether a given login request is coming from a different 
client. The user agent will tell you if a different browser is being used 
(though it can be spoofed, so this is not a security measure), but that 
won't help if someone is using the same browser on two different machines 
(also, what kind of app requires that users should not be able to log in 
from different browsers on the same machine?). And as already mentioned, 
there are limitations to using IP address to uniquely identify machines.
 

 *Theoretically* I am thinking following :

 in pre-login (if I can intercept login attempt) - put a code that checks 
 whether user that is trying to login - has already logged in (and not 
 logged out yet) If yes, do not allow the login (or somehow forcely 
 invalidate other session - and allow this login attempt to go thru)


Maybe add a session_id field to db.auth_user, and when a user logs in (a) 
check that field, and if it has a value, delete the session file associated 
with the existing ID (if it exists) and (b) store the new session_id. Note, 
this won't work with cookie based sessions -- in that case, you would 
instead have to check the session_id value stored in db.auth_user on every 
request in order to catch and invalidate the session cookie from the older 
session (this adds a db lookup to every request -- might want to cache 
these in RAM, though you may need to clean up periodically if there are a 
large number of users).

Also, note that this doesn't protect against session hijacking. It only 
protects against multiple simultaneous logins (which would be using 
different sessions rather than sharing a single hijacked session).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Scheduler only runs 1 task from 2 queued

2014-10-15 Thread Niphlod
if it's a module yes, it's the whole reason of having a module not to 
reevaluate it at every time. If you're debugging, though, it should be a 
function.
Mind that you can always prepare a simple script (i.e. mylaunch.py) and use

web2py.py -M -S appname -R mylaunch.py

mylaunch.py will be executed in the web2py environment, and then the 
process will exit (so, each time you launch it, it recompiles/reevaluate 
everything)

On Wednesday, October 15, 2014 11:06:48 AM UTC+2, Ramos wrote:


 using your suggestion 

 web2py.py -M -S appname

 whenever i change my code i have to exit my shell console and run it again 
 right?

 Regards

 2014-10-15 10:03 GMT+01:00 António Ramos ramst...@gmail.com javascript:
 :


 2014-10-14 23:06 GMT+01:00 Niphlod nip...@gmail.com javascript::

 web2py.py -M -S appname


 Niphold
 You deserve a promotion too!!

 thank you for your time.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Niphlod
you have stop_time equal to start_time. that's the reason why it isn't 
working ... 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Niphlod
meaning. stop_time isn't there in the video, and shouldn't be there in 
your record. It means please don't process this task if stop_time passed

On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it isn't 
 working ... 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Is it possible to restrict a user to single login instance ?

2014-10-15 Thread Anthony
 

 *Theoretically* I am thinking following :

 in pre-login (if I can intercept login attempt) - put a code that checks 
 whether user that is trying to login - has already logged in (and not 
 logged out yet) If yes, do not allow the login (or somehow forcely 
 invalidate other session - and allow this login attempt to go thru)


 Maybe add a session_id field to db.auth_user, and when a user logs in (a) 
 check that field, and if it has a value, delete the session file associated 
 with the existing ID (if it exists) and (b) store the new session_id. Note, 
 this won't work with cookie based sessions -- in that case, you would 
 instead have to check the session_id value stored in db.auth_user on every 
 request in order to catch and invalidate the session cookie from the older 
 session (this adds a db lookup to every request -- might want to cache 
 these in RAM, though you may need to clean up periodically if there are a 
 large number of users).

 Also, note that this doesn't protect against session hijacking. It only 
 protects against multiple simultaneous logins (which would be using 
 different sessions rather than sharing a single hijacked session).


And keep in mind that this isn't really a security measure -- if an 
attacker has obtained the login credentials of a user, you are letting the 
attacker log in. For this to help with security, you would have to warn the 
original user about a login taking place from a new client.

Anthony

 


 Anthony


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Júlia Rizza
Actually, stop_time is a day after start_time. Anyway, nothing happens if I 
don't define a stop_time.

Em quarta-feira, 15 de outubro de 2014 09h52min13s UTC-3, Niphlod escreveu:

 meaning. stop_time isn't there in the video, and shouldn't be there in 
 your record. It means please don't process this task if stop_time passed

 On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it 
 isn't working ... 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] how to set a default represent for all fields

2014-10-15 Thread Richard Vézina
What do you mean... It would have be the same if web2py offer a solution...

:-P

Richard

On Tue, Oct 14, 2014 at 2:09 PM, drmb...@gmail.com wrote:

  I was expecting an elegant web2py solution but brute force works too.
 Thanks Richard.

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Semantic UI instead of bootstap

2014-10-15 Thread lyn2py
It's good for the widgets but not the grid.

It looks better by itself than to mix with others like zurb and bootstrap. 
It's a tad bigger, and different kind of style.
Out of the box, I personally did not find its styling as nice as zurb and 
bootstrap, and it requires to input quite a bit of code to produce. There 
was a widget that I couldn't get it to display properly, and there was no 
easy way to search for answers on stack overflow or google like the others 
(because it's much younger) 
I tried but gave up and went with another instead. That was when I needed 
to change my code and boy... it's an overhaul.

Others that may interest you: purecss, uikit, bootflat (bootstrap has a lot 
of flat ui's available, most of the nice ones are premium at codecanyon)

On Monday, October 13, 2014 10:19:34 PM UTC+8, Ramos wrote:

 is semantic UI a good frontend ?

 http://semantic-ui.com/

 Regards


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Niphlod
doh! you're right. I see though that the appname is ticket4service, while 
your parameter to start the scheduler is python web2py.py -K test ... 
should be python web2py.py -K ticket4service

On Wednesday, October 15, 2014 3:00:46 PM UTC+2, Júlia Rizza wrote:

 Actually, stop_time is a day after start_time. Anyway, nothing happens if 
 I don't define a stop_time.

 Em quarta-feira, 15 de outubro de 2014 09h52min13s UTC-3, Niphlod escreveu:

 meaning. stop_time isn't there in the video, and shouldn't be there 
 in your record. It means please don't process this task if stop_time 
 passed

 On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it 
 isn't working ... 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Júlia Rizza
yeah, I forgot to tell that I cloned the app into a new one, with other 
name, but I'm using the right name in the parameter anyway.

Em quarta-feira, 15 de outubro de 2014 12h19min53s UTC-3, Niphlod escreveu:

 doh! you're right. I see though that the appname is ticket4service, while 
 your parameter to start the scheduler is python web2py.py -K test ... 
 should be python web2py.py -K ticket4service

 On Wednesday, October 15, 2014 3:00:46 PM UTC+2, Júlia Rizza wrote:

 Actually, stop_time is a day after start_time. Anyway, nothing happens if 
 I don't define a stop_time.

 Em quarta-feira, 15 de outubro de 2014 09h52min13s UTC-3, Niphlod 
 escreveu:

 meaning. stop_time isn't there in the video, and shouldn't be there 
 in your record. It means please don't process this task if stop_time 
 passed

 On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it 
 isn't working ... 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] pg8000 driver that comes with web2py 2.8.2 is not supporting JSON field type?

2014-10-15 Thread Arnav Sharma
Hi Niphlod,

I am a newbie to unittests, Eden unittests, postgis, postgresql and its
drivers which is why I had come asking for help. Anyhow, I appreciate your
input.

Many thanks

On 15 October 2014 03:55, Niphlod niph...@gmail.com wrote:



 On Tuesday, October 14, 2014 11:50:45 PM UTC+2, ArnvShrma wrote:

 Hi Niphlod,

 I tried using psycopg2 but there are few reasons because of which I can
 not use it. I am currently deploying travis CI to run Sahana Eden unit
 tests. psycopg2 fails a few of the tests which it really should not. You
 can see the build here [1].

 [1] https://travis-ci.org/arnavsharma93/eden/jobs/37883503

 So, any temporary fix of running pg8000?


 web2py does not maintain pg8000 (although its developer is a contributor
 to web2py's code). Contact him about the issue on the json type.

 Also, it seems that most of the errors (web2py doesn't maintain Sahana
 Eden either, and I'm not a developer or Sahana Eden) comes from lat/long
 differences from fixed values (again, probably, related from a quick
 copy/paste unittest suite than a carefully built one)

 If only people could READ unittests instead of pointing out failing ones
 as actual failuresworld will have less headaches.
 E.g.:

 26.0729016786571 != 26.072901678657075

 let's confront them carefully...

 26.0729016786571
 26.072901678657075

 yep. psycopg2 returns the same value than pg8000, only with a lesser 
 precision, estimated in roughly...wait, let's do calcs.
 26.07291 to 26.07292  equals to 1 meter. Every digit you loose in precision, 
 adds up roughly to an order of magnitude...
 meaning 26.0729 to 26.0730 equals 10 meters.
 sahana's tests are complaining about a difference of  well, much more 
 LESS than the dimension a grain of salt (actually, a lot less).
 If sahana is not trying to tie gps coordinates to atoms, psycopg2 is not the 
 problem, sahana's tests are.

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/BfSIbUSPk38/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
*Arnav Sharma http://web.iiit.ac.in/~arnav.s/*
*IIITH*

If everything is under control, you are going too slow. - Some wise man
with big nerdy glasses.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: french web2py developper in paris

2014-10-15 Thread eric cuver
I am looking for developers who are paid for intervening to training 
sessions evening and training period for several beginners in code or for 
people who want to create prototypes for their startup. 
as to how people are ruby. there will be training in html, javascript and 
python and web2py. the idea is to do as the ruby community is because in 
France, for example, there was only 4 years ruby was nothing. and now they 
have a lot of job  in ruby​​. because they are on the schools code in paris 
 as bootcamps in usa. So we want to do the same with web2py. I am a state 
places to see if there are developers who live in paris to training 
sessions or bootcamps can come helps us to train people on web2py and 
python. but trainers will pay for the training will pay off.

Le mercredi 15 octobre 2014 00:17:06 UTC+2, Massimo Di Pierro a écrit :

 Looking for projects or for developers?

 On Tuesday, 14 October 2014 04:24:12 UTC-5, eric cuver wrote:

 I want to know is there for developers in web2py on paris for projects in 
 web2py in paris.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2py + Google Cloud Endpoints: There is a way to make them work together ?

2014-10-15 Thread Cláudio Bastos
Hi, 

i'm struggling to make Web2py and Google Cloud Endpoints work together.

When I change app.yaml to include :


- url: /_ah/spi/.*
  script: my_api.application

libraries:
- name: pycrypto
  version: 2.6

it tells me :


INFO 2014-10-14 23:42:24,845 module.py:659] default: POST 
 /_ah/spi/BackendService.getApiConfigs HTTP/1.1 500 -
 INFO 2014-10-14 23:42:24,846 module.py:659] default: GET 
 /_ah/api/discovery/v1/apis HTTP/1.1 500 60
 ERROR2014-10-15 02:42:24,927 wsgi.py:262] 
 Traceback (most recent call last):
   File C:\Program Files\Google\Cloud 
 SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py,
  
 line 239, in Handle
 handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
   File C:\Program Files\Google\Cloud 
 SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py,
  
 line 298, in _LoadHandler
 handler, path, err = LoadObject(self._handler)
   File C:\Program Files\Google\Cloud 
 SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py,
  
 line 84, in LoadObject
 obj = __import__(path[0])
   File C:\Devel\workspace\myproject\gaehandler.py, line 52, in module
 class MyApi(remote.service):
 AttributeError: 'module' object has no attribute 'service'


So it's like it couldn't import protorpc module.
I checked my appengine sdk and see that there is protorpc/remote.py with 
Service class in there.

Does anyone know any way to make it happen?

Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] return tail of a text log file

2014-10-15 Thread Vin
Hi all,

I need to stream a text log file via web2py. The file is generated by a 
python script that runs outside web2py, but is saved to the uploads 
folder.

This is what I have in a controller called 2.py:

def index():
 import os
 path=os.path.join(request.folder,'uploads','log.log')
 return response.stream(open(path,'rb'),chunk_size=4096)


When I navigate to *...app/2 *the contents of log.log are displayed on the 
browser, yes. But my problem is that I only need to see the tail of the 
file (it can get very large), like you would from the command line.

*tail -f log.log*

Any ideas?

Thanks!
Vin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Upload to static folder in other application

2014-10-15 Thread Annet
Hi Anthony,

Thanks for your reply. I tried your code and it works. I have a related 
question, I have a table grp_subgroup which apart from fields
groupID, imageFilename and image, also contains fields name and description 
in a function I have the following code to store the 
original file name:

record = db.grp_subgroup(groupID=groupID)
form = SQLFORM(db.grp_subgroup, record, deletable=True, showid=False, 
formstyle=bootstrap3, separator='',
   hidden=dict(nodeID=nodeID))
if request.vars.image != None:
form.vars.imageFilename = request.vars.image.filename

When the user inserts a subgroup this works, however, when the user updates 
the name and description and does not
re-upload an image I get the following error:

Is there a way to prevent this from happening?

Traceback (most recent call last):
  File /Users/iannet/web2py-deutschland/gluon/restricted.py, line 220, in 
restricted
exec ccode in environment
  File 
/Users/iannet/web2py-deutschland/applications/myleonexus/controllers/group.py 
http://127.0.0.1:8000/admin/default/edit/myleonexus/controllers/image.py, 
line 190, in module
  File /Users/iannet/web2py-deutschland/gluon/globals.py, line 385, in 
lambda
self._caller = lambda f: f()
  File /Users/iannet/web2py-deutschland/gluon/tools.py, line 3287, in f
return action(*a, **b)
  File 
/Users/iannet/web2py-deutschland/applications/myleonexus/controllers/group.py 
http://127.0.0.1:8000/admin/default/edit/myleonexus/controllers/image.py, 
line 63, in grp_subgroup
form.vars.imageFilename = request.vars.image.filename
AttributeError: 'str' object has no attribute 'filename'


Is there a way to prevent this from happening?

Furthermore, in case of an update form the form does not indicate that an 
image file has already been uploaded, the image
field is a browse button and the message 'no file selected'.

I read the book's part on an image blog and SQLFORM and uploads, in the 
examples the image field shows a file link and an
option to delete just the image not the record. I did not get this to work 
for I wasn't able to figure out how upload=URL('download')
works. In case of the img_logo table it has the following scr selector: 
scr=“/myleonexus/image/download/img_logo.image.beca…67.png”
where myleonexus is the application, image is the controller, but download 
is not a function in the image controller.

In case of you solution:

folder = 'nodeID' + str(nodeID)
db.img_logo.image.uploadfolder = 
os.path.join(request.env.applications_parent, 'applications', 'dbmodel', 
'static', 'uploads', folder)

Is it possible to use upload=URL('download') or not?


Best,

Annet

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: return tail of a text log file

2014-10-15 Thread Dave S


On Tuesday, October 14, 2014 3:23:15 PM UTC-7, Vin wrote:

 Hi all,

 I need to stream a text log file via web2py. The file is generated by a 
 python script that runs outside web2py, but is saved to the uploads 
 folder.

 This is what I have in a controller called 2.py:

 def index():
 import os
 path=os.path.join(request.folder,'uploads','log.log')
 return response.stream(open(path,'rb'),chunk_size=4096)


 When I navigate to *...app/2 *the contents of log.log are displayed on 
 the browser, yes. But my problem is that I only need to see the tail of 
 the file (it can get very large), like you would from the command line.

 *tail -f log.log*

 Any ideas?


Python's seek() has an option to specify relative to the end of file for 
a file open in read mode.
Old docs: http://docs.python.org/2.4/lib/bltin-file-objects.html
Current docs: http://docs.python.org/2/library/stdtypes.html#file-objects

There is also os.stat()
http://docs.python.org/2/library/os.html#files-and-directories
 
/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] GRID selectable inside component

2014-10-15 Thread LaDarrius Stewart
I have a grid inside a component inside a component which has selectable 
set to run a function that assigns the ids to a session variable. When 
inside the component it does not work when i click submit I can tell that 
the page is being reloaded but the callback does not run. I know that the 
code works because if I go to the .load page directly and try it works as 
expected. But from the component page it doesnt execute the callback.



selectable = [('Create Invoice', lambda ids: [selectabletest(ids)], 'btn 
btn-info btn-md')]
grid2 = SQLFORM.grid(query, selectable=selectable, args=request.args[:1], 
formname='invgrid', user_signature=False)

def selectabletest(ids):
session.lambdatest = ids

-- 
This message is for named person(s) only.  It may contain confidential 
and/or legally privileged information.  No confidentiality or privilege is 
waived or lost should mis-transmission occur.  If you receive this message 
in error, delete it (and all copies) and notify the sender.  You must not, 
directly or indirectly,use, disclose, distribute, print, or copy any part 
of this message if you are not the intended recipient. GAD GROUP 
TECHNOLOGY, INC. reserves the right to monitor all e-mail communications 
through its networks.

Any views expressed in this message are those of the individual sender, 
except where the message states otherwise and the sender is authorized to 
state them to be the views of any such entity.

This e-mail has been virus and content scanned by GAD GROUP TECHNOLOGY, INC.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to delete session file on logout

2014-10-15 Thread Mandar Vaze / मंदार वझे
On Wed, Oct 15, 2014 at 1:06 AM, Anthony abasta...@gmail.com wrote:

 On Tuesday, October 14, 2014 2:18:05 PM UTC-4, Mandar Vaze wrote:

 (This is related to security issue - I've explained the security issue in
 detail to Massimo and anthony separately)

 I want the session to be invalid as soon as after user logs out (as
 well as after certain period of inactivity)
 This is supposed to be default behaviour - but somehow doesn't work.


 In the current version of web2py, the default behavior is that upon
 logout, the session is cleared and renewed (i.e., a new session ID is
 issued). However, it does not delete the old session file.

When you say it somehow doesn't work, do you just mean the old session
 file remains, or is something else not working?


Yes. Session file does not get deleted.
The side effect of session file remaining on the disk is that if the
hijacked session ID is used by the attacker - then somehow contents of
the session file on the disk are reused (even if session contents from
memory (Storage object) are cleaned) Thus allowing the attacker access to
logged in page without actually having to login.

So now I'm explicitly deleting the session file.

BTW - which method gets invoked when session has expired ?
Is there a hook where I can add the code to delete the session file - in
addition to post_logout ?
This may be better than too frequent cron job with session2trash script.

-Mandar








 What I want is something like sessions2trash.py script - except that file
 should deleted right away - even if the session has *not* expired.

 Currently I'm using something like following. *Please suggest correct
 way to handle this* (I know this works only for file based sessions, but
 that is OK)

 def post_logout(user):
 try:
 import os
 os.unlink(response.session_filename) # Clear the session from
 disk
 except OSError:
 pass
 session.renew(clear_session=True)  # Clear the memory/Storage object.



 You shouldn't need that last line, as the logout function already does
 exactly that by default.

 Anthony

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/j-GwnDc0G6g/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Apostrophe causes new column in PYFPDF

2014-10-15 Thread Leonel Câmara
I have found the problem. It's not the HTML helpers that are escaping twise.

The problem is that gluon.contrib.generics.pyfpdf_from_html calls sanitize 
on the input.

 P(Row's).xml()
'pRow#x27;s/p'
 from gluon.sanitizer import sanitize
 sanitize('pRow#x27;s/p')
'pRowamp;#x27;s/p'
 sanitize('pRow#x27;s/p', escape=False)
'pRowamp;#x27;s/p'


This is where things are being escaped twice. So this seems like a bug in 
gluon.sanitizer.XssCleaner which shouldn't escape entities that are already 
escaped.

Even after this bug is corrected, we would still have to unescape the input 
at least in gluon.contrib.generics.pyfpdf_from_html before calling 
pdf.write_html since the HTMLParser in fpdf isn't doing it.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: return tail of a text log file

2014-10-15 Thread Dave S


On Wednesday, October 15, 2014 10:43:23 AM UTC-7, Dave S wrote:



 On Tuesday, October 14, 2014 3:23:15 PM UTC-7, Vin wrote:

 Hi all,

 I need to stream a text log file via web2py. The file is generated by a 
 python script that runs outside web2py, but is saved to the uploads 
 folder.

 This is what I have in a controller called 2.py:

 def index():
 import os
 path=os.path.join(request.folder,'uploads','log.log')
 return response.stream(open(path,'rb'),chunk_size=4096)


 When I navigate to *...app/2 *the contents of log.log are displayed on 
 the browser, yes. But my problem is that I only need to see the tail of 
 the file (it can get very large), like you would from the command line.

 *tail -f log.log*

 Any ideas?


 Python's seek() has an option to specify relative to the end of file for 
 a file open in read mode.
 Old docs: http://docs.python.org/2.4/lib/bltin-file-objects.html
 Current docs: http://docs.python.org/2/library/stdtypes.html#file-objects
 

 There is also os.stat()
 http://docs.python.org/2/library/os.html#files-and-directories
  


See also these posts in other forums:

http://code.activestate.com/recipes/157035-tail-f-in-python/
http://stackoverflow.com/questions/6591931/getting-file-size-in-python

and a broader answer:
http://blog.gocept.com/2013/07/15/reliable-file-updates-with-python/


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler isn't starting

2014-10-15 Thread Niphlod
With that record and the correct parameter, task needs to be executed. 
There's probably an issue on how you're starting it. If you are sure 
everything is in place, pack a minimal app to reproduce the behaviour.

On Wednesday, October 15, 2014 5:45:04 PM UTC+2, Júlia Rizza wrote:

 yeah, I forgot to tell that I cloned the app into a new one, with other 
 name, but I'm using the right name in the parameter anyway.

 Em quarta-feira, 15 de outubro de 2014 12h19min53s UTC-3, Niphlod escreveu:

 doh! you're right. I see though that the appname is ticket4service, while 
 your parameter to start the scheduler is python web2py.py -K test ... 
 should be python web2py.py -K ticket4service

 On Wednesday, October 15, 2014 3:00:46 PM UTC+2, Júlia Rizza wrote:

 Actually, stop_time is a day after start_time. Anyway, nothing happens 
 if I don't define a stop_time.

 Em quarta-feira, 15 de outubro de 2014 09h52min13s UTC-3, Niphlod 
 escreveu:

 meaning. stop_time isn't there in the video, and shouldn't be there 
 in your record. It means please don't process this task if stop_time 
 passed

 On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it 
 isn't working ... 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] postgres schemas rname issue

2014-10-15 Thread libertil
Hi,
I am dealing with postgreSQL database with a fair number of tables and I 
currently group 
logically similar tables under different schemas.Now when I create the 
model I following
the examples I was able to specify the schema using the rname.

However I have issues when linking records from tables in the same schema 
(different from public)


Model:

db.define_table('uploads',
Field('upload_id', type='integer'),
Field('md5_signature', type='text'),
Field('original_filename', type='text'),
Field('filename', type='upload'),
Field('upload_date', type='datetime'),
Field('parent_upload_fk','reference upload.upload_id'),
Field('upload_status_fk','reference upload_statuses.upload_status_id',
  represent=lambda id, row: db.upload_statuses(id).description if id else 
''),
   format='%(filename)s',
rname = 'manage.uploads',
primarykey=['upload_id'],
  migrate=False)

db.define_table('upload_statuses',
  Field('upload_status_id', type='integer'),
Field('description', type='text'),
format='%(description)s',
rname = 'manage.upload_statuses',
primarykey=['upload_status_id'],
migrate=False)

Controller

grid = SQLFORM.grid(query,
fields=[db.uploads.original_filename,
db.uploads.md5_signature,
db.uploads.upload_date,
db.uploads.upload_status_fk],
  headers={'uploads.original_filename' : 'Filename',
'uploads.md5_signature' : 'Md5',
  'uploads.upload_date' : 'Upload date',
  'uploads.upload_status_fk': 'State'},
maxtextlengths={'uploads.md5_signature' :32,
'uploads.original_filename' : 80},
showbuttontext = False,
   deletable=False,
editable=False,
details=False,
selectable=None,
create=False,
searchable = False,
user_signature=False)

  return dict(grid=grid)

Error
class 'psycopg2.ProgrammingError' ERROR: la relationship 
manage.upload_statuses does not exist

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to delete session file on logout

2014-10-15 Thread Anthony


 In the current version of web2py, the default behavior is that upon 
 logout, the session is cleared and renewed (i.e., a new session ID is 
 issued). However, it does not delete the old session file. 

 When you say it somehow doesn't work, do you just mean the old session 
 file remains, or is something else not working?


 Yes. Session file does not get deleted.
 The side effect of session file remaining on the disk is that if the 
 hijacked session ID is used by the attacker - then somehow contents of 
 the session file on the disk are reused (even if session contents from 
 memory (Storage object) are cleaned) Thus allowing the attacker access to 
 logged in page without actually having to login.


It may be worth having web2py delete the file (or database record in the 
case of database based sessions) automatically upon session.renew(). Maybe 
submit a Google Code issue about this.

BTW - which method gets invoked when session has expired ? 
 Is there a hook where I can add the code to delete the session file - in 
 addition to post_logout ?


First, although login can expire, sessions themselves do not expire (they 
simply terminate when the browser session ends by virtue of the fact that 
the browser will no longer transmit session cookies for old sessions).

In any case, there is no process that can monitor sessions/logins for 
expiration automatically (i.e., no place for a hook). The only events 
that the framework can respond to are requests, but an inactive client is 
not making any requests, so there would be nothing to trigger an expiration 
check. If you want to monitor logins for expiration and proactively delete 
session files or database records, you would have to run an external 
process (i.e., something like sessions2trash), perhaps using the scheduler 
or some other mechanism.

To prevent session hijacking, keep all logged in activity (including the 
login itself) over HTTPS. If you're still concerned, delete the session 
file upon logout (as you are now doing) and run sessions2trash 
periodically. Trying to delete the session file at the precise instant of 
login expiration will add little to overall security.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Item in ``from list'' not a string (custom_import.py) web2py 2.9.11

2014-10-15 Thread Luciano Laporta Podazza
Hi again,

So a friend of mine helped me solving the issue, on gluon/custom_import.py,
on line 82 we have to replace this line:

modules_prefix, globals, locals, [itemname], level)

With this one:

modules_prefix, globals, locals, [itemname*.encode('utf-8')*], level)

And that's all!.

Thanks for your support!

On Mon, Oct 13, 2014 at 4:36 PM, Luciano Laporta Podazza 
lucianopoda...@gmail.com wrote:

 Thanks Niphlod,

 I've just managed to make any python version work ( 2.7.5), web2py runs
 the Python version I want but the error still remains.

 It's weird 'cause on my Mac, with Python *2.7.5 (default, Mar  9 2014,
 22:15:05) *it works like a charm.

 I'll keep the research but this is driving me nuts.



 On Mon, Oct 13, 2014 at 4:28 PM, Niphlod niph...@gmail.com wrote:

 it's not a web2py issue but it seems something with the Shopify lib and
 that bug that isn't going very well as of web2py starts with something
 else you need to check your setup web2py can't choose what python
 version to run at runtime

 On Sunday, October 12, 2014 7:39:16 PM UTC+2, Luciano Laporta Podazza
 wrote:

 It seems to.

 I've tried using pyenv to switch to Python 2.7.5 (the one it works),
 declared it as global and verified that works running 'python', reinstalled
 web2py 2.9.11 on server but web2py it still uses Python *2.7.6*.

 On the other hand I've tried to apply the patch with no luck (actually
 I'm learning how to do it :P)

 Any suggestions?. Thanks!

 On Sun, Oct 12, 2014 at 10:07 AM, Niphlod nip...@gmail.com wrote:

 uhm, could be something related to

 http://bugs.python.org/issue21720




 On Sunday, October 12, 2014 1:53:40 AM UTC+2, Luciano Laporta Podazza
 wrote:

 Hello,

 I'm using locally web2py (*2.9.8*) + Shopify API (2.0.4) on Mac OS X
 10.9.5 (Python *2.7.5*) and this code works perfectly:

 from gluon.tools import Service
 service = Service()
 import gluon.contrib.simplejson as json


 def call():
 session.forget()
 return service()


 @service.json
 def create_order():
 data = json.loads(request.body.read())
 import shopify
 #(API Key, Password)
 shop_url = https://%s:%s...@myshop.myshopify.com/admin; % ('key',
 'secret')
 shopify.ShopifyResource.set_site(shop_url)
 shop  = shopify.Shop.current
 orders = shopify.Order.find(financial_status='pending')
 new_order = shopify.Order()


 for order in orders:
 if order.order_number == data['order_number']:
 clone_order(order, new_order, order.attributes)


 def clone_order(objfrom, objto, names):
 for n in names:
 if hasattr(objfrom, n):
 if n in [source_name, cart_token, id, token,
 name, checkout_token, checkout_id]:
 objto.n = None
 elif n == line_items:
 v = getattr(objfrom, n)
 setattr(objto, n, v)
 if objto.line_items[-1].title != Cargo por COD:
 objto.line_items.append({variant_id : 972802884,
 quantity : 1, price: 2.5, title: Cargo por COD})
 elif n == order_number:
 v = getattr(objfrom, n)
 objto.note = Agregado COD, numero de orden vieja: #
 + str(objfrom.order_number)
 else:
 v = getattr(objfrom, n)
 setattr(objto, n, v)
 objto.order_number = 1198
 try:
 objto.save()
 objfrom.cancel()
 objfrom.close()
 return Success
 except Exception, e:
 return Fail

 But when deploying to server (Ubuntu 14.04 with Web2py *2.9.11* /
 Python *2.7.6 -note the different python and web2py version-*) I get
 this error:

 Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 224, in restricted
  exec ccode in environment
  File 
 /home/www-data/web2py/applications/mascotanube/controllers/cash_on_delivery.py
  
 https://activecrime.com/admin/default/edit/mascotanube/controllers/cash_on_delivery.py,
  line 49, in module
  File /home/www-data/web2py/gluon/globals.py, line 392, in lambda
  self._caller = lambda f: f()
  File 
 /home/www-data/web2py/applications/mascotanube/controllers/cash_on_delivery.py
  
 https://activecrime.com/admin/default/edit/mascotanube/controllers/cash_on_delivery.py,
  line 7, in call
  return service()
  File /home/www-data/web2py/gluon/tools.py, line 5138, in __call__
  return self.serve_json(request.args[1:])
  File /home/www-data/web2py/gluon/tools.py, line 4815, in serve_json
  s = universal_caller(self.json_procedures[args[0]], *args[1:], **d)
  File /home/www-data/web2py/gluon/tools.py, line 4474, in 
 universal_caller
  return f(**arg_dict)
  File 
 /home/www-data/web2py/applications/mascotanube/controllers/cash_on_delivery.py
  
 https://activecrime.com/admin/default/edit/mascotanube/controllers/cash_on_delivery.py,
  line 17, in create_order
  orders = shopify.Order.find(financial_status='pending')
  File 
 

[web2py] Re: scheduler isn't starting

2014-10-15 Thread Júlia Rizza
Ok, I reproduced all the steps in a new app and everything went ok. But I 
still can't see why it is not working in an specific app, since it does not 
return any error or relevant debug info. What could be the reason for it to 
assign no tasks while I have at least 3 tasks on db?

Em quarta-feira, 15 de outubro de 2014 16h46min41s UTC-3, Niphlod escreveu:

 With that record and the correct parameter, task needs to be executed. 
 There's probably an issue on how you're starting it. If you are sure 
 everything is in place, pack a minimal app to reproduce the behaviour.

 On Wednesday, October 15, 2014 5:45:04 PM UTC+2, Júlia Rizza wrote:

 yeah, I forgot to tell that I cloned the app into a new one, with other 
 name, but I'm using the right name in the parameter anyway.

 Em quarta-feira, 15 de outubro de 2014 12h19min53s UTC-3, Niphlod 
 escreveu:

 doh! you're right. I see though that the appname is ticket4service, 
 while your parameter to start the scheduler is python web2py.py -K test 
 ... should be python web2py.py -K ticket4service

 On Wednesday, October 15, 2014 3:00:46 PM UTC+2, Júlia Rizza wrote:

 Actually, stop_time is a day after start_time. Anyway, nothing happens 
 if I don't define a stop_time.

 Em quarta-feira, 15 de outubro de 2014 09h52min13s UTC-3, Niphlod 
 escreveu:

 meaning. stop_time isn't there in the video, and shouldn't be 
 there in your record. It means please don't process this task if 
 stop_time 
 passed

 On Wednesday, October 15, 2014 2:49:43 PM UTC+2, Niphlod wrote:

 you have stop_time equal to start_time. that's the reason why it 
 isn't working ... 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] nested for loop and pass in view

2014-10-15 Thread LoveWeb2py
Hello I'm trying to create a menu for users who have already answered a 
question correctly. The questions are stored in the database, but for some 
reason my double for loop displays 10 of the same question. When I try my 
logic using python web2py.py -S myapp -M the logic works fine, however when 
I transfer it to the view it shows something like this:

Menu item 1
Menu item 1
Menu item 1
Menu item 1
Menu item 1
Menu item 1
Menu item 2
Menu item 2
Menu item 2
Menu item 2
Menu item 2

and so on and so on... I'm guessing it has something to do with my for 
loop, but I've been stuck on this for hours. Any help would be greatly 
appreciated. Thanks!


code here:

 ul{{try:}}

 {{for question in all_questions:}}

 {{for record in correct_questions:}}

 {{if question['difficulty']=='subject1' and 
 correct_questions[record]['question'] != question['id']:}}

 li class=paddeda href={{=URL('challenges', 
 vars={'chal':question['id']})}}{{=question['title']}} 
 ({{=question['points']}} pts) /a/li

 {{pass}}

 {{pass}}

 {{else:}}

 

 li class=paddedi class=fa fa-check icon-small/i 
 a href={{=URL('challenges', vars={'chal':question['id']})}}, 
 style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
 /a/li

 {{pass}}

 {{except:}}

 {{pass}}

  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] What are .table files in sqlite databases?

2014-10-15 Thread Yi Liu
Dear all,

I am trying to backup my sqlite databases using its backup API:
sqlite3 storage.db .backup db.bak

I noticed it made a copy of storage.db. But how about all those .tables 
files. I search about sqlite and web2py, seems nothing came up about them. 

Using ls -l, I can tell most these .table files have not been modified for 
a long time. So no data is in them.

Should I back up them or not?

Thanks!

-- Yi

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What are .table files in sqlite databases?

2014-10-15 Thread Leonel Câmara
Table files have nothing to do with sqlite. They are files generated by 
web2py with the table structure, to detect changes and perform migrations. 
You don't necessarily need to keep them in your backups, you can do a fake 
migration to generate them again.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What are .table files in sqlite databases?

2014-10-15 Thread Yi Liu
Thank you very much for your quick and complete answer, Leonel!

-- Yi

On Wednesday, October 15, 2014 4:13:33 PM UTC-7, Leonel Câmara wrote:

 Table files have nothing to do with sqlite. They are files generated by 
 web2py with the table structure, to detect changes and perform migrations. 
 You don't necessarily need to keep them in your backups, you can do a fake 
 migration to generate them again.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: nested for loop and pass in view

2014-10-15 Thread Anthony
The a element in the inner loop only references the question variable, 
which is set in the outer loop. Perhaps instead of question, you menat to 
put correct_questions[record].

Anthony

On Wednesday, October 15, 2014 7:03:39 PM UTC-4, LoveWeb2py wrote:

 Hello I'm trying to create a menu for users who have already answered 
 a question correctly. The questions are stored in the database, but for 
 some reason my double for loop displays 10 of the same question. When I try 
 my logic using python web2py.py -S myapp -M the logic works fine, however 
 when I transfer it to the view it shows something like this:

 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 2
 Menu item 2
 Menu item 2
 Menu item 2
 Menu item 2

 and so on and so on... I'm guessing it has something to do with my for 
 loop, but I've been stuck on this for hours. Any help would be greatly 
 appreciated. Thanks!


 code here:

 ul{{try:}}

 {{for question in all_questions:}}

 {{for record in correct_questions:}}

 {{if question['difficulty']=='subject1' and 
 correct_questions[record]['question'] != question['id']:}}

 li class=paddeda href={{=URL('challenges', 
 vars={'chal':question['id']})}}{{=question['title']}} 
 ({{=question['points']}} pts) /a/li

 {{pass}}

 {{pass}}

 {{else:}}

 

 li class=paddedi class=fa fa-check icon-small/i 
 a href={{=URL('challenges', vars={'chal':question['id']})}}, 
 style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
 /a/li

 {{pass}}

 {{except:}}

 {{pass}}

  



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: nested for loop and pass in view

2014-10-15 Thread LoveWeb2py
Hi Anthony,

I think that part is correct. Here is the return from my request:

correct_questions:
26:
answered_by:
1L
correct:
True
id:
26L
last_update:
datetime.datetime(2014, 10, 13, 19, 49, 6)
question:
5L
submitted:
Yes
35:
answered_by:
1L
correct:
True
id:
35L
last_update:
datetime.datetime(2014, 10, 13, 23, 6, 51)
question:
3L
submitted:
Yes
55:
answered_by:
1L
correct:
True
id:
55L
last_update:
datetime.datetime(2014, 10, 14, 17, 45, 4)
question:
7L
submitted:
William
58:
answered_by:
1L
correct:
True
id:
58L
last_update:
datetime.datetime(2014, 10, 14, 18, 20, 4)
question:
8L
submitted:
8
68:
answered_by:
1L
correct:
True
id:
68L
last_update:
datetime.datetime(2014, 10, 14, 22, 41, 33)
question:
10L
submitted:
262144
70:
answered_by:
1L
correct:
True
id:
70L
last_update:
datetime.datetime(2014, 10, 14, 22, 49, 52)
question:
1L
submitted:
Hello World
79:
answered_by:
1L
correct:
True
id:
79L
last_update:
datetime.datetime(2014, 10, 14, 22, 53, 36)
question:
11L
submitted:
Autumn
81:
answered_by:
1L
correct:
True
id:
81L
last_update:
datetime.datetime(2014, 10, 15, 4, 27, 28)
question:
9L
submitted:
4
85:
answered_by:
1L
correct:
True
id:
85L
last_update:
datetime.datetime(2014, 10, 15, 23, 6, 48)
question:
2L
submitted:
learning
Had to run the first for loop to get into the keys and then compared 
values. 

I've modified the code to do check if the question was answered correctly 
in the controller and append the question id to a list. Still not 
working... here is my controller:


def questions_for_people():
correctList = []
correct_questions = db((db.questions_answered.correct==on)  
(db.questions_answered.answered_by==auth.user.id)).select(db.questions_answered.ALL,
 
groupby=db.questions_answered.question, distinct=True).as_dict()
for row in correct_questions:
for item in all_questions:
if correct_questions[row]['question'] == item['id']:
correctList.append(int(item['id']))
return dict(correctList=correctList)

and in my view:
ul
{{for question in all_questions:}}
{{if question['diff_level']==100 and question['id'] not 
in correctList:}}

li class=paddeda href={{=URL('challenges', 
vars={'chal':question['id']})}}{{=question['title']}} 
({{=question['points']}} pts) /a/li
{{pass}}
{{else:}}
{{if question['diff_level']==100 and question['id'] in 
correctList:}}
li class=paddedi class=fa fa-check icon-small/i 
a href={{=URL('challenges', vars={'chal':question['id']})}}, 
style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
/a/li
{{pass}}
{{pass}}

when I run this nothing returns back to my menu... 

On Wednesday, October 15, 2014 7:44:46 PM UTC-4, Anthony wrote:

 The a element in the inner loop only references the question variable, 
 which is set in the outer loop. Perhaps instead of question, you meant to 
 put correct_questions[record]

 Anthony

 On Wednesday, October 15, 2014 7:03:39 PM UTC-4, LoveWeb2py wrote:

 Hello I'm trying to create a menu for users who have already answered 
 a question correctly. The questions are stored in the database, but for 
 some reason my double for loop displays 10 of the same question. When I try 
 my logic using python web2py.py -S myapp -M the logic works fine, however 
 when I transfer it to the view it shows something like this:

 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 1
 Menu item 2
 Menu item 2
 Menu item 2
 Menu item 2
 Menu item 2

 and so on and so on... I'm guessing it has something to do with my for 
 loop, but I've been stuck on this for hours. Any help would be greatly 
 appreciated. Thanks!


 code here:

 ul{{try:}}

 {{for question in all_questions:}}

 {{for record in correct_questions:}}

 {{if question['difficulty']=='subject1' and 
 correct_questions[record]['question'] != question['id']:}}

 li class=paddeda href={{=URL('challenges', 
 vars={'chal':question['id']})}}{{=question['title']}} 
 ({{=question['points']}} pts) /a/li

 {{pass}}

 {{pass}}

 {{else:}}

 

 li class=paddedi class=fa fa-check 
 icon-small/i a href={{=URL('challenges', 
 vars={'chal':question['id']})}}, 
 style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
 /a/li

 {{pass}}

 {{except:}}

 {{pass}}

  



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop 

[web2py] Re: postgres schemas rname issue

2014-10-15 Thread libertil
My bad!!

I just realized I had a stupid typo in my model.

It works fine now.

Sorry 




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: nested for loop and pass in view

2014-10-15 Thread Anthony
On Wednesday, October 15, 2014 8:05:57 PM UTC-4, LoveWeb2py wrote:

 Hi Anthony,

 I think that part is correct.


In your original code, the inner loop looped over correct_questions, but in 
the menu items, you did not reference the correct_questions item and 
instead referenced the question item from the outer loop -- that is why you 
saw the same menu item repeated multiple times.
 

 I've modified the code to do check if the question was answered correctly 
 in the controller and append the question id to a list. Still not 
 working... here is my controller:


 def questions_for_people():
 correctList = []
 correct_questions = db((db.questions_answered.correct==on)  
 (db.questions_answered.answered_by==auth.user.id)).select(db.questions_answered.ALL,
  
 groupby=db.questions_answered.question, distinct=True).as_dict()


Why use .as_dict()? If you leave it as a Rows object, you can refer to 
row.question instead of having to do correct_questions[row]['question'].

Also, what is all_questions? Do they come from another db table, and if so, 
is it linked to db.questions_answered? Perhaps you could just do a single 
db query (via a join) to get the data you need.

ul
 {{for question in all_questions:}}
 {{if question['diff_level']==100 and question['id'] 
 not in correctList:}}
 
 li class=paddeda href={{=URL('challenges', 
 vars={'chal':question['id']})}}{{=question['title']}} 
 ({{=question['points']}} pts) /a/li
 {{pass}}
 {{else:}}
 {{if question['diff_level']==100 and question['id'] in 
 correctList:}}
 li class=paddedi class=fa fa-check icon-small/i 
 a href={{=URL('challenges', vars={'chal':question['id']})}}, 
 style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
 /a/li
 {{pass}}
 {{pass}}

 when I run this nothing returns back to my menu... 


If nothing returns, then presumable question['diff_level'] never equals 
100, as both if statements include that condition. Also, rather than 
nesting the second if inside an else, you can simply use an elif.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: nested for loop and pass in view

2014-10-15 Thread LoveWeb2py
Took in your suggestions, Anthony and my code worked. Thank you so much for 
dedicating so much time towards helping others. I think I speak for 
everyone when I say you're very much appreciated!!

On Wednesday, October 15, 2014 9:44:32 PM UTC-4, Anthony wrote:

 On Wednesday, October 15, 2014 8:05:57 PM UTC-4, LoveWeb2py wrote:

 Hi Anthony,

 I think that part is correct.


 In your original code, the inner loop looped over correct_questions, but 
 in the menu items, you did not reference the correct_questions item and 
 instead referenced the question item from the outer loop -- that is why you 
 saw the same menu item repeated multiple times.
  

 I've modified the code to do check if the question was answered correctly 
 in the controller and append the question id to a list. Still not 
 working... here is my controller:


 def questions_for_people():
 correctList = []
 correct_questions = db((db.questions_answered.correct==on)  
 (db.questions_answered.answered_by==auth.user.id)).select(db.questions_answered.ALL,
  
 groupby=db.questions_answered.question, distinct=True).as_dict()


 Why use .as_dict()? If you leave it as a Rows object, you can refer to 
 row.question instead of having to do correct_questions[row]['question'].

 Also, what is all_questions? Do they come from another db table, and if 
 so, is it linked to db.questions_answered? Perhaps you could just do a 
 single db query (via a join) to get the data you need.

 ul
 {{for question in all_questions:}}
 {{if question['diff_level']==100 and question['id'] 
 not in correctList:}}
 
 li class=paddeda href={{=URL('challenges', 
 vars={'chal':question['id']})}}{{=question['title']}} 
 ({{=question['points']}} pts) /a/li
 {{pass}}
 {{else:}}
 {{if question['diff_level']==100 and question['id'] in 
 correctList:}}
 li class=paddedi class=fa fa-check icon-small/i 
 a href={{=URL('challenges', vars={'chal':question['id']})}}, 
 style=color:gray;{{=question['title']}} ({{=question['points']}} pts) 
 /a/li
 {{pass}}
 {{pass}}

 when I run this nothing returns back to my menu... 


 If nothing returns, then presumable question['diff_level'] never equals 
 100, as both if statements include that condition. Also, rather than 
 nesting the second if inside an else, you can simply use an elif.

 Anthony


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Refresh DIV onclick

2014-10-15 Thread LoveWeb2py
I tried to search through most of the forums before submitting my question 
but I couldn't seem to find what I was looking for.

When a user submits their answer I would like to do two things:

if it is accepted and its corrected I would like to refresh the page, but 
if its not correct I would just like to refresh the div that has their 
submitted answers.

my controller is:

def submit_answer():
answer=FORM('Answer: ',
  INPUT(_name='answer', requires=IS_NOT_EMPTY()),
  INPUT(_type='submit', _class='btn btn-primary', 
_id=sub_button))
if answer.accepts(request,session):
#session.tabTracker = request.vars['chal']
answer_comp = 
db(db.answers.id==int(request.vars['chal'])).select(db.right_answers.ALL).first()
if answer.vars['answer'] == answer_comp['answer']:
response.flash = 'Correct! Nice job!'
else:
response.flash = 'Incorrect answer'
elif answer.errors:
response.flash = 'Please submit your answer'
else:
response.flash = ''
return dict(answer=answer)

and my view:
{{=LOAD('board','submit_answer.load', 
vars={'chal':question['id']},ajax=True)}}

The name of the div I would like to refresh is: div class=panel-heading

I've tried the response.js solution Anthony posted in another forum, but it 
didn't seem to work.

I know web2py has a onclick= feature and I'm thinking thats the way to go, 
but not sure how to structure it

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Refresh DIV onclick

2014-10-15 Thread LoveWeb2py
UPDATE: This works well for me after the form submits: redirect( 
request.env.http_web2py_component_location,client_side=True)

That came straight from the book, but its when the student gets a question 
wrong is where I'm running into trouble. I'd like to just refresh the div 
so they could continue to enter answers.

On Wednesday, October 15, 2014 11:45:39 PM UTC-4, LoveWeb2py wrote:

 I tried to search through most of the forums before submitting my question 
 but I couldn't seem to find what I was looking for.

 When a user submits their answer I would like to do two things:

 if it is accepted and its corrected I would like to refresh the page, but 
 if its not correct I would just like to refresh the div that has their 
 submitted answers.

 my controller is:

 def submit_answer():
 answer=FORM('Answer: ',
   INPUT(_name='answer', requires=IS_NOT_EMPTY()),
   INPUT(_type='submit', _class='btn btn-primary', 
 _id=sub_button))
 if answer.accepts(request,session):
 #session.tabTracker = request.vars['chal']
 answer_comp = db(db.answers.id
 ==int(request.vars['chal'])).select(db.right_answers.ALL).first()
 if answer.vars['answer'] == answer_comp['answer']:
 response.flash = 'Correct! Nice job!'
 else:
 response.flash = 'Incorrect answer'
 elif answer.errors:
 response.flash = 'Please submit your answer'
 else:
 response.flash = ''
 return dict(answer=answer)

 and my view:
 {{=LOAD('board','submit_answer.load', 
 vars={'chal':question['id']},ajax=True)}}

 The name of the div I would like to refresh is: div class=panel-heading

 I've tried the response.js solution Anthony posted in another forum, but 
 it didn't seem to work.

 I know web2py has a onclick= feature and I'm thinking thats the way to go, 
 but not sure how to structure it


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.