[web2py] Re: Groupby year on date field

2015-02-03 Thread Moiz Nagpurwala
Hello,

Sorry to bug you all, but I am still stuck with this year groupby issue.

I am fairly new to Python and web2py.

Any suggestions or alternative method to achieve the result is highly 
appreciated.

Thank you all.

-- 
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: How can I change a form so that the Enter key is disabled for Submit

2015-02-03 Thread Tom Stratton
Thanks -

I found several methods on SO that involved manipulation of the OUTPUT from 
web2py that gets rendered in the browser. Implemented a solution that was 
very specific to the forms that I want to have filled in.

I had hoped for a web2py specific way to manage the submit button behavior 
because of this observed behavior:

   - In web2py, for list fields, enter adds a new value to the list
   - in web2py, for text fields, enter creates a line break in the 
   input.

These are great behaviors but they put the users into the habit of pressing 
enter and the fields that I was validating are not amenable to an a-priori 
decision about whether the form is completely filled in or not as blank 
fields are acceptable and common.

Ultimately, I disabled the enter key on a field-by-field basis using jquery 
and left the behavior as-is for any field with list in the name.

Thanks for the suggestions!

Tom

On Friday, January 30, 2015 at 1:34:52 PM UTC-8, Niphlod wrote:

 there are a lot if you want to do down that path.


 http://stackoverflow.com/questions/895171/prevent-users-from-submitting-form-by-hitting-enter

 IMHO disabling enter is not a solution (I'm a keyboard guy and I love to 
 send forms with enter): at the very minimum you should do a proper 
 validation (server-side with web2py is easy). The most elegant way is to 
 disable the submit button via javascript until all required fields are 
 filled. 


-- 
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] https only on admin

2015-02-03 Thread Juozas Masiulis
For certain reasons I could not use https for my entire website. I load 
content from external domains through javascript, which I do not controll, 
and those scripts get blocked by the browser. I would like to use https 
only on admin, and I can get apache to redirect only admin to https  by 
using this http://pastebin.com/raw.php?i=Hkz9YqnH config 

The redirection seems to work correctly, but then I can't acces admin 
interface, because I am getting an exception , which I could read only by 
changing this back to default config. 

Traceback (most recent call last):
File /var/www/web2py/gluon/main.py, line 435, in wsgibase
session.connect(request, response)
File /var/www/web2py/gluon/globals.py, line 931, in connect
session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
TypeError: 'NoneType' object is not callable


926.
927.
928.
929.
930.
931.

932.
933.
934.
935.

response.cookies[response.session_id_name]['path'] = '/'
if cookie_expires:
response.cookies[response.session_id_name]['expires'] = \
cookie_expires.strftime(FMT)

session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)

response.session_hash = hashlib.md5(session_pickled).hexdigest()

if self.flash:
(response.flash, self.flash) = (self.flash, None)

Function argument list

(self=Storage {}, request=Storage {'_vars': None, 'function': 'index', 
'c...'folder': '/var/www/web2py/applications/admin/'}, response=Storage 
{'body': cStringIO.StringO object at 0..._caller': function lambda at 
0x7f0dbcfb3050}, db=None, tablename='web2py_session', masterapp='admin', 
migrate=True, separate=None, check_client=False, cookie_key=None, 
cookie_expires=None, compression_level=None)

-- 
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: Handling (2006, 'MySQL server has gone away') from Scheduler, pythonanywhere

2015-02-03 Thread Ian Ryder
No, there's nothing in there for now - just wanted to catch the right 
place. 

Is there a straight-forward way to reconnect?

As mentioned, it's dropping out with no activity other than the scheduler 
heartbeat running and once it drops out, it stays dropped out so the whole 
app is effectively unworkable at the moment.

Thanks in advance
Ian

On Tuesday, February 3, 2015 at 6:27:04 AM UTC+11, Massimo Di Pierro wrote:

 Did you put any dal query in a try... except? I am recently seeing people 
 do this a lot and it very wrong.

 On Monday, 2 February 2015 05:09:47 UTC-6, Ian Ryder wrote:

 Hi, I've got a showstopper running scheduler on pythonanywhere - every 
 few hours it drops out with:

 Traceback (most recent call last): File /web2py/gluon/shell.py, 
 line 272, in run exec(python_code, _env) File string, line 1, in 
 module File /web2py/gluon/scheduler.py, 
 line 719, in loop self.wrapped_report_task(task, self.async(task)) File 
 /web2py/gluon/scheduler.py, 
 line 868, in wrapped_report_task db.rollback() File 
 /web2py/gluon/dal.py, 
 line 8555, in rollback self._adapter.rollback() File 
 /web2py/gluon/dal.py, 
 line 1922, in rollback return self.connection.rollback()
 OperationalError: (2006, 'MySQL server has gone away')

 I can trap the error scheduler.py but I'm not sure how to reinitiate the 
 connection - this error only seems to come from this process and it will 
 happen even if it's not being used. Everything else seems to work fine.

 Any help on how to handle and reconnect gracefully appreciated.

 Thanks
 Ian



-- 
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] Debian 7 with Lighttpd + web2py setup

2015-02-03 Thread Jon M.
Peaceful greetings Google Group Members and Mr. Di Pierro.

First of all, thanks to all of you, web2py dev team, group members,for 
giving us the power of deploying with such a complete python web framework. 
I can imagine the heavy load of work behind from its beginning, to present 
day.

The thing is, I'm struggling with the setup of lighty with web2py.

  - I want to work only with Lighttpd as if I were working with Rocket, 
therefore, I want to disable Rocket at web2py startup.
  - The /etc/lighttpd/lighttpd.conf setup, as in many blogs, as in official 
web2py manual at the lighttpd recipe, does not work for me.
  - When starting web2py at the desired port 80 or 8000, Rocket claims that 
port, so, it doesn't start.
 
Some doubts with suggestion of being clear:

  Nowhere says if code needs to be replaced, added or overwritten. Kinda 
mixed code from many places regarding lighty with web2py.

  Some URLs are not clear, from a glimpse someone can see URL for Windows 
paths, others for UNIX.

  Some authors use /var/www/web2py, while others use 
/home/www-data/web2py. Which one is the one and why?

  Is that configuration even possible? I've been working-learning web2py 
for almost half-year and I just can't get there.

Here's what I have in /etc/lighttpd/lighttpd.conf:

server.modules = (
mod_access,
mod_alias,
mod_compress,
mod_redirect,
mod_rewrite,
mod_fastcgi,
mod_accesslog,
mod_status,
)
 
server.port = 8000
server.bind = 127.0.0.1
server.event-handler= poll   
server.dir-listing  = disable
server.upload-dirs  = (/var/cache/lighttpd/uploads)
server.pid-file = /var/run/lighttpd.pid
server.username = www-data
server.groupname= www-data  
server.error-handler-404= /test.fcgi
server.document-root= /home/www-data/web2py
server.errorlog = /tmp/error.log

fastcgi.server  = (.fcgi =
(fcgihandler =
(min-procs = 1,
 socket= 
/tmp/fcgi.sock
)
)
  )

index-file.names= ( index.php, index.html, 
index.lighttpd.html )
url.access-deny = ( ~, .inc )
static-file.exclude-extensions = ( .php, .pl, .fcgi )

compress.cache-dir  = /var/cache/lighttpd/compress/
compress.filetype   = ( application/javascript, text/css, 
text/html, text/plain )

# default listening port for IPv6 falls back to the IPv4 port
include_shell /usr/share/lighttpd/use-ipv6.pl  + server.port
include_shell /usr/share/lighttpd/create-mime.assign.pl
include_shell /usr/share/lighttpd/include-conf-enabled.pl

#w2p

$HTTP[host] =~ (^|\.)example\.com$ {
  server.document-root = /home/www-data/web2py
url.rewrite-once = (
  ^(/.+?/static/.+)$ = /applications$1,
  ^(/static/.+)$ = /applications/app$1,
  ^/$ = /fcgihandler.fcgi/app/default/index,
  (^/app.*)$ = /fcgihandler.fcgi$1,
  (^/admin.*)$ = /fcgihandler.fcgi$1,
  (^/examples.*)$ = /fcgihandler.fcgi$1,
  (^/welcome.*)$ = /fcgihandler.fcgi$1,
  (^|/.*)$ = /fcgihandler.fcgi/app/default/$1,
)
}

The fcgihandler.fcgi is the default from the handlers folder under web2py.

 -- I copied the handler under 
/home/www-data/web2py/handlers/fcgihandler.py to /home/www-data/web2py/, 
and changed the *.py extension to *.fcgi.
 -- I changed the name of handler as suggested here: 
http://web2py.googlegroups.com/attach/e96c0ab84d8e474e/tutorial.htm?view=1part=2
 -- I've already stopped whatever wanted to make use of the port 80. 
Apache2 mostly.
 -- I run the sudo -u www-data python fcgihandler.fcgi, as stated in the 
link above. Prior to run web2py, and prior to restarting lighttpd with the 
custom configuration. No success.

I appreciate your time taken to read this, and your help. 

Have a nice day/night everyone! :D

P.D.: Spanish spoken too. Just in case. [:

-- 
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: Submit current form prior to logout?

2015-02-03 Thread lillian

I'm already handling my own validation so I can sanitize and do the right 
thing as needed.  I'm mostly concerned about preserving user changes in 
cases where they might reasonably expect them to be persisted.

Along those lines, since there is no login expired event (as I understand 
it) there is no way to perform an auto-logout and subsequent auto-submit 
like we've been discussing? 

On Monday, February 2, 2015 at 1:24:17 PM UTC-8, Niphlod wrote:

 that works only if your controller accepts basically any data (very low 
 barrier on validation). My usecase scenario didn't ever involve the user 
 not knowing it's submitting data, and I'd treat half-filled forms with a 
 dedicated controller to clean/purge/mark_as_unreliable data what's coming 
 in...but that's me with my usual scenario.
 The underlying concept in developing is that every app has its own 
 goals... in principle, if you can live with whatever data the user had the 
 time to fill, there's nothing wrong with your approach.

 On Sunday, February 1, 2015 at 4:27:12 AM UTC+1, lillian wrote:


 Yeah that's basically what I came up with between posting and seeing your 
 reply, except I'm letting the code in my controller do the actual db update 
 (its that same code used if the user had clicked on submit) and then I 
 redirect based on what UI element called submit (submit button? do the 
 normal thing.  Logout button? logout. etc.)

 Does that make sense?  It works but I'm wondering if there might be 
 issues I'm not aware of.  Kinda new to this type of programming :-/

 On Friday, January 30, 2015 at 1:31:08 PM UTC-8, Niphlod wrote:

 the gist of it should be something like

 $(function() {
 $('a#thelogoutbutton').on('click', function(e) {
 e.preventDefault();
 if (code_to_submit_the_form() == 'everythingwentwell') {
 window.href = this.href;
 } else {
 managefailure();
 //optionally window.href = this.href
 } 
 })
 })

 as a general rule, it's not a polite thing to do to block on something 
 if the user presses i want to go out of here, so be sure to do it as 
 switfly as possible (i.e. don't require a strict check on 
 code_to_submit_the_form() and make it happen in under a half second).



-- 
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: uwsgi: strange messages

2015-02-03 Thread Martin Weissenboeck
You are right, there is a lot of entries about from operator... and I
have tried some proposlas, but without success. Therefore I postet my
question here.

Anyway, your hints was helpful - thank you: it seems that there are
diffenent libraries python2.7: I wanted to use Python 2.7.9, but uwsgi
expected Python 2.7.6

Maybe it is possible to use Python 2.7.9 together with web2py and 2.7.6 for
the rest of the Ubuntu server, but I had not enough time to try it.

2015-02-03 9:18 GMT+01:00 Niphlod niph...@gmail.com:

 the  from operator import _compare_digest as compare_digest is
 documented on the interwebs just google it... standard issues are
 playing with different versions of python in the same server.
 the how do I run it not from root well. Don't start uwsgi while
 logged in as root ! You stated this is the result of installing nginx+uwsgi
 using the script on a test server  if the script is this
 https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
  it
 has the correct permissions to AVOID running as root if the script is
 another one. it's wrong.




-- 
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 mimic routes.py with nginx

2015-02-03 Thread al ex
I have commented the following 4 directives in my server declaration, that
now looks like as below, and it seems to work better.

open_file_cache  max=1000 inactive=20s;
open_file_cache_valid30s;
open_file_cache_min_uses 2;
open_file_cache_errors   on;

-
in /etc/nginx/sites-available/mydomain


server {
  listen [::]:443 ssl spdy;
  listen 443 ssl spdy;
  server_name mydomain;

  charset utf-8;

# these includes are taken from https://github.com/h5bp/server-configs-nginx
include /etc/nginx/h5bp/directive-only/ssl.conf;
include /etc/nginx/h5bp/directive-only/spdy.conf;
include /etc/nginx/h5bp/directive-only/ssl-stapling.conf;
include /etc/nginx/h5bp/directive-only/x-ua-compatible.conf;
include /etc/nginx/h5bp/directive-only/extra-security.conf;
include /etc/nginx/h5bp/location/protect-system-files.conf;

# these 4 are now commented, it seems now to work better
# open_file_cache  max=1000 inactive=20s;
# open_file_cache_valid30s;
# open_file_cache_min_uses 2;
# open_file_cache_errors   on;


  location /nginx_status {
stub_status on;
access_log   off;
deny all;
  }

location / {
uwsgi_pass  unix:///tmp/web2py.sock;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWAREnginx/$nginx_version;
 include /etc/nginx/conf.d/web2py/gzip.conf;
}

  location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
  alias /home/www-data/web2py/applications/$1/static/$2;
  expires max;
  log_not_found off;
  include /etc/nginx/conf.d/web2py/gzip_static.conf;
  }
}


If you catch anything bad with this configuration, please let me know.
Thank you


On Tue, Feb 3, 2015 at 7:06 AM, Michele Comitini michele.comit...@gmail.com
 wrote:



 Il giorno lunedì 2 febbraio 2015 12:29:00 UTC+1, alex ha scritto:

 Michele,

 Thank you for quick answer!

 If I put in nginx server directive:

 location ~ ^/AAA(/.*)?$ { rewrite ^.*$ http://example.com/app/ctr/fnc
 break ; }

 and leave web2py/applications/app/routes.py with only

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),
 )

 everytime I call /AAA it gets rewritten to /app/ctr/fnc.
 Instead, I would like to see always /AAA



 I think you should post a minimal server directive to reproduce the
 problem.
 Don't use complete URI's (i.e. with https part) or you are likely to get
 an http redirection. This should get closer to you need:

 location /AAA { rewrite ^/AAA/.*$ /a/c/f last; }

 location / { uwsgi|scgi|fcgi handler section }


 On the other hand, if I remove the rewrite from nginx server directive,
 and I leave both routes_in and routes_out as described before in
 /app/routes.py, it works but randomly.

 Once every two or three times I refresh the page, I get:

 invalid request




 On Mon, Feb 2, 2015 at 7:50 PM, Michele Comitini michele@gmail.com
 wrote:

 you still need your routes.py in place:

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),

 )


 2015-02-02 11:23 GMT+01:00 al ex a22...@gmail.com:

 I have setup this route in /web2py/applications/app

 routes_in = (
 (r'/AAA/?', '/app/ctr/fnc'),
 )

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),

 )


 With rockets, on localhost, it works fine.

 On production server nginx 1.7.9, uwsgi 2.0.8, python 2.7.6, if I
 repeatedly refresh /AAA, sometimes it work, sometimes it gives: invalid
 request.

 This goes apparently randomly.

 How to isolate and solve this problem?
 I thought maybe trying to eliminate routes.py, and mimic the same rules
 on nginx, could give me a hint.

 routes_in would go to

 location ~ ^/AAA(/.*)?$ { rewrite ^.*$ http://example.com/app/ctr/fnc
 break ; }

 but how to write route_out in this case?


  --
 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+un...@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+un...@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 

[web2py] Re: uwsgi: strange messages

2015-02-03 Thread Niphlod
the  from operator import _compare_digest as compare_digest is documented 
on the interwebs just google it... standard issues are playing with 
different versions of python in the same server.
the how do I run it not from root well. Don't start uwsgi while 
logged in as root ! You stated this is the result of installing nginx+uwsgi 
using the script on a test server  if the script is this 
https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
 it 
has the correct permissions to AVOID running as root if the script is 
another one. it's wrong.


  

-- 
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: ckeditor : how to make read only, how to remove the toolbar in a dynamic way

2015-02-03 Thread Serge Bourgeois
Thanks for your response.

The solution I'm looking for should preserve the way ckeditor displays the
text.

Based on you idea, I tried this in my controller:

db.my_table.my_field.represent = lambda value, row:
 ckeditor.widget(db.my_table.my_field, value, **{'_name':'my_field_row_%s'
% row.id }) if 'new' in request.args or 'edit' in request.args  else
text_widget(db.my_table.my_field, value, **{'_name':'my_field_row_%s' %
row.id}).add_class('width250px' 'height50px')

( .. I added widht250px and height50px in the head of layout.html)

Mybe I missed some points in your suggestion ?
The result of this test leads to loosing the text format and displaying the
tags ...

Example of what displays on the screen for 'my_field':

p
This is my text strongthis is a strong text including an image:nbsp;img
alt=
src=/prj/default/download/plugin_ckeditor_upload.upload.bfe9ba00ebcb13a7.44657365727665546f42654c6f7665642e6d7033.mp3
//strong/p
p
nbsp;/p



2015-02-02 12:13 GMT+01:00 Tim Nyborg tim.nyb...@gmail.com:

 Depends on how you're implementing the widget.

 I've got a CKEditor widget as follows (pretty much a glorified copy of
 text.widget with the ckeditor class):

 class CKEditor(FormWidget):
 _class = 'ckeditor'

 @classmethod
 def widget(cls, field, value, **attributes):
 
 generates a TEXTAREA tag.

 see also: :meth:`FormWidget.widget`
 
 default = dict(value=value)
 attr = cls._attributes(field, default, **attributes)
 return TEXTAREA(**attr)

 Used in the model, it's:

 idb.define_table(
 'module',
 Field('id', 'id', readable=False),
 ...
 Field('description', 'text', widget=CKEditor.widget)
 )

 So to do what you're suggesting, I change it to:

 def hideable_ckeditor_widget():
 return SQLFORM.widgets.text.widget if 'new' in request.args or 'edit'
 in request.args else CKEditor.widget

 idb.define_table(
 'module',
 Field('id', 'id', readable=False),
 ...
 Field('description', 'text', widget=hideable_ckeditor_widget())
 )



 On Sunday, February 1, 2015 at 9:25:35 AM UTC, Serge Bourgeois wrote:

 I just implemented the ckeditor plugin. It looks great, but I need help
 (example if possible) showing how to hide the ckeditor toolbar for some
 text fields, for instance in a controller with a smartgrid, where
 request.args does not contain 'now' nor 'edit'.
 Thanks in advance !
 Serge

  --
 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/tnDhxZZLfdI/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: Handling (2006, 'MySQL server has gone away') from Scheduler, pythonanywhere

2015-02-03 Thread vld...@gmail.com
sometimes this error (2006, 'MySQL server has gone away') happens when 
parameter 'max_allowed_packet is too small.


$ sudo vim /etc/mysql/my.cnf
# goto  the [mysqld] section
[mysqld]
 ...
max_allowed_packet=8M   -- change this with, for example, 500M

Hope this can help you

Vladyslav Kozlovskyy
Ukraine, Chernivtsi


03.02.15 06:07, Kiran Subbaraman написав(ла):
Looks similar to this open-issue: 
https://github.com/web2py/web2py/issues/733


Kiran Subbaraman
http://subbaraman.wordpress.com/about/
On Tue, 03-02-2015 2:47 AM, Niphlod wrote:
uhm. does pythonanywhere even support a running process outside the 
web one ?


BTW: all kinky calls to the db are fail-safed in the scheduler (see 
wrapped_* functions), to alleviate locking (albeit primarely for 
sqlite).
This has the added benefit of making the scheduler more resilient 
against blocking, but this has gone away sounds like some problems 
with the underlying connectionpool

--
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 
mailto: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 
mailto: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] args typed in by hand into URL address window

2015-02-03 Thread Alex Glaros
never mind, found it: {{=request.raw_args}}

thanks

Alex

-- 
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 mimic routes.py with nginx

2015-02-03 Thread Michele Comitini
Where's the /AAA location directive?
If you want to cache you can try the uwsgi directives :
http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_cache
The rest seems ok.

2015-02-03 13:22 GMT+01:00 al ex a22...@gmail.com:

 I have commented the following 4 directives in my server declaration, that
 now looks like as below, and it seems to work better.

 open_file_cache  max=1000 inactive=20s;
 open_file_cache_valid30s;
 open_file_cache_min_uses 2;
 open_file_cache_errors   on;

 -
 in /etc/nginx/sites-available/mydomain


 server {
   listen [::]:443 ssl spdy;
   listen 443 ssl spdy;
   server_name mydomain;

   charset utf-8;

 # these includes are taken from
 https://github.com/h5bp/server-configs-nginx
 include /etc/nginx/h5bp/directive-only/ssl.conf;
 include /etc/nginx/h5bp/directive-only/spdy.conf;
 include /etc/nginx/h5bp/directive-only/ssl-stapling.conf;
 include /etc/nginx/h5bp/directive-only/x-ua-compatible.conf;
 include /etc/nginx/h5bp/directive-only/extra-security.conf;
 include /etc/nginx/h5bp/location/protect-system-files.conf;

 # these 4 are now commented, it seems now to work better
 # open_file_cache  max=1000 inactive=20s;
 # open_file_cache_valid30s;
 # open_file_cache_min_uses 2;
 # open_file_cache_errors   on;


   location /nginx_status {
 stub_status on;
 access_log   off;
 deny all;
   }

 location / {
 uwsgi_pass  unix:///tmp/web2py.sock;
 include uwsgi_params;
 uwsgi_param UWSGI_SCHEME $scheme;
 uwsgi_param SERVER_SOFTWAREnginx/$nginx_version;
  include /etc/nginx/conf.d/web2py/gzip.conf;
 }

   location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
   alias /home/www-data/web2py/applications/$1/static/$2;
   expires max;
   log_not_found off;
   include /etc/nginx/conf.d/web2py/gzip_static.conf;
   }
 }


 If you catch anything bad with this configuration, please let me know.
 Thank you


 On Tue, Feb 3, 2015 at 7:06 AM, Michele Comitini 
 michele.comit...@gmail.com wrote:



 Il giorno lunedì 2 febbraio 2015 12:29:00 UTC+1, alex ha scritto:

 Michele,

 Thank you for quick answer!

 If I put in nginx server directive:

 location ~ ^/AAA(/.*)?$ { rewrite ^.*$ http://example.com/app/ctr/fnc
 break ; }

 and leave web2py/applications/app/routes.py with only

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),
 )

 everytime I call /AAA it gets rewritten to /app/ctr/fnc.
 Instead, I would like to see always /AAA



 I think you should post a minimal server directive to reproduce the
 problem.
 Don't use complete URI's (i.e. with https part) or you are likely to get
 an http redirection. This should get closer to you need:

 location /AAA { rewrite ^/AAA/.*$ /a/c/f last; }

 location / { uwsgi|scgi|fcgi handler section }


 On the other hand, if I remove the rewrite from nginx server directive,
 and I leave both routes_in and routes_out as described before in
 /app/routes.py, it works but randomly.

 Once every two or three times I refresh the page, I get:

 invalid request




 On Mon, Feb 2, 2015 at 7:50 PM, Michele Comitini michele@gmail.com
 wrote:

 you still need your routes.py in place:

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),

 )


 2015-02-02 11:23 GMT+01:00 al ex a22...@gmail.com:

 I have setup this route in /web2py/applications/app

 routes_in = (
 (r'/AAA/?', '/app/ctr/fnc'),
 )

 routes_out = (
 ('/app/ctr/fnc', r'/AAA'),

 )


 With rockets, on localhost, it works fine.

 On production server nginx 1.7.9, uwsgi 2.0.8, python 2.7.6, if I
 repeatedly refresh /AAA, sometimes it work, sometimes it gives: invalid
 request.

 This goes apparently randomly.

 How to isolate and solve this problem?
 I thought maybe trying to eliminate routes.py, and mimic the same
 rules on nginx, could give me a hint.

 routes_in would go to

 location ~ ^/AAA(/.*)?$ { rewrite ^.*$ http://example.com/app/ctr/fnc
 break ; }

 but how to write route_out in this case?


  --
 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+un...@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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 

[web2py] question, kind of general

2015-02-03 Thread lucas
hey everyone,

so i wrote some code that does a bunch of web scraping and i just threw the 
code in a regular controller so i can output at different stages of 
development so i can trace the outputs for the next stage.

now i have to code running and it can run for days on end at full CPU 
capacity.  it is working great but it is locking up access from other 
client requests to other functions and views.

if i move the code to a module, will i get better multi-threading/SMTP so 
that the regular side of the website doesn't blow up or lock up or freeze 
out on other client requests?

also, if i setup cron to run this code, where is it best located so that 
the rest of the site doesn't suffer from servicing client requests?

thanx in advance, lucas

-- 
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] args typed in by hand into URL address window

2015-02-03 Thread Alex Glaros
how to catch args typed in by user into address window

example of URL at top of browser:

view_user_profile/4

user goes to address window and changes 4 to 1 so now, #1 person's data 
appears instead of #4 person

view_user_profile/1

what is the syntax for capturing that URL arg typed in by user?  I want to 
redirect if that happens.

thanks

Alex Glaros

-- 
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: insecure string pickle

2015-02-03 Thread Leonel Câmara
Did you compile the admin app on the same computer this is running in now?

-- 
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: ckeditor : how to make read only, how to remove the toolbar in a dynamic way

2015-02-03 Thread Serge Bourgeois
If I could find a way to add a way to change, in the view this

td id=cke_top_my_table_my_field class=cke_top role=presentationdiv
class=cke_toolbox role=group aria-labelledby=cke_6
onmousedown=return false;span id=cke_6

by this:

td id=cke_top_my_table_my_field class=cke_top hide
role=presentationdiv
class=cke_toolbox role=group aria-labelledby=cke_6
onmousedown=return false;span id=cke_6

then I woujld add this in the style definition of layout.html

.hide {display:none !important;}

and it would work...

Any suggestion on how I could add 'hide' in the class?

2015-02-03 10:02 GMT+01:00 Serge Bourgeois serge.bourgeo...@gmail.com:

 Thanks for your response.

 The solution I'm looking for should preserve the way ckeditor displays the
 text.

 Based on you idea, I tried this in my controller:

 db.my_table.my_field.represent = lambda value, row:
  ckeditor.widget(db.my_table.my_field, value, **{'_name':'my_field_row_%s'
 % row.id }) if 'new' in request.args or 'edit' in request.args  else
 text_widget(db.my_table.my_field, value, **{'_name':'my_field_row_%s' %
 row.id}).add_class('width250px' 'height50px')

 ( .. I added widht250px and height50px in the head of layout.html)

 Mybe I missed some points in your suggestion ?
 The result of this test leads to loosing the text format and displaying
 the tags ...

 Example of what displays on the screen for 'my_field':

 p
 This is my text strongthis is a strong text including an
 image:nbsp;img alt=
 src=/prj/default/download/plugin_ckeditor_upload.upload.bfe9ba00ebcb13a7.44657365727665546f42654c6f7665642e6d7033.mp3
 //strong/p
 p
 nbsp;/p



 2015-02-02 12:13 GMT+01:00 Tim Nyborg tim.nyb...@gmail.com:

 Depends on how you're implementing the widget.

 I've got a CKEditor widget as follows (pretty much a glorified copy of
 text.widget with the ckeditor class):

 class CKEditor(FormWidget):
 _class = 'ckeditor'

 @classmethod
 def widget(cls, field, value, **attributes):
 
 generates a TEXTAREA tag.

 see also: :meth:`FormWidget.widget`
 
 default = dict(value=value)
 attr = cls._attributes(field, default, **attributes)
 return TEXTAREA(**attr)

 Used in the model, it's:

 idb.define_table(
 'module',
 Field('id', 'id', readable=False),
 ...
 Field('description', 'text', widget=CKEditor.widget)
 )

 So to do what you're suggesting, I change it to:

 def hideable_ckeditor_widget():
 return SQLFORM.widgets.text.widget if 'new' in request.args or
 'edit' in request.args else CKEditor.widget

 idb.define_table(
 'module',
 Field('id', 'id', readable=False),
 ...
 Field('description', 'text', widget=hideable_ckeditor_widget())
 )



 On Sunday, February 1, 2015 at 9:25:35 AM UTC, Serge Bourgeois wrote:

 I just implemented the ckeditor plugin. It looks great, but I need help
 (example if possible) showing how to hide the ckeditor toolbar for some
 text fields, for instance in a controller with a smartgrid, where
 request.args does not contain 'now' nor 'edit'.
 Thanks in advance !
 Serge

  --
 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/tnDhxZZLfdI/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] args typed in by hand into URL address window

2015-02-03 Thread Richard Vézina
request.args(0)...

If user input 4 instead of 1 and access the page you can get the args the
same way you do it if you pass args value programmatically...

Is you question to know how you can avoid that or kind of double check if
programmatically passed args doens't change?

If so, maybe it is not exactly what  you want, but maybe signing url can
help :
http://web2py.com/books/default/chapter/29/04/the-core?search=signed+url#Digitally-signed-urls

This suppose to avoid modification of url by user because if url signature
change processing is trunked somehow, I gues you can implement your own
logic about that...

Richard

On Tue, Feb 3, 2015 at 3:58 PM, Alex Glaros alexgla...@gmail.com wrote:

 how to catch args typed in by user into address window

 example of URL at top of browser:

 view_user_profile/4

 user goes to address window and changes 4 to 1 so now, #1 person's data
 appears instead of #4 person

 view_user_profile/1

 what is the syntax for capturing that URL arg typed in by user?  I want to
 redirect if that happens.

 thanks

 Alex Glaros

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


Re: [web2py] args typed in by hand into URL address window

2015-02-03 Thread Richard Vézina
Or, if you just want to check if args passed has been change you can store
the programmatically passed args in session and ckeck in session before
process form or accessed page

Richard

On Tue, Feb 3, 2015 at 4:20 PM, Richard Vézina ml.richard.vez...@gmail.com
wrote:

 request.args(0)...

 If user input 4 instead of 1 and access the page you can get the args the
 same way you do it if you pass args value programmatically...

 Is you question to know how you can avoid that or kind of double check if
 programmatically passed args doens't change?

 If so, maybe it is not exactly what  you want, but maybe signing url can
 help :
 http://web2py.com/books/default/chapter/29/04/the-core?search=signed+url#Digitally-signed-urls

 This suppose to avoid modification of url by user because if url signature
 change processing is trunked somehow, I gues you can implement your own
 logic about that...

 Richard

 On Tue, Feb 3, 2015 at 3:58 PM, Alex Glaros alexgla...@gmail.com wrote:

 how to catch args typed in by user into address window

 example of URL at top of browser:

 view_user_profile/4

 user goes to address window and changes 4 to 1 so now, #1 person's data
 appears instead of #4 person

 view_user_profile/1

 what is the syntax for capturing that URL arg typed in by user?  I want
 to redirect if that happens.

 thanks

 Alex Glaros

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


Re: [web2py] args typed in by hand into URL address window

2015-02-03 Thread Richard Vézina
Ok, read very fast... didn't understand the context...

For user_profile kind of stuff, I would go with permission... You create a
role that has access to user_profile_update_form, like, manage_user
group... And you have 2 functions/pages one that only show user profile
data... You can filter what you want to expose or not... And the other
controler with a update form allow to admin or user_manager role to
alter user profile of the orther users...

In both controller you check role like that :

def manage_user():
if not auth.has_membership('manage_user'):
redirect(ON PERMISSION ISSUE PAGE DETAILING HOW TO ASK FOR MORE
PERMISSION)
...
regular controller suff


Or if you don't want user to see each other profile at all you can just
check that user id passed as args is the user id :

def user_profile():
if not request.args(0) == auth.user_id:
redirect(ON PERMISSION ISSUE PAGE DETAILING HOW TO ASK FOR MORE
PERMISSION)
...
regular controller suff


Richard

On Tue, Feb 3, 2015 at 4:22 PM, Richard Vézina ml.richard.vez...@gmail.com
wrote:

 Or, if you just want to check if args passed has been change you can store
 the programmatically passed args in session and ckeck in session before
 process form or accessed page

 Richard

 On Tue, Feb 3, 2015 at 4:20 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 request.args(0)...

 If user input 4 instead of 1 and access the page you can get the args the
 same way you do it if you pass args value programmatically...

 Is you question to know how you can avoid that or kind of double check if
 programmatically passed args doens't change?

 If so, maybe it is not exactly what  you want, but maybe signing url can
 help :
 http://web2py.com/books/default/chapter/29/04/the-core?search=signed+url#Digitally-signed-urls

 This suppose to avoid modification of url by user because if url
 signature change processing is trunked somehow, I gues you can implement
 your own logic about that...

 Richard

 On Tue, Feb 3, 2015 at 3:58 PM, Alex Glaros alexgla...@gmail.com wrote:

 how to catch args typed in by user into address window

 example of URL at top of browser:

 view_user_profile/4

 user goes to address window and changes 4 to 1 so now, #1 person's data
 appears instead of #4 person

 view_user_profile/1

 what is the syntax for capturing that URL arg typed in by user?  I want
 to redirect if that happens.

 thanks

 Alex Glaros

 --
 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: question, kind of general

2015-02-03 Thread Leonel Câmara
You should use the scheduler for this. Moving it to a module won't solve 
the problem.

-- 
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] args typed in by hand into URL address window

2015-02-03 Thread Alex Glaros
thanks Richard,  all of this is very helpful.  Will use it all now at at 
least later.

I think arg that I want is raw_args, but what is syntax for getting it?

if I type  {{=response.raw_args}}  I get None when raw_args in 
response.toolbar displays as 4

thanks

Alex

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