[web2py] Re: web2py 2.7.1 is OUT

2013-10-07 Thread Mirko
Hi,
Is it this one ? https://github.com/mdipierro/web2py-book
Thanks,
Mirko

On Monday, October 7, 2013 3:36:09 AM UTC+2, Tim Richardson wrote:

 the trunk version of the book available on GIT is as up to date as 
 possible (and a lot more recent than the version linked to on the website). 
 The book is simply a web2py app, so you can git clone it into a web2py 
 applications directory and hey presto, you've got the latest version. 


 On Saturday, October 5, 2013 10:20:21 PM UTC+10, Arnon Marcus wrote:

 How updated are the documentation? What version does the book reflect?



-- 
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/groups/opt_out.


Re: [web2py] Re: web2py 2.7.1 is OUT

2013-10-07 Thread Johann Spies
On 7 October 2013 08:30, Mirko mscavaz...@gmail.com wrote:

 Hi,
 Is it this one ? https://github.com/mdipierro/web2py-book


Yes.

Regards
Johann

-- 
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/groups/opt_out.


[web2py] Re: IMAP: Insert email to Sent folder

2013-10-07 Thread IVINH
Hi Alan,

By example at:
http://www.web2pyslices.com/slice/show/1706/how-to-compose-a-multi-attachment-draftnormal-email-with-imapsmtp
I have modified:

if form.vars.draft:
request.vars[k].file.seek(0)
payload = request.vars[k].file.read()
attachments.append(dict(payload=payload, filename=filename, 
mime=application/vnd.ms-excel))

to attach a ms-excel file, but the attachment (was successfully inserted) 
in draft  is not correct data. Can you help me?



Vào 10:37:56 UTC+7 Thứ hai, ngày 07 tháng mười năm 2013, IVINH đã viết:

 It's OK. Thank Alan Etkin.

 I need attachments file name before download (ex: big file), how do you 
 get it?
 I try added new field files and modified function select IMAP, it's 
 work for me: 

 for part in message.walk():
 maintype = part.get_content_maintype()
 if (%s.attachments % tablename in colnames) or \
(%s.files % tablename in colnames) or \
(%s.content % tablename in colnames):
 payload = part.get_payload(decode=True)
 if payload:
 filename = part.get_filename()
 values = {mime: part.get_content_type()}
 #if ((filename or not text in maintype) and
 if (filename):
 if (%s.attachments % tablename in colnames):
 values.update({payload: payload,
 filename: filename,
 encoding: part.get_content_charset(),
 disposition: 
 part[Content-Disposition]})
 attachments.append(values)
 if (%s.files % tablename in colnames):
 files.append({'filename':filename,'size':len(payload)})
 elif ((text in maintype) and
   (%s.content % tablename in colnames)):
 values.update({text: 
 self.encode_text(payload,
self.get_charset(part))})
 content.append(values)

 if %s.size % tablename in colnames:
 if part is not None:
 size += len(str(part))
 item_dict[%s.content % tablename] = content
 item_dict[%s.files % tablename] = files
 item_dict[%s.attachments % tablename] = attachments
 item_dict[%s.size % tablename] = size
 imapqry_list.append(item_dict)





 Vào 02:45:32 UTC+7 Thứ hai, ngày 07 tháng mười năm 2013, Alan Etkin đã 
 viết:

 I am testing it too and for some mail got this traceback:
 ERROR:web2py.dal:Could not parse date text: 10 Dec 2012 02:23:50 +0100. 
 need more than 1 value to unpackou 


 There's a pending pull request that should fix the issue

 http://github.com/web2py/web2py/pull/241



-- 
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/groups/opt_out.


[web2py] Re: Unsuccessful password reset

2013-10-07 Thread lesssugar


 Your problem does not come from the code you show us


When I comment this piece of code *(A)*:
auth.messages.reset_password = response.render(
'mailing/pass_reset.html',
dict(subject='Password reset',
link = 'http://'+request.env.http_host+URL('default', 'user', 
args=['reset_password'])+'/%(key)s'))

- password reset works with no errors.

The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


What do you mean, unresolved? This code is directly copied from the book. 
E.g. when I do this *(B)*, the reset works as well:

auth.messages.reset_password = 'Click on link http://'+ 
request.env.http_host + URL('default', 'user', args=['reset_password']) + 
'/%(key)s to reset your password'

When I go with the earlier code *(A)*, it fails.

Anyway, I'll keep digging. Thanks for help and suggestions.

 


On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem does 
 not come from the code you show us. 

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved but this is not the cause of the (0x22) problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. It's 
 getting a little bit frustrating as I'm not sure where to look for the bug.

 On Thursday, October 3, 2013 1:22:50 AM UTC+2, Massimo Di Pierro wrote:

 What is this supposed to do?

 {{=XML('%(key)s')}}

 Are you sure you are not looking for:

 a href={{=URL('default','user', args=('reset_password',key), 
 scheme=True, host=True)}} Go to password reset/a

 Is key a variable?
 Anyway, I am not sure your problem comes from this code.

 On Wednesday, 2 October 2013 08:14:17 UTC-5, lesssugar wrote:

 Sorry, Massimo, but I really don't get it. Is the slash causing the 
 problem? I use '[controller_name]/[view_name.html]' to render other emails 
 and it's all ok.

 I even tried to do it this way in the mailing view:

 a href={{=URL('default','user', args='reset_password', scheme=True, 
 host=True)}}/{{=XML('%(key)s')}} Go to password reset/a

 - and nothing, still the same error. I would be grateful for another 
 hint, if there is one.


 On Tuesday, October 1, 2013 10:31:23 PM UTC+2, Massimo Di Pierro wrote:

 You probably have same strange character in 'mailing/pass_reset.html'

 On Tuesday, 1 October 2013 13:26:46 UTC-5, lesssugar wrote:

 I'm trying to send a custom email template to user when they perform 
 password reset:

 *db.py:*

 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject=Password reset,
 link=URL('default','user', args='reset_password')))

 and in *mailing/pass_reset.html*:

 ...
 a href={{=URL('default','user', args=['reset_password'], 
 scheme=True, host=True) + '/%(key)s'}} Go to password reset/a
 ...

 and everytime I'm testing, I get this:

  File /home/username/www/web2py/gluon/tools.py, line 2739, in 
 email_reset_password
 dict(key=reset_password_key, link=link)):
 ValueError: unsupported format character '' (0x22) at index 411


 Any ideas what might be 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/groups/opt_out.


Re: [web2py] Logging http audit

2013-10-07 Thread Ricardo Pedroso
On Sun, Oct 6, 2013 at 2:31 PM, Arnon Marcus a.m.mar...@gmail.com wrote:
 Hi,

 I would like to log more HTTP-traffic-related data into logstash - no
 webserver outputs the information I need.
 I know there is already a built-in http logger, but just like any
webserver,
 it does not include the body and other data (controller-action, args,
vars,
 user, session, etc).
 I want to have a cross-application logger that does that, and use the
 logstash-formatter module for the file-format.
 What would be my best approach?
 The existing http-logger already does a good job at capturing the
 http-traffic (request AND response) in a global way (non
 app/controller-specific, I assume it functions at the wsgi level), but
lacks
 extra information.
 I can create the logstash-handler as a separate handler and bind it to
 existing logger(s) - but where do I find the code of the http handler?
 Should I modify it, or fork it (create a new one using the existing one
as a
 basis)? If so, how? Should it be in the anyserver.py (assuming I want to
use
 gevent)?
 I would like to avoid having to use it at the controller-action level
(that
 would be stupid), while still not reinventing the wheel for that.
 Any suggestions?


Maybe a WSGI Middleware , for example:

import sys
import time

from gluon.globals import current

class Logger(object):
def __init__(self, application):
self.application = application

def __call__(self, environ, start_response):
# Do something here to modify request
def _start_response(status, headers, exc_info=None):
# Do something to modify the response status or headers
print sys.stderr, 'before start_response'

# Call upstream start_response
start_response(status, headers, exc_info)
print sys.stderr, 'after start_response'
return start_response(status, headers, exc_info)

print sys.stderr, 'before application'
start_time = time.time()

# Call the wrapped application
app_iter = self.application(environ, _start_response)

# Do something to modify the response body
end_time = time.time()
print sys.stderr, 'after application'

if hasattr(current, 'request'):
request = current.request
print sys.stderr, %s/%s/%s took %.3f ms to run % (
request.application,
request.controller,
request.function ,
(end_time - start_time) *
1000)

# Return modified response
return app_iter

and to run with gevent, for example:

#!/usr/bin/python
# coding: utf-8

# To use a virtualenv:

#VENV_PATH = '/home/envs/someenv'
#
#activate_this = VENV_PATH + '/bin/activate_this.py'
#execfile(activate_this, dict(__file__=activate_this))

import gevent.monkey
gevent.monkey.patch_all()
import sys
from gevent.pywsgi import WSGIServer

# change these parameters as required
LOGGING = False
SOFTCRON = False

import sys
import os

path = os.path.dirname(os.path.abspath(__file__))
os.chdir(path)

if not os.path.isdir('applications'):
raise RuntimeError('Running from the wrong folder')

sys.path = [path] + [p for p in sys.path if not p == path]

sys.stdout = sys.stderr

import gluon.main
from logger_middleware import Logger

if LOGGING:
application = Logger(gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
logfilename='httpserver.log',
profiler_dir=None))
else:
application = Logger(gluon.main.wsgibase)

if SOFTCRON:
from gluon.settings import global_settings
global_settings.web2py_crontype = 'soft'


if __name__ == '__main__':
print 'Serving on 8088...'
WSGIServer(('', 8088), application).serve_forever()


Also you can search for logger middlewares, you have one here:
https://pypi.python.org/pypi/wsgi-request-logger

Ricardo

-- 
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/groups/opt_out.


[web2py] Re: Custom Style of a textarea.

2013-10-07 Thread Ykä Marjanen
Glad to help back, as I've gotten so much help from here.

If you like to have a more generic code to add your classes to the form 
objects, you can use the code below. It will add a new class to all 
elements while keeping the web2py classes. I think you could even add this 
to the layout with try-statement, so anytime you use any form, it would 
include new classes.

!-- Additing bootstrap 3 classes to web2py form--
{{for element in form.elements():}}
{{if element['_class']:}}
{{element['_class'] = str(element['_class']) +  form-control}}
{{else:}}
{{element['_class'] = 'form-control'}}
{{pass}}
{{pass}}

Ykä

On Sunday, October 6, 2013 10:31:19 PM UTC+3, Francisco García wrote:

 Hello Ykä and Paolo,

 Your answers are very useful for me. The problem is solved.
 All I needed was this sentence:

 form.custom.widget.FIELD['_class'] = 'text myclass'}

 Thank you for your fast answer.
 Regards.


 El sábado, 5 de octubre de 2013 09:24:59 UTC+2, Ykä Marjanen escribió:

 Hi Francisco,

 happy to help you, as I've gone a 4 day intensive bootstrap 3 integration 
 to web2py and learned a lot about customizing the views and forms. This 
 might not be the best (or only) solution, but has worked well for me:

 - Web2py form includes classes based on their type, which I recommend to 
 keep, if you want any added web2py functionality.
 - You need to use custom form style (form.custom.begin) and then 
 manipulate each widget separately (or all of them in a for loop)

 Here's my form code in a view (controller is not modified). In this form 
 I have added form-control class of bootstrap 3 and kept the original 
 class as well. For textarea you can do 
 form.custom.widget.textfield['_rows'] = 3 if you want to make a smaller 
 textarea.

 
 form action= enctype=multipart/form-data method=post role=form
 div class=form-group
 {{form.custom.widget.campaign['_class'] = 
 'generic-widget form-control'}}
 {{form.custom.widget.topic['_class'] = 'string 
 form-control'}}
 {{form.custom.widget.topic['_placeholder'] = 'Idea 
 topic'}}
 {{form.custom.widget.description['_class'] = 'text 
 form-control'}}
 {{form.custom.widget.description['_placeholder'] = 
 'Idea description'}}
 div class=form-group
 label for=exampleSelectSelect a 
 campaign/label
 {{=form.custom.widget.campaign}}
 /div
 div class=form-group
 label for=exampleInputTopicInput idea topic 
 and description/label
 {{=form.custom.widget.topic}}
 /div
 div class=form-group
 {{=form.custom.widget.description}}
 /div
 button type=submit class=btn btn-primarySubmit 
 your idea/button
 /div
 {{=form.custom.end}}

 

 Ykä

 On Friday, October 4, 2013 8:14:33 PM UTC+3, Francisco García wrote:

 Hello all,

 I am loading a form from a database table, with CRUD or SQLFORM (It is 
 the same for me).
 This form contains text fields and textarea fields between others.

 Now, I need to change in the views the class of all textareas,  from 
 class=text  to class=myclass
 How can I do this from controllers or views?   (I can't edit any css 
 file).

 I am trying with form.custom.widget  but I can't change it.
 I'm not sure if it is something simple, or it is impossible to do this 
 way.


 Thank you in advance.
 Regards,
 Francisco



-- 
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/groups/opt_out.


[web2py] Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Johann Spies
This code in web2py:

fields = [db.rissue.so, db.rissue.sn, db.rsubject.subject]
query = ((db.rissue.id  0)
 (db.rsc_joern_link.rj_id == db.rissue.uuid)
 (db.rsc_joern_link.sc_id == db.rsubject.uuid)
 )
data = SQLFORM.grid(query,
fields = fields,
maxtextlength=120,
editable = False,
deletable = False)

results in the following backend query:

SELECT  rissue.so, rissue.sn, rsubject.subject,
rsc_joern_link.id
FROM rsc_joern_link, rissue, rsubject
WHERE (((rissue.id  0)
AND (rsc_joern_link.rj_id = rissue.uuid))
AND (rsc_joern_link.sc_id = rsubject.uuid))
ORDER BY rsc_joern_link.id, rissue.id, rsubject.id
LIMIT 20
OFFSET 0;

which is not a serious problem when working with small datasets but the
added 'orderby' clause causes serious delays when when working with large
datasets.

As a workaround I am nou using 'orderby = db.table.id  in all cases to
prevent web2py adding what I did not mean.

On a small dataset (3543 records) the effect was:

SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM
rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND
(rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id =
rsubject.uuid)) ORDER BY rissue.id LIMIT 20 OFFSET 0;



1.58ms (this was with my orderby)

SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM
rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND
(rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id =
rsubject.uuid)) ORDER BY rsc_joern_link.id, rissue.id, rsubject.id
LIMIT 20 OFFSET 0;

6.66ms  (this was with web2py's interpretation of my query)


I have not tested this but I suspect the multiple field orderby's only
happens when joins are involved.

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

-- 
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/groups/opt_out.


[web2py] Re: 2.4.7 problems

2013-10-07 Thread sherdim


 The source of the problem is in the gluon/cache.py

When I have revert this only file to the version of 2012-09-18 - cache.disk 
is working again

below the method from that file, which have became errorous in the last 
versions:

def _open_shelf_with_lock(self):
Open and return a shelf object, obtaining an exclusive lock
on self.locker first. Replaces the close method of the
returned shelf instance with one that releases the lock upon
closing.
def _close(self):
try:
shelve.Shelf.close(self)
finally:
portalocker.unlock(self.locker)
self.locker.close()

storage, locker, locker_locked = None, None, False
try:
locker = open(self.locker_name, 'a')
portalocker.lock(locker, portalocker.LOCK_EX)
locker_locked = True
storage = shelve.open(self.shelve_name)
storage.close = _close.__get__(storage, shelve.Shelf)
storage.locker = locker
except Exception:
logger.error('corrupted cache file %s, will try to delete and 
recreate it!' % (self.shelve_name))
if storage:
storage.close()
storage = None

try:
os.unlink(self.shelve_name)
storage = shelve.open(self.shelve_name)
storage.close = _close.__get__(storage, shelve.Shelf)
storage.locker = locker
if not CacheAbstract.cache_stats_name in storage.keys():
storage[CacheAbstract.cache_stats_name] = {
'hit_total': 0,
'misses': 0,
}
storage.sync()
except (IOError, OSError):
logger.warn('unable to delete and recreate cache file %s' % 
self.shelve_name)
if storage:
storage.close()
storage = None
if locker_locked:
portalocker.unlock(locker)
if locker:
locker.close()
return storage


-- 
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/groups/opt_out.


Re: [web2py] logging controller output for specific session

2013-10-07 Thread Ricardo Pedroso
On Thu, Oct 3, 2013 at 9:39 AM, Geo geo.petr...@gmail.com wrote:

 Greetings,
 I have a controller that generates many log messages. Most of them are 
 currently used for debugging but some (warnings and errors) are also useful 
 for users.
 Logs are currently handled with a module similar to this: 
 http://www.web2pyslices.com/slice/show/1416/logging

 I have tried attaching a StringIO handler to capture messages to a string

Try different loggers objects, for example:


 import logging
 import StringIO

 def index():

   logger = logging.getLogger('%s.%s.%s' % (request.application,
request.controller, request.function))

 log_capture_string = StringIO.StringIO()
 ch = logging.StreamHandler(log_capture_string)
 ch.setLevel(logging.ERROR)
 logger.addHandler(ch)

 #controller actions

 logger.removeHandler(ch)
 notifications = log_capture_string.getvalue()
 notifications = notifications.split('\n')
 log_capture_string.close()

 #controller return
 return dict(notifications = notifications, myothervars=myothervars)


 This works well if I run this controller alone (no other sessions, no other 
 controllers running at the same time). But as soon as I run something else 
 concurrently, the handler will capture that too.

 Do you know if there is a way to capture the output of a controller when ran 
 in a specific session?
 I thought about mimicking the internal error handler (the one that generates 
 error tickets) but without success.

 Thanks in advance
 Geo

 --
 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/groups/opt_out.

-- 
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/groups/opt_out.


[web2py] Re: Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Anthony
I don't think it's the grid specifically that's doing that. When the DAL 
does a query with limitby, if no orderby is specified, it automatically 
orders by the primary keys of the tables involved, I assume to ensure the 
same query returns the same results each time (especially important for 
pagination). There is an undocumented orderby_on_limitby argument of 
.select() that controls this behavior (it defaults to True).

Anthony

On Monday, October 7, 2013 6:41:54 AM UTC-4, Johann Spies wrote:

 This code in web2py:

 fields = [db.rissue.so, db.rissue.sn, db.rsubject.subject]
 query = ((db.rissue.id  0)
  (db.rsc_joern_link.rj_id == db.rissue.uuid)
  (db.rsc_joern_link.sc_id == db.rsubject.uuid)
  )
 data = SQLFORM.grid(query,
 fields = fields,
 maxtextlength=120,
 editable = False,
 deletable = False)

 results in the following backend query:

 SELECT  rissue.so, rissue.sn, rsubject.subject, 

 rsc_joern_link.id 
 FROM rsc_joern_link, rissue, rsubject 
 WHERE (((rissue.id  0) 
 AND (rsc_joern_link.rj_id = rissue.uuid)) 
 AND (rsc_joern_link.sc_id = rsubject.uuid)) 

 ORDER BY rsc_joern_link.id, rissue.id, rsubject.id 
 LIMIT 20 
 OFFSET 0;

 which is not a serious problem when working with small datasets but the 
 added 'orderby' clause causes serious delays when when working with large 
 datasets.  

 As a workaround I am nou using 'orderby = db.table.id  in all cases to 
 prevent web2py adding what I did not mean. 

 On a small dataset (3543 records) the effect was:

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rissue.id LIMIT 20 OFFSET 0;

  

 1.58ms (this was with my orderby)

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rsc_joern_link.id, rissue.id, rsubject.id LIMIT 20 
 OFFSET 0;

 6.66ms  (this was with web2py's interpretation of my query)


 I have not tested this but I suspect the multiple field orderby's only 
 happens when joins are involved.

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

-- 
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/groups/opt_out.


Re: [web2py] Re: Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Johann Spies
Thanks for the explanation Anthony.  Users with large datasets should be
aware of this.

Regards
Johann


On 7 October 2013 13:59, Anthony abasta...@gmail.com wrote:

 I don't think it's the grid specifically that's doing that. When the DAL
 does a query with limitby, if no orderby is specified, it automatically
 orders by the primary keys of the tables involved, I assume to ensure the
 same query returns the same results each time (especially important for
 pagination). There is an undocumented orderby_on_limitby argument of
 .select() that controls this behavior (it defaults to True).

 Anthony


 On Monday, October 7, 2013 6:41:54 AM UTC-4, Johann Spies wrote:

 This code in web2py:

 fields = [db.rissue.so, db.rissue.sn, db.rsubject.subject]
 query = ((db.rissue.id  0)
  (db.rsc_joern_link.rj_id == db.rissue.uuid)
  (db.rsc_joern_link.sc_id == db.rsubject.uuid)
  )
 data = SQLFORM.grid(query,
 fields = fields,
 maxtextlength=120,
 editable = False,
 deletable = False)

 results in the following backend query:

 SELECT  rissue.so, rissue.sn, rsubject.subject,

 rsc_joern_link.id
 FROM rsc_joern_link, rissue, rsubject
 WHERE (((rissue.id  0)
 AND (rsc_joern_link.rj_id = rissue.uuid))
 AND (rsc_joern_link.sc_id = rsubject.uuid))

 ORDER BY rsc_joern_link.id, rissue.id, rsubject.id
 LIMIT 20
 OFFSET 0;

 which is not a serious problem when working with small datasets but the
 added 'orderby' clause causes serious delays when when working with large
 datasets.

 As a workaround I am nou using 'orderby = db.table.id  in all cases to
 prevent web2py adding what I did not mean.

 On a small dataset (3543 records) the effect was:

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rissue.id LIMIT 20 OFFSET 0;



 1.58ms (this was with my orderby)

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rsc_joern_link.id, rissue.id, rsubject.id LIMIT 20 
 OFFSET 0;

 6.66ms  (this was with web2py's interpretation of my query)


 I have not tested this but I suspect the multiple field orderby's only
 happens when joins are involved.

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

  --
 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/groups/opt_out.




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

-- 
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/groups/opt_out.


Re: [web2py] Re: Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Michele Comitini
Joahnn, yes on large datasets the ordering is devastating, since it causes
full table sweep even if not needed.

We must add the orderby_on_limitby paramenters in the book because it
impacts large datasets.
Shortcut queries that return single values like db.table(id=3) are already
optimized to avoid ordering.

mic


2013/10/7 Johann Spies johann.sp...@gmail.com

 Thanks for the explanation Anthony.  Users with large datasets should be
 aware of this.

 Regards
 Johann


 On 7 October 2013 13:59, Anthony abasta...@gmail.com wrote:

 I don't think it's the grid specifically that's doing that. When the DAL
 does a query with limitby, if no orderby is specified, it automatically
 orders by the primary keys of the tables involved, I assume to ensure the
 same query returns the same results each time (especially important for
 pagination). There is an undocumented orderby_on_limitby argument of
 .select() that controls this behavior (it defaults to True).

 Anthony


 On Monday, October 7, 2013 6:41:54 AM UTC-4, Johann Spies wrote:

 This code in web2py:

 fields = [db.rissue.so, db.rissue.sn, db.rsubject.subject]
 query = ((db.rissue.id  0)
  (db.rsc_joern_link.rj_id == db.rissue.uuid)
  (db.rsc_joern_link.sc_id == db.rsubject.uuid)
  )
 data = SQLFORM.grid(query,
 fields = fields,
 maxtextlength=120,
 editable = False,
 deletable = False)

 results in the following backend query:

 SELECT  rissue.so, rissue.sn, rsubject.subject,


 rsc_joern_link.id
 FROM rsc_joern_link, rissue, rsubject
 WHERE (((rissue.id  0)
 AND (rsc_joern_link.rj_id = rissue.uuid))

 AND (rsc_joern_link.sc_id = rsubject.uuid))

 ORDER BY rsc_joern_link.id, rissue.id, rsubject.id
 LIMIT 20
 OFFSET 0;

 which is not a serious problem when working with small datasets but the
 added 'orderby' clause causes serious delays when when working with large
 datasets.

 As a workaround I am nou using 'orderby = db.table.id  in all cases to
 prevent web2py adding what I did not mean.

 On a small dataset (3543 records) the effect was:

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rissue.id LIMIT 20 OFFSET 0;



 1.58ms (this was with my orderby)

 SELECT  rissue.so, rissue.sn, rsubject.subject, rsc_joern_link.id FROM 
 rsc_joern_link, rissue, rsubject WHERE (((rissue.id  0) AND 
 (rsc_joern_link.rj_id = rissue.uuid)) AND (rsc_joern_link.sc_id = 
 rsubject.uuid)) ORDER BY rsc_joern_link.id, rissue.id, rsubject.id LIMIT 20 
 OFFSET 0;

 6.66ms  (this was with web2py's interpretation of my query)


 I have not tested this but I suspect the multiple field orderby's only
 happens when joins are involved.

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

  --
 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/groups/opt_out.




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

 --
 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/groups/opt_out.


-- 
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/groups/opt_out.


Re: [web2py] Re: Union of tables displayed in SQLFORM.grid

2013-10-07 Thread Johann Spies
On 4 October 2013 12:39, TYRANISTAR makisthegr...@gmail.com wrote:

 Thank you for your reply. Do you have an example on how to do that? Sorry
 for asking but I am still a newbie at web2py.


Create a view in the backend or use db.executesql(your query creating the
VIEW containing the 'UNION').
Make sure your view contains an 'id' field.  You can put something like
'SELECT 1 AS id ...'  in the query.
In your crontroller or in the model, create a table definition to reflect
the view and make put in that definition: migrate = False

You can then do a

data = SQLFORM.grid(db.view that you created.id  0, ...)

Regards
Johann

-- 
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/groups/opt_out.


Re: [web2py] Re: Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Tim Richardson
I'll put this in the book. 

 There is an undocumented orderby_on_limitby argument of .select() that 
controls this behavior (it defaults to True).

-- 
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/groups/opt_out.


Re: [web2py] Re: Why does Web2py add 'orderby' to grid queries?

2013-10-07 Thread Anthony
On Monday, October 7, 2013 8:11:42 AM UTC-4, Michele Comitini wrote:

 Joahnn, yes on large datasets the ordering is devastating, since it causes 
 full table sweep even if not needed.

 We must add the orderby_on_limitby paramenters in the book because it 
 impacts large datasets.
 Shortcut queries that return single values like db.table(id=3) are already 
 optimized to avoid ordering.


db.table(id=3) is for returning the sole matching record, so you don't have 
to worry about the database's arbitrary ordering of results. But when using 
limitby to return a particular subset of records (e.g., when doing 
pagination), don't you need to specify an orderby to guarantee that the 
results on each query will remain in the same order?

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/groups/opt_out.


[web2py] How to update an image with web2py onclick

2013-10-07 Thread Vladimir Bratov


I have an image

img  src={{=URL(r=request,f='imageFr',args=[request.args(3)])}}/ 

within my .html. Within the same .html I want to have a text input field 
and a button that will send textfield text to imageFr and update the image 
with a new image that will be generated by imageFr. I wrote this:

INPUT type=text id=q name = q value=LAST/INPUT type=button 
value=Draw onclick=/

But now I have no idea about what should I do onclick.

-- 
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/groups/opt_out.


[web2py] Tracking the date/time of a field change.

2013-10-07 Thread James Thompson
I need to track the date/time of the last change to one field in a row.
Example:

Field('f_status', type='text',
  label=T('Status'), requires=IS_IN_SET(['status1', 'status2', 
'status3'])),
Field('f_status_change_dt', type='datetime',
  label=T('Status Change Dt')),

where 'status_change_dt' would be automatically be set to the current 
date/time whenever the value of the 'status' field changed.
   
I could do this in my own app code, but I was hoping for something in the 
model so that it happens in the web2py admin, or any other apps that use 
this model as well.

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/groups/opt_out.


[web2py] Re: capturing the text value of a clicked link using python

2013-10-07 Thread Massimo Di Pierro
You cannot do this with Python. you need to do this with JS:

!DOCTYPE html
html lang='EN'
head
titleTesting /title
/head
body
h1Medicinal Plant List/h1
script
   onclick = function(){ var t=jQuery(this).attr(href); alert(t); }
/script
a href=http://www.google.com; name=My Link onclick=onclick()My 
Link/a
/body
/html


On Sunday, 6 October 2013 11:35:01 UTC-5, Remya R G wrote:




-- 
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/groups/opt_out.


Re: [web2py] chat-tornado in web2py using websocket_messaging.py

2013-10-07 Thread Massimo Di Pierro
Can you help us find out why Tornado 31. does not work?

On Sunday, 6 October 2013 21:24:29 UTC-5, Junior Phanter wrote:

 Sorry my bad english, 

 Analyzing the web2py_websocket inside web2py.js. I noticed that when I 
 used:

script
$(document).ready(function(){
   var data;
   web2py_websocket('ws://127.0.0.1:/realtime/mygroup', 
 function(e){data=eval('('+e.data+')')});
});
/script
  

 the browser console accused the web2py_websocket was not a function, so 
 I changed the code to:

script
$(document).ready(function(){
   var data;
   $.web2py.web2py_websocket('ws://127.0.0.1:/realtime/mygroup', 
 function(e){data=eval('('+e.data+')')});
});
/script

 worked perfectly!


 I changed it to Tornado 3.0 (Tornado 3.1.1 not work) and web2py 2.7.1. 


 2013/10/4 Junior Phanter junior...@gmail.com javascript:

 greetings ,
 sorry my bad english , I 'm trying to implement a chat using the tornado 
 and websocket_messaging.py , but I'm having trouble hearing the tornado 
 server . the server receives the tornado MESSAGES using :

 websocket_send ( ' http://127.0.0.1: ', ' Hello World ', ' mykey ', 
 ' mygroup ' )

 but the script :
 -
script
$(document).ready(function(){
   var data;
   web2py_websocket('ws://127.0.0.1:/realtime/mygroup
 ',function(e){data=eval('('+e.data+')')});
});
/script
 -
 does not capture the listener .

 I tested the application that comes as an example within the 
 websocket_messaging.py and neither worked .

 - exemplo dentro do websocket_messaging.py 
 --

 Here is a complete sample web2py action:

 def index():
 form=LOAD('default','ajax_form',ajax=True)
 script=SCRIPT('''
 jQuery(document).ready(function(){
   var callback=function(e){alert(e.data)};
   if(!web2py_websocket('ws://127.0.0.1:/realtime/mygroup
 ',callback))
 alert(html5 websocket not supported by your browser, try 
 Google Chrome);
 });
 ''')
 return dict(form=form, script=script)

 def ajax_form():
 form=SQLFORM.factory(Field('message'))
 if form.accepts(request,session):
 from gluon.contrib.websocket_messaging import websocket_send
 websocket_send(
 'http://127.0.0.1:
 ',form.vars.message,'mykey','mygroup')
 return form


 -



 I'm using the Tornado 2.1 and 2.6.4 web2py

  -- 
 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 javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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/groups/opt_out.


[web2py] Re: Unsuccessful password reset

2013-10-07 Thread Massimo Di Pierro
Sorry. Now I understand better what you are trying to do. Your invalid 
character must be in mailing/pass_reset.html. Can you show us that file?

On Monday, 7 October 2013 04:17:53 UTC-5, lesssugar wrote:

 Your problem does not come from the code you show us


 When I comment this piece of code *(A)*:
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 - password reset works with no errors.

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


 What do you mean? This code is directly copied from the book. E.g. when I 
 do this *(B)*, the reset works as well:

 auth.messages.reset_password = 'Click on link http://'+ 
 request.env.http_host + URL('default', 'user', args=['reset_password']) + 
 '/%(key)s to reset your password'

 When I go with the earlier code *(A)*, it fails.

 Anyway, I'll keep digging. Thanks for help and suggestions.

  


 On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem does 
 not come from the code you show us. 

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved but this is not the cause of the (0x22) problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. It's 
 getting a little bit frustrating as I'm not sure where to look for the bug.

 On Thursday, October 3, 2013 1:22:50 AM UTC+2, Massimo Di Pierro wrote:

 What is this supposed to do?

 {{=XML('%(key)s')}}

 Are you sure you are not looking for:

 a href={{=URL('default','user', args=('reset_password',key), 
 scheme=True, host=True)}} Go to password reset/a

 Is key a variable?
 Anyway, I am not sure your problem comes from this code.

 On Wednesday, 2 October 2013 08:14:17 UTC-5, lesssugar wrote:

 Sorry, Massimo, but I really don't get it. Is the slash causing the 
 problem? I use '[controller_name]/[view_name.html]' to render other 
 emails 
 and it's all ok.

 I even tried to do it this way in the mailing view:

 a href={{=URL('default','user', args='reset_password', scheme=True, 
 host=True)}}/{{=XML('%(key)s')}} Go to password reset/a

 - and nothing, still the same error. I would be grateful for another 
 hint, if there is one.


 On Tuesday, October 1, 2013 10:31:23 PM UTC+2, Massimo Di Pierro wrote:

 You probably have same strange character in 'mailing/pass_reset.html'

 On Tuesday, 1 October 2013 13:26:46 UTC-5, lesssugar wrote:

 I'm trying to send a custom email template to user when they perform 
 password reset:

 *db.py:*

 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject=Password reset,
 link=URL('default','user', args='reset_password')))

 and in *mailing/pass_reset.html*:

 ...
 a href={{=URL('default','user', args=['reset_password'], 
 scheme=True, host=True) + '/%(key)s'}} Go to password reset/a
 ...

 and everytime I'm testing, I get this:

  File /home/username/www/web2py/gluon/tools.py, line 2739, in 
 email_reset_password
 dict(key=reset_password_key, link=link)):
 ValueError: unsupported format character '' (0x22) at index 411


 Any ideas what might be 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/groups/opt_out.


[web2py] Re: 2.4.7 problems

2013-10-07 Thread Massimo Di Pierro
Please open a ticket about this.

On Monday, 7 October 2013 06:21:55 UTC-5, sherdim wrote:

 The source of the problem is in the gluon/cache.py

 When I have revert this only file to the version of 2012-09-18 - 
 cache.disk is working again

 below the method from that file, which have became errorous in the last 
 versions:

 def _open_shelf_with_lock(self):
 Open and return a shelf object, obtaining an exclusive lock
 on self.locker first. Replaces the close method of the
 returned shelf instance with one that releases the lock upon
 closing.
 def _close(self):
 try:
 shelve.Shelf.close(self)
 finally:
 portalocker.unlock(self.locker)
 self.locker.close()

 storage, locker, locker_locked = None, None, False
 try:
 locker = open(self.locker_name, 'a')
 portalocker.lock(locker, portalocker.LOCK_EX)
 locker_locked = True
 storage = shelve.open(self.shelve_name)
 storage.close = _close.__get__(storage, shelve.Shelf)
 storage.locker = locker
 except Exception:
 logger.error('corrupted cache file %s, will try to delete and 
 recreate it!' % (self.shelve_name))
 if storage:
 storage.close()
 storage = None

 try:
 os.unlink(self.shelve_name)
 storage = shelve.open(self.shelve_name)
 storage.close = _close.__get__(storage, shelve.Shelf)
 storage.locker = locker
 if not CacheAbstract.cache_stats_name in storage.keys():
 storage[CacheAbstract.cache_stats_name] = {
 'hit_total': 0,
 'misses': 0,
 }
 storage.sync()
 except (IOError, OSError):
 logger.warn('unable to delete and recreate cache file %s' 
 % self.shelve_name)
 if storage:
 storage.close()
 storage = None
 if locker_locked:
 portalocker.unlock(locker)
 if locker:
 locker.close()
 return storage




-- 
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/groups/opt_out.


[web2py] Re: Tracking the date/time of a field change.

2013-10-07 Thread 黄祥
i think you can achieve it with default.
e.g. 
Field('f_status_change_dt', type='datetime',
  label=T('Status Change Dt')*, default=request.now*)

or if you set auth.signature or record_versioning, web2py automatically do 
that for you.

ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning
http://web2py.com/books/default/chapter/29/09/access-control#Record-versioning

best regards,
stifan

-- 
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/groups/opt_out.


[web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?

2013-10-07 Thread Py Dev
Hi Tim,

thanks for your tip with the jQuery Grid code. 

My question referred to the code from Simon Ashley how to use jeditable, 
see best marked answer...
This code is not on 
web2pysliceshttp://www.web2pyslices.com/slice/show/1714/jqgrid-viewing-and-updating-data

Cheers!

pd



my question 

Am Samstag, 5. Oktober 2013 15:14:38 UTC+2 schrieb Tim Richardson:

 look on web2pyslices 

 http://www.web2pyslices.com/slice/show/1714/jqgrid-viewing-and-updating-data




-- 
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/groups/opt_out.


[web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?

2013-10-07 Thread Py Dev
Hi Simon, 

thanks for your quick answer! There is some progess, an other error 
message: :-)

Error Message:

Traceback *(*most recent call last*):*

*  *File 
/Users/myname/PycharmProjects/DataBaseExamples/web2py/gluon/restricted.py*, 
*line 217*, **in *restricted

*exec *ccode *in *environment

  File 
/Users/myname/PycharmProjects/DataBaseExamples/web2py/applications/DataBaseExamples/controllers/jeditable.pyhttp://127.0.0.1:8000/admin/default/edit/DataBaseExamples/controllers/jeditable.py
*, *line 19*, **in ***module**

*  *File 
/Users/myname/PycharmProjects/DataBaseExamples/web2py/gluon/globals.py*, 
*line 
371*, **in lambda***

***self**.*_caller *= **lambda *f*: *f*()*

*  *File 
/Users/myname/PycharmProjects/DataBaseExamples/web2py/applications/DataBaseExamples/controllers/jeditable.pyhttp://127.0.0.1:8000/admin/default/edit/DataBaseExamples/controllers/jeditable.py
*, *

line 14*, **in *upd_dog_name

id*,*column *= *request*.*post_vars*.*id*.*split*(*'.'*) **#'NoneType' 
object has no attribute 'split'*

AttributeError*: *'NoneType' object has no attribute 'split'

---

Did you take the code from a working example?

Thanks for your help!

pd

Am Sonntag, 6. Oktober 2013 03:55:50 UTC+2 schrieb Simon Ashley:

 Just remark out/ delete the truncate fleas line.
 If the 'upd_dog_name' function is not called, check installation and 
 calling of jeditable



-- 
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/groups/opt_out.


[web2py] Re: Unsuccessful password reset

2013-10-07 Thread lesssugar
Here's the code of mailing/pass_reset.html:

{{extend 'mailing/template.html'}}

tr
td bgcolor=#ff style=padding: 40px 30px 40px 30px;
table border=0 cellpadding=0 cellspacing=0 width=100%
tbody
tr
td style=color: #00; font-family: Arial, 
sans-serif; font-size: 20px;
bYour requested pasword reset/b
/td
/tr
tr
td style=padding: 20px 0 30px 0; color: #33; 
font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
Click the link below to continue:
/td
/tr
tr
td style=padding: 20px 0 30px 0; color: #33; 
font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
{{=link}}
/td
/tr
tr
td style=padding: 10px 0 20px 0; color: #66; 
font: italic 14px Georgia,serif; line-height: 22px;
MR Team
/td
/tr
/tbody
/table
/td
/tr

The view extends mailing/template.html but I used the temaplate for other 
mailings which work correct, so I guess the template is not a problem.


On Monday, October 7, 2013 3:29:20 PM UTC+2, Massimo Di Pierro wrote:

 Sorry. Now I understand better what you are trying to do. Your invalid 
 character must be in mailing/pass_reset.html. Can you show us that file?

 On Monday, 7 October 2013 04:17:53 UTC-5, lesssugar wrote:

 Your problem does not come from the code you show us


 When I comment this piece of code *(A)*:
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 - password reset works with no errors.

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


 What do you mean? This code is directly copied from the book. E.g. when I 
 do this *(B)*, the reset works as well:

 auth.messages.reset_password = 'Click on link http://'+ 
 request.env.http_host + URL('default', 'user', args=['reset_password']) + 
 '/%(key)s to reset your password'

 When I go with the earlier code *(A)*, it fails.

 Anyway, I'll keep digging. Thanks for help and suggestions.

  


 On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem does 
 not come from the code you show us. 

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved but this is not the cause of the (0x22) problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. It's 
 getting a little bit frustrating as I'm not sure where to look for the bug.

 On Thursday, October 3, 2013 1:22:50 AM UTC+2, Massimo Di Pierro wrote:

 What is this supposed to do?

 {{=XML('%(key)s')}}

 Are you sure you are not looking for:

 a href={{=URL('default','user', args=('reset_password',key), 
 scheme=True, host=True)}} Go to password reset/a

 Is key a variable?
 Anyway, I am not sure your problem comes from this code.

 On Wednesday, 2 October 2013 08:14:17 UTC-5, lesssugar wrote:

 Sorry, Massimo, but I really don't get it. Is the slash causing the 
 problem? I use '[controller_name]/[view_name.html]' to render other 
 emails 
 and it's all ok.

 I even tried to do it this way in the mailing view:

 a href={{=URL('default','user', args='reset_password', 
 scheme=True, host=True)}}/{{=XML('%(key)s')}} Go to password reset
 /a

 - and nothing, still the same error. I would be grateful for another 
 hint, if there is one.


 On Tuesday, October 1, 2013 10:31:23 PM UTC+2, Massimo Di Pierro 
 wrote:

 You probably have same strange character in 
 'mailing/pass_reset.html'

 On Tuesday, 1 October 2013 13:26:46 UTC-5, lesssugar wrote:

 I'm trying to send a custom email template to user when they 
 perform password reset:

 *db.py:*

 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 

[web2py] Re: Unsuccessful password reset

2013-10-07 Thread Massimo Di Pierro


On Monday, 7 October 2013 09:04:07 UTC-5, lesssugar wrote:

 Here's the code of mailing/pass_reset.html:

 {{extend 'mailing/template.html'}}

 tr
 td bgcolor=#ff style=padding: 40px 30px 40px 30px;
 table border=0 cellpadding=0 cellspacing=0 width=100%
 tbody
 tr
 td style=color: #00; font-family: Arial, 
 sans-serif; font-size: 20px;
 bYour requested password reset/b
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 Click the link below to continue:
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 {{=link}}
 /td
 /tr
 tr
 td style=padding: 10px 0 20px 0; color: #66; 
 font: italic 14px Georgia,serif; line-height: 22px;
 MR Team
 /td
 /tr
 /tbody
 /table
 /td
 /tr

 The view extends mailing/template.html but I used the temaplate for other 
 mailings which work correct, so I guess the template is not a problem.


 On Monday, October 7, 2013 3:29:20 PM UTC+2, Massimo Di Pierro wrote:

 Sorry. Now I understand better what you are trying to do. Your invalid 
 character must be in mailing/pass_reset.html. Can you show us that file?

 On Monday, 7 October 2013 04:17:53 UTC-5, lesssugar wrote:

 Your problem does not come from the code you show us


 When I comment this piece of code *(A)*:
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 - password reset works with no errors.

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


 What do you mean? This code is directly copied from the book. E.g. when 
 I do this *(B)*, the reset works as well:

 auth.messages.reset_password = 'Click on link http://'+ 
 request.env.http_host + URL('default', 'user', args=['reset_password']) + 
 '/%(key)s to reset your password'

 When I go with the earlier code *(A)*, it fails.

 Anyway, I'll keep digging. Thanks for help and suggestions.

  


 On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem does 
 not come from the code you show us. 

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved but this is not the cause of the (0x22) problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. It's 
 getting a little bit frustrating as I'm not sure where to look for the 
 bug.

 On Thursday, October 3, 2013 1:22:50 AM UTC+2, Massimo Di Pierro wrote:

 What is this supposed to do?

 {{=XML('%(key)s')}}

 Are you sure you are not looking for:

 a href={{=URL('default','user', args=('reset_password',key), 
 scheme=True, host=True)}} Go to password reset/a

 Is key a variable?
 Anyway, I am not sure your problem comes from this code.

 On Wednesday, 2 October 2013 08:14:17 UTC-5, lesssugar wrote:

 Sorry, Massimo, but I really don't get it. Is the slash causing the 
 problem? I use '[controller_name]/[view_name.html]' to render other 
 emails 
 and it's all ok.

 I even tried to do it this way in the mailing view:

 a href={{=URL('default','user', args='reset_password', 
 scheme=True, host=True)}}/{{=XML('%(key)s')}} Go to password reset
 /a

 - and nothing, still the same error. I would be grateful for another 
 hint, if there is one.


 On Tuesday, October 1, 2013 10:31:23 PM UTC+2, Massimo Di Pierro 
 wrote:

 You probably have same strange character in 
 'mailing/pass_reset.html'

 On Tuesday, 1 October 2013 13:26:46 UTC-5, lesssugar wrote:

 I'm trying to send a custom email template to user when they 
 perform password reset:

 

[web2py] Re: Unsuccessful password reset

2013-10-07 Thread Massimo Di Pierro
This is the problem:

table border=0 cellpadding=0 cellspacing=0 width=100%

Notice you are extending mailing/template.html and you may have more 
similar problems there.

This is subtle. auth.messages.reset_password is supposed to be a string 
with placeholders like %(key)s. Internally the placeholders are replaced 
using 

   message = auth.messages.reset_password % dict(key=)

You generate auth.messages.reset_password using response.render and your 
template include % and perhaps other % symbols. So when web2py does

   message = auth.messages.reset_password % dict(key=)

it expects % to be an escape symbol for a placeholder but % is an invalid 
placeholder.
So what do you do? You must replace all % which are not placeholders with 
%%. This can be automated:

1) define:

def fixit(text):
import re
return re.compile('(\%)[^(]').sub('%%',text)

2) In your code define:

auth.messages.reset_password = fixit(response.render())

et voila'.

Massimo

On Monday, 7 October 2013 09:29:08 UTC-5, Massimo Di Pierro wrote:



 On Monday, 7 October 2013 09:04:07 UTC-5, lesssugar wrote:

 Here's the code of mailing/pass_reset.html:

 {{extend 'mailing/template.html'}}

 tr
 td bgcolor=#ff style=padding: 40px 30px 40px 30px;
 table border=0 cellpadding=0 cellspacing=0 width=100%
 tbody
 tr
 td style=color: #00; font-family: Arial, 
 sans-serif; font-size: 20px;
 bYour requested password reset/b
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 Click the link below to continue:
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 {{=link}}
 /td
 /tr
 tr
 td style=padding: 10px 0 20px 0; color: #66; 
 font: italic 14px Georgia,serif; line-height: 22px;
 MR Team
 /td
 /tr
 /tbody
 /table
 /td
 /tr

 The view extends mailing/template.html but I used the temaplate for other 
 mailings which work correct, so I guess the template is not a problem.


 On Monday, October 7, 2013 3:29:20 PM UTC+2, Massimo Di Pierro wrote:

 Sorry. Now I understand better what you are trying to do. Your invalid 
 character must be in mailing/pass_reset.html. Can you show us that file?

 On Monday, 7 October 2013 04:17:53 UTC-5, lesssugar wrote:

 Your problem does not come from the code you show us


 When I comment this piece of code *(A)*:
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 - password reset works with no errors.

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


 What do you mean? This code is directly copied from the book. E.g. when 
 I do this *(B)*, the reset works as well:

 auth.messages.reset_password = 'Click on link http://'+ 
 request.env.http_host + URL('default', 'user', args=['reset_password']) + 
 '/%(key)s to reset your password'

 When I go with the earlier code *(A)*, it fails.

 Anyway, I'll keep digging. Thanks for help and suggestions.

  


 On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem 
 does not come from the code you show us. 

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved but this is not the cause of the (0x22) problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. It's 
 getting a little bit frustrating as I'm not sure where to look for the 
 bug.

 On Thursday, October 3, 2013 1:22:50 AM UTC+2, Massimo Di Pierro 
 wrote:

 What is this supposed to do?

 

[web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?

2013-10-07 Thread Py Dev
 

Hi Simon, 

I just found the problem:

The line:

  script src={{=URL('static','js/jquery.jeditable.js')}}/script

has to be inserted after(!)   

{{include 'web2py_ajax.html'}}

which adds jquery.js


Changing that, first my inline changes were reverted, but when I adapted 
the location 

in the line

jQuery('.dog_name').editable({{=URL('jeditable', 'upd_dog_name')}},{

to my location of „*upd_dog_name“* now it works perfect!


Thank you very much for this wonderful example: I learned a lot with it, 
especially how to pass data from web2py/python to javascript and back. 

And this inline-editing is very useful too :-) 

This should be integrated into web2py and/or the quick examples!

Do you have more examples of this kind? :-)

Excellent! Perfect! 10 of 10 stars! Thanks a lot!

pd

-- 
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/groups/opt_out.


[web2py] Re: Custom Style of a textarea.

2013-10-07 Thread Anthony
There are multiple ways to handle this, including Javascript on the client 
side, manipulation of form.custom.widget, the web2py server-side DOM, and 
custom widgets. Note, when adding a class to an existing element on the 
server side, you can use the .add_class method, which intelligently handles 
cases where there is already an existing class.

At the form level, you can use the server-side DOM:

form.elements('textarea', replace=lambda el: el.add_class('form-control'))

The above affects only this particular form.

Another option is to create a custom widget, which works at the table level 
and therefore affects all forms based on the table:

def text_widget(field, value, text_class='form-control'):
return SQLFORM.widgets.text.widget(field, value).add_class(text_class)

db.define_table('mytable',
Field('myfield', 'text', widget=text_widget))

Finally, you could monkey patch the text widget directly, which would 
affect all text fields in all tables:

SQLFORM.widgets.text._class = 'text form-control'

Anthony

On Monday, October 7, 2013 6:32:53 AM UTC-4, Ykä Marjanen wrote:

 Glad to help back, as I've gotten so much help from here.

 If you like to have a more generic code to add your classes to the form 
 objects, you can use the code below. It will add a new class to all 
 elements while keeping the web2py classes. I think you could even add this 
 to the layout with try-statement, so anytime you use any form, it would 
 include new classes.

 !-- Additing bootstrap 3 classes to web2py form--
 {{for element in form.elements():}}
 {{if element['_class']:}}
 {{element['_class'] = str(element['_class']) +  form-control}}
 {{else:}}
 {{element['_class'] = 'form-control'}}
 {{pass}}
 {{pass}}

 Ykä

 On Sunday, October 6, 2013 10:31:19 PM UTC+3, Francisco García wrote:

 Hello Ykä and Paolo,

 Your answers are very useful for me. The problem is solved.
 All I needed was this sentence:

 form.custom.widget.FIELD['_class'] = 'text myclass'}

 Thank you for your fast answer.
 Regards.


 El sábado, 5 de octubre de 2013 09:24:59 UTC+2, Ykä Marjanen escribió:

 Hi Francisco,

 happy to help you, as I've gone a 4 day intensive bootstrap 3 
 integration to web2py and learned a lot about customizing the views and 
 forms. This might not be the best (or only) solution, but has worked well 
 for me:

 - Web2py form includes classes based on their type, which I recommend to 
 keep, if you want any added web2py functionality.
 - You need to use custom form style (form.custom.begin) and then 
 manipulate each widget separately (or all of them in a for loop)

 Here's my form code in a view (controller is not modified). In this form 
 I have added form-control class of bootstrap 3 and kept the original 
 class as well. For textarea you can do 
 form.custom.widget.textfield['_rows'] = 3 if you want to make a smaller 
 textarea.

 
 form action= enctype=multipart/form-data method=post role=form
 div class=form-group
 {{form.custom.widget.campaign['_class'] = 
 'generic-widget form-control'}}
 {{form.custom.widget.topic['_class'] = 'string 
 form-control'}}
 {{form.custom.widget.topic['_placeholder'] = 'Idea 
 topic'}}
 {{form.custom.widget.description['_class'] = 'text 
 form-control'}}
 {{form.custom.widget.description['_placeholder'] = 
 'Idea description'}}
 div class=form-group
 label for=exampleSelectSelect a 
 campaign/label
 {{=form.custom.widget.campaign}}
 /div
 div class=form-group
 label for=exampleInputTopicInput idea topic 
 and description/label
 {{=form.custom.widget.topic}}
 /div
 div class=form-group
 {{=form.custom.widget.description}}
 /div
 button type=submit class=btn btn-primarySubmit 
 your idea/button
 /div
 {{=form.custom.end}}

 

 Ykä

 On Friday, October 4, 2013 8:14:33 PM UTC+3, Francisco García wrote:

 Hello all,

 I am loading a form from a database table, with CRUD or SQLFORM (It is 
 the same for me).
 This form contains text fields and textarea fields between others.

 Now, I need to change in the views the class of all textareas,  from 
 class=text  to class=myclass
 How can I do this from controllers or views?   (I can't edit any css 
 file).

 I am trying with form.custom.widget  but I can't change it.
 I'm not sure if it is something simple, or it is impossible to do this 
 way.


 Thank you in advance.
 Regards,
 Francisco



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

[web2py] Re: Unsuccessful password reset

2013-10-07 Thread lesssugar
Worked - like - charm.

:)

On Monday, October 7, 2013 4:37:02 PM UTC+2, Massimo Di Pierro wrote:

 This is the problem:

 table border=0 cellpadding=0 cellspacing=0 width=100%

 Notice you are extending mailing/template.html and you may have more 
 similar problems there.

 This is subtle. auth.messages.reset_password is supposed to be a string 
 with placeholders like %(key)s. Internally the placeholders are replaced 
 using 

message = auth.messages.reset_password % dict(key=)

 You generate auth.messages.reset_password using response.render and your 
 template include % and perhaps other % symbols. So when web2py does

message = auth.messages.reset_password % dict(key=)

 it expects % to be an escape symbol for a placeholder but % is an invalid 
 placeholder.
 So what do you do? You must replace all % which are not placeholders with 
 %%. This can be automated:

 1) define:

 def fixit(text):
 import re
 return re.compile('(\%)[^(]').sub('%%',text)

 2) In your code define:

 auth.messages.reset_password = fixit(response.render())

 et voila'.

 Massimo

 On Monday, 7 October 2013 09:29:08 UTC-5, Massimo Di Pierro wrote:



 On Monday, 7 October 2013 09:04:07 UTC-5, lesssugar wrote:

 Here's the code of mailing/pass_reset.html:

 {{extend 'mailing/template.html'}}

 tr
 td bgcolor=#ff style=padding: 40px 30px 40px 30px;
 table border=0 cellpadding=0 cellspacing=0 width=100%
 tbody
 tr
 td style=color: #00; font-family: Arial, 
 sans-serif; font-size: 20px;
 bYour requested password reset/b
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 Click the link below to continue:
 /td
 /tr
 tr
 td style=padding: 20px 0 30px 0; color: #33; 
 font-family: Arial, sans-serif; font-size: 14px; line-height: 22px;
 {{=link}}
 /td
 /tr
 tr
 td style=padding: 10px 0 20px 0; color: #66; 
 font: italic 14px Georgia,serif; line-height: 22px;
 MR Team
 /td
 /tr
 /tbody
 /table
 /td
 /tr

 The view extends mailing/template.html but I used the temaplate for 
 other mailings which work correct, so I guess the template is not a problem.


 On Monday, October 7, 2013 3:29:20 PM UTC+2, Massimo Di Pierro wrote:

 Sorry. Now I understand better what you are trying to do. Your invalid 
 character must be in mailing/pass_reset.html. Can you show us that 
 file?

 On Monday, 7 October 2013 04:17:53 UTC-5, lesssugar wrote:

 Your problem does not come from the code you show us


 When I comment this piece of code *(A)*:
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 'user', 
 args=['reset_password'])+'/%(key)s'))

 - password reset works with no errors.

 The code you are showing is wrong because your link contains %(key)s 
 which is unresolved


 What do you mean? This code is directly copied from the book. E.g. 
 when I do this *(B)*, the reset works as well:

 auth.messages.reset_password = 'Click on link http://'+ 
 request.env.http_host + URL('default', 'user', args=['reset_password']) + 
 '/%(key)s to reset your password'

 When I go with the earlier code *(A)*, it fails.

 Anyway, I'll keep digging. Thanks for help and suggestions.

  


 On Monday, October 7, 2013 4:36:22 AM UTC+2, Massimo Di Pierro wrote:

 I cannot help you without looking at the entire code. Your problem 
 does not come from the code you show us. 

 The code you are showing is wrong because your link contains 
 %(key)s which is unresolved but this is not the cause of the (0x22) 
 problem.


 On Sunday, 6 October 2013 11:53:27 UTC-5, lesssugar wrote:

 Massimo (or anyone willing to help),

 all I'm trying to achieve is use my own email template to send a 
 password-reset message to user. How do I do this properly?

 Currently, I have this

 *db.py*
 auth.messages.reset_password = response.render(
 'mailing/pass_reset.html',
 dict(subject='Password reset',
 link = 'http://'+request.env.http_host+URL('default', 
 'user', args=['reset_password'])+'/%(key)s'))

 *pass_reset.html*
 ...
 tr
 td style=padding: 20px 0 30px 0; color: #33; font-family: 
 Arial, sans-serif; font-size: 14px; line-height: 22px;
 *{{=link}}*
 /td
 /tr
 ...

 I constantly get unsupported format character error. The character 
 (0x22) is ASCII quotation mark: **. I don't see it in my code. 
 It's getting a little bit frustrating as I'm not sure where to look for 
 the 
 

[web2py] How to create Testimonials page using web2py?

2013-10-07 Thread Jayakumar Bellie
Hi,

Have anyone created a testimonial page using web2py?

-- 
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/groups/opt_out.


[web2py] Re: HTML error code 206, due to headers not set

2013-10-07 Thread Jayakumar Bellie
I have also found if there is good internet speed, this problem does not 
occur. It works fine with 8 Mbps connection.

On Monday, October 7, 2013 11:15:43 AM UTC+5:30, Jayakumar Bellie wrote:

 I created a new application and just added 

 {{=response.toolbar()}} 

 In my view and check for my response is

 headers:X-Powered-By:web2pylogo:*web2py*™  http://www.web2py.com/
 On Saturday, October 5, 2013 8:12:21 AM UTC+5:30, Massimo Di Pierro wrote:

 This is where the 206 status is set and looks to me the headers are set. 
 Can anybody reproduce the problem?
 Can you show us the controller?

 On Friday, 4 October 2013 14:16:04 UTC-5, Niphlod wrote:

 if you get back only that header, something is wrong with your setup. 
 web2py adds a bunch of standard headers on every response.
 https://github.com/web2py/web2py/blob/master/gluon/main.py#L209

 On Friday, October 4, 2013 9:12:22 AM UTC+2, Jayakumar Bellie wrote:

 Hi,
 When my application loads, it does not load the js files fully. I found 
 it loads then partially, 
 due to this application is not at all usable.

 I found that application has only one header

 {'X-Powered-By': 'web2py'}

 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html  10.2.7 206 
 Partial Content
 says adding content type and content length will solve the issue.
 How to add then in web2py
 It is possible to add content type. 
 How about content length?
 Will this solve my 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/groups/opt_out.


Re: [web2py] Re: How to serve multiple domains and multiple applications on nginx using pattern-based route

2013-10-07 Thread Tito Garrido
This route didn't work for me...
routes_in = ((
(('.*http://demo.ivinh.com.* /*', '/demo')),
 (('.*http://demo1.ivinh.com.* /*', '/demo1'))
))

Not sure it is because I am using uwsgi... it keeps going to the default
website...




On Sat, Oct 5, 2013 at 4:30 PM, Tito Garrido titogarr...@gmail.com wrote:

 Thanks!!! I will try!


 On Fri, Oct 4, 2013 at 11:32 PM, IVINH toa...@gmail.com wrote:


 Nginx config:


 server {
  listen 80;
 server_name demo.ivinh.com www.demo.ivinh.com;
  include deny_admin.txt;
 access_log logs/demo.ivinh.com.access.log;
  error_log logs/demo.ivinh.com.error.log;
 location / {
 proxy_pass http://127.0.0.1:86;
  proxy_set_header Host demo.ivinh.com;
 include proxy.conf;
  }}
  server {
 listen 80;
  server_name demo1.ivinh.com www.demo1.ivinh.com;
  include deny_admin.txt;
 access_log logs/demo1.ivinh.com.access.log;
  error_log logs/demo1.ivinh.com.error.log;
 location / {
 proxy_pass http://127.0.0.1:86;
  proxy_set_header Host demo1.ivinh.com;
 include proxy.conf;
  }}


 Web2py routes.py run at 127.0.0.1 port 86:


 routes_in = ((
 (('.*http://demo.ivinh.com.* /*', '/demo')),
  (('.*http://demo1.ivinh.com.* /*', '/demo1'))
 ))





 Vào 06:43:07 UTC+7 Thứ bảy, ngày 05 tháng mười năm 2013, Tito Garrido đã
 viết:

 Hi Folks,

 I am using the default setup from the book for nginx:

 scripts/setup-web2py-nginx-**uwsgi-ubuntu.sh

 And my routes are using *pattern-based* system.

 The question is, how can I route www.domain1.com to app1 and
 www.domain2.com to app2?

 nginx config in sites-enabled:

 *server {
 listen  80;
 server_name $hostname;
 ###to enable correct use of response.static_version
 location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
 alias /home/www-data/web2py/applications/$1/static/$2;
 expires max;
 }
 ###

 ###if you use something like myapp = dict(languages=[en, it,
 jp], default_language=en) in your routes.py
 #location ~* ^/(\w+)/(en|it|jp)/static/(.*)$ {
 #alias /home/www-data/web2py/applications/$1/;
 #try_files static/$2/$3 static/$3 =404;
 #}
 ###
 location ~* ^/(\w+)/static/ {
 root /home/www-data/web2py/applications/;
 #remove next comment on production
 expires max;
 ### if you want to use pre-gzipped static files (recommended)
 ### check scripts/zip_static_files.py and remove the comments
 include /etc/nginx/conf.d/web2py/gzip_static.conf;
 ###
 }
 location / {
 #uwsgi_pass  127.0.0.1:9001;
 uwsgi_pass  unix:///tmp/web2py.socket;
 include uwsgi_params;
 uwsgi_param UWSGI_SCHEME $scheme;
 uwsgi_param SERVER_SOFTWAREnginx/$nginx_version;

 ###remove the comments to turn on if you want gzip
 compression of your pages
 include /etc/nginx/conf.d/web2py/gzip.conf;
 ### end gzip section

 ### remove the comments if you use uploads (max 10 MB)
 #client_max_body_size 10m;
 ###
 }
 }*

 Thanks in advance!

 Tito
 --

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

  --
 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/groups/opt_out.




 --

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




-- 

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

-- 
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/groups/opt_out.


[web2py] Re: IMAP: Insert email to Sent folder

2013-10-07 Thread Alan Etkin


 to attach a ms-excel file, but the attachment (was successfully inserted) 
 in draft  is not correct data. Can you help me?


It seems you have to supply the attachment data encoding also. Try somehing 
like:

... .append({..., encoding: encoding})

-- 
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/groups/opt_out.


Re: [web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?

2013-10-07 Thread Adnan Smajlovic
Simon,
Thank you for this. Very helpful, and just implemented it in one of my
grids! Also checked Kendoui. Looks very nice.


On Mon, Oct 7, 2013 at 10:50 AM, Py Dev py...@weblern.com wrote:

 Hi Simon,

 I just found the problem:

 The line:

   script src={{=URL('static','js/jquery.jeditable.js')}}/script

 has to be inserted after(!)

 {{include 'web2py_ajax.html'}}

 which adds jquery.js


 Changing that, first my inline changes were reverted, but when I adapted
 the location

 in the line

 jQuery('.dog_name').editable({{=URL('jeditable', 'upd_dog_name')}},{

 to my location of „*upd_dog_name“* now it works perfect!


 Thank you very much for this wonderful example: I learned a lot with it,
 especially how to pass data from web2py/python to javascript and back.

 And this inline-editing is very useful too :-)

 This should be integrated into web2py and/or the quick examples!

 Do you have more examples of this kind? :-)

 Excellent! Perfect! 10 of 10 stars! Thanks a lot!

 pd

 --
 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/groups/opt_out.


-- 
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/groups/opt_out.


[web2py] Re: Web2py admin crashes

2013-10-07 Thread Dave S
On Friday, October 4, 2013 7:26:45 PM UTC-7, Massimo Di Pierro wrote:

 I did not hear this before. What is the problem with the update button. 
 Can you explain it in more detail? What are you upgrading from and to?


From: 2.5.1-stable+timestamp.2013.06.06.15.39.19
To: 2.6.4 (don't have the timestamp)
After:  2.6.4-stable+timestamp.2013.09.22.01.43.37

Using the update button broke the admin interface due to the import 
Config error; this turned out to be that pretty much the whole gluon 
directory was still old code, but top level code (and the welcome app) had 
been updated.  I think the scripts directory (deployment stuff) also was 
old code.  As in the posts in the 2.6.1 thread, downloading the source and 
unzipping was the answer (I didn't unzip in place; I used Beyond Compare so 
that I could see what was what, but then didn't take enough detailed notes 
for good reporting).

My first thought was that I had missed something in the list of stuff that 
All Users needed to copy, but that list was pretty short, so I went back 
to the older threads and got the clue to look at the unzipping. My 
application, outside of the admin part, seemed to be running ok:  a couple 
of html pages displaying some values from my tables, and some SOAP service 
functions that added to the tables.  I have a simple set up:  installed 
Web2Py with Rocket and Sqlite 3, and have stuck with those pieces.

HTH; if you prod me, I may be able to remember answers to specific 
questions.

/dps





 

 On Friday, 4 October 2013 14:57:32 UTC-5, Dave S wrote:

 On Thursday, October 3, 2013 10:51:37 AM UTC-7, Dave S wrote:


 On Thursday, October 3, 2013 8:28:52 AM UTC-7, Joe Magaro wrote:

 Hi, 

 All was working well, until today I went and clicked administrative 
 interface for my site, and it issues a ticket.

 Internal errorTicket issued: 
 admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1https://www.wordgurgle.com/admin/default/ticket/admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1

 When I click to view the ticket, it crashes and issues another ticket. 
 I checked the http logs, but cant seem to find anything of importance. Can 
 some one give me the next step to help solve this issue?


 Can you read the tickets from a local shell?

 less Web2pyDir/applications/admin/errors/*



 I just did the upgrade, and it looks like my services are running ok, 
 but I get a cannot import name Config, which I think means I missed 
 copying one of the files from the welcome app or something.  Private server 
 running web2py+rocket.



 Basically, the update button is still having problems updating the gluon 
 files.  (This is mentioned in the followups in the 2.6.1 announcement 
 thread, a useful resource.)

 Download the source zip, and copy the gluon, handlers, and so forth into 
 your installation.

 /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/groups/opt_out.


[web2py] Re: what is web2py ??

2013-10-07 Thread Dave S


On Sunday, October 6, 2013 5:41:37 AM UTC-7, Tim Richardson wrote:



 On Sunday, 6 October 2013 15:35:33 UTC+11, Massimo Di Pierro wrote:

 Saying you want to use cgi with Python is a little like saying you want 
 to use a bicycle with a jet engine. 


 Actually, that sounds like fun. http://www.youtube.com/watch?v=ByemtRt_CP0

 Perhaps like using a car powered by a horse. 

 (passing that link on ...)


http://www.horsenation.com/wp-content/uploads/2013/04/one-horse-power-car.jpg

/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/groups/opt_out.


[web2py] oauth2 login with google

2013-10-07 Thread ssuresh
I am trying to integrate google login into web2py(without using janrain). I 
could see examples of oauth login using facebook and linkedin  but not 
google.   Can someone please point to on how to get started..

-- 
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/groups/opt_out.


Re: [web2py] Re: capturing the text value of a clicked link using python

2013-10-07 Thread Vinicius Assef
Or you can use brython: www.brython.info ;-)

On Mon, Oct 7, 2013 at 10:24 AM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 You cannot do this with Python. you need to do this with JS:

 !DOCTYPE html
 html lang='EN'
 head
 titleTesting /title
 /head
 body
 h1Medicinal Plant List/h1
 script
onclick = function(){ var t=jQuery(this).attr(href); alert(t); }
 /script
 a href=http://www.google.com; name=My Link onclick=onclick()My
 Link/a
 /body
 /html


 On Sunday, 6 October 2013 11:35:01 UTC-5, Remya R G wrote:


 --
 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/groups/opt_out.

-- 
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/groups/opt_out.


Re: [web2py] oauth2 login with google

2013-10-07 Thread Michele Comitini
The trick is always the same extend OAuthAccount get_user() to return
(first_name, last_name ... ).

If you want to use the code below, after registering your app on google,
save the json credentials in your app/private/google_auth.json

### code
###
from gluon.contrib.login_methods.oauth20_account import OAuthAccount

try:
import json
except ImportError:
from gluon.contrib import simplejson as json


class GoogleAccount(OAuthAccount):
OAuth 2.0 for Google

def __init__(self):
with open(os.path.join(request.folder, 'private/google_auth.json'),
'rb') as f:
gai = Storage(json.load(f)['web'])

OAuthAccount.__init__(self, None, gai.client_id, gai.client_secret,
  gai.auth_uri, gai.token_uri,
  scope='
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email',
  approval_prompt='force',
state=auth_provider=google)

def get_user(self):

token = self.accessToken()
if not token:
return None

uinfo_url = '
https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' %
urllib2.quote(token, safe='')

uinfo = None

try:
uinfo_stream = urllib2.urlopen(uinfo_url)
except:
session.token = None
return
data = uinfo_stream.read()
uinfo = json.loads(data)

username = uinfo['id']

return dict(first_name = uinfo['given_name'],
last_name = uinfo['family_name'],
username = username,
email = uinfo['email'])



2013/10/7 ssuresh sureshsarka...@gmail.com

 I am trying to integrate google login into web2py(without using janrain).
 I could see examples of oauth login using facebook and linkedin  but not
 google.   Can someone please point to on how to get started..

 --
 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/groups/opt_out.


-- 
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/groups/opt_out.


[web2py] Re: Modifying routes.example.py to routes.py

2013-10-07 Thread dhmorgan
the old routes.example.py that was in the root web2py directory is now in 
web2py/examples and is named routes.pattern.example.py

On Monday, October 7, 2013 5:20:24 AM UTC-5, Bedour Alshaigy wrote:

 Good morning everyone,

 I am a new web2py user. I am trying to modify  routes.example.py to 
 routes.py (to make one of my apps the default apps), however the only file 
 I can find with that name is in the welcome folder (attached), and when I 
 open it it looks like this (attached). Is this the right file, and should I 
 make a copy and call it routes.py and post it inside the applications 
 folder or in the web2py folder? Many 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/groups/opt_out.


[web2py] Re: Web2py admin crashes

2013-10-07 Thread Niphlod
btw: isn't this a simple problem of someone caching too much 
http://www.web2py.com/examples/static/web2py_src.zip ?!?

On Monday, October 7, 2013 7:32:41 PM UTC+2, Dave S wrote:

 On Friday, October 4, 2013 7:26:45 PM UTC-7, Massimo Di Pierro wrote:

 I did not hear this before. What is the problem with the update button. 
 Can you explain it in more detail? What are you upgrading from and to?


 From: 2.5.1-stable+timestamp.2013.06.06.15.39.19
 To: 2.6.4 (don't have the timestamp)
 After:  2.6.4-stable+timestamp.2013.09.22.01.43.37

 Using the update button broke the admin interface due to the import 
 Config error; this turned out to be that pretty much the whole gluon 
 directory was still old code, but top level code (and the welcome app) had 
 been updated.  I think the scripts directory (deployment stuff) also was 
 old code.  As in the posts in the 2.6.1 thread, downloading the source and 
 unzipping was the answer (I didn't unzip in place; I used Beyond Compare so 
 that I could see what was what, but then didn't take enough detailed notes 
 for good reporting).

 My first thought was that I had missed something in the list of stuff that 
 All Users needed to copy, but that list was pretty short, so I went back 
 to the older threads and got the clue to look at the unzipping. My 
 application, outside of the admin part, seemed to be running ok:  a couple 
 of html pages displaying some values from my tables, and some SOAP service 
 functions that added to the tables.  I have a simple set up:  installed 
 Web2Py with Rocket and Sqlite 3, and have stuck with those pieces.

 HTH; if you prod me, I may be able to remember answers to specific 
 questions.

 /dps





  

 On Friday, 4 October 2013 14:57:32 UTC-5, Dave S wrote:

 On Thursday, October 3, 2013 10:51:37 AM UTC-7, Dave S wrote:


 On Thursday, October 3, 2013 8:28:52 AM UTC-7, Joe Magaro wrote:

 Hi, 

 All was working well, until today I went and clicked administrative 
 interface for my site, and it issues a ticket.

 Internal errorTicket issued: 
 admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1https://www.wordgurgle.com/admin/default/ticket/admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1

 When I click to view the ticket, it crashes and issues another ticket. 
 I checked the http logs, but cant seem to find anything of importance. 
 Can 
 some one give me the next step to help solve this issue?


 Can you read the tickets from a local shell?

 less Web2pyDir/applications/admin/errors/*



 I just did the upgrade, and it looks like my services are running ok, 
 but I get a cannot import name Config, which I think means I missed 
 copying one of the files from the welcome app or something.  Private 
 server 
 running web2py+rocket.



 Basically, the update button is still having problems updating the gluon 
 files.  (This is mentioned in the followups in the 2.6.1 announcement 
 thread, a useful resource.)

 Download the source zip, and copy the gluon, handlers, and so forth into 
 your installation.

 /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/groups/opt_out.


[web2py] Re: How to create Testimonials page using web2py?

2013-10-07 Thread Massimo Di Pierro
What's a testimonial page?

On Monday, 7 October 2013 10:58:06 UTC-5, Jayakumar Bellie wrote:

 Hi,

 Have anyone created a testimonial page using web2py?


-- 
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/groups/opt_out.


Re: [web2py] chat-tornado in web2py using websocket_messaging.py

2013-10-07 Thread Junior Phanter
I'll try to help. It will be an honor for me.


2013/10/7 Massimo Di Pierro massimo.dipie...@gmail.com

 Can you help us find out why Tornado 31. does not work?


 On Sunday, 6 October 2013 21:24:29 UTC-5, Junior Phanter wrote:

 Sorry my bad english,

 Analyzing the web2py_websocket inside web2py.js. I noticed that when I
 used:

script
$(document).ready(function(){
   var data;
   
 web2py_websocket('ws://127.0.**0.1:/realtime/mygrouphttp://127.0.0.1:/realtime/mygroup',
 function(e){data=eval('('+e.**data+')')});
});
/script


 the browser console accused the web2py_websocket was not a function, so
 I changed the code to:

script
$(document).ready(function(){
   var data;
   
 $.web2py.web2py_websocket('ws:**//127.0.0.1:/realtime/**mygrouphttp://127.0.0.1:/realtime/mygroup',
 function(e){data=eval('('+e.**data+')')});
});
/script

 worked perfectly!


 I changed it to Tornado 3.0 (Tornado 3.1.1 not work) and web2py 2.7.1.


 2013/10/4 Junior Phanter junior...@gmail.com

 greetings ,
 sorry my bad english , I 'm trying to implement a chat using the tornado
 and websocket_messaging.py , but I'm having trouble hearing the tornado
 server . the server receives the tornado MESSAGES using :

 websocket_send ( ' http://127.0.0.1: ', ' Hello World ', ' mykey ',
 ' mygroup ' )

 but the script :
 --**--**-
script
$(document).ready(function(){
   var data;
   
 web2py_websocket('ws://127.0.**0.1:/realtime/mygrouphttp://127.0.0.1:/realtime/mygroup
 ',**function(e){data=eval('('+e.**data+')')});
});
/script
 --**--**
 -
 does not capture the listener .

 I tested the application that comes as an example within the
 websocket_messaging.py and neither worked .

 - exemplo dentro do websocket_messaging.py
 --

 Here is a complete sample web2py action:

 def index():
 form=LOAD('default','ajax_**form',ajax=True)
 script=SCRIPT('''
 jQuery(document).ready(**function(){
   var callback=function(e){alert(e.**data)};
   if(!web2py_websocket('ws://127**
 .0.0.1:/realtime/mygroup http://127.0.0.1:/realtime/mygroup',*
 *callback))
 alert(html5 websocket not supported by your browser,
 try Google Chrome);
 });
 ''')
 return dict(form=form, script=script)

 def ajax_form():
 form=SQLFORM.factory(Field('**message'))
 if form.accepts(request,session):
 from gluon.contrib.websocket_**messaging import
 websocket_send
 websocket_send(
 'http://127.0.0.1:',form.**
 vars.message,'mykey','mygroup'**)
 return form

 --**--**
 --**---



 I'm using the Tornado 2.1 and 2.6.4 web2py

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/**web2py 
 http://github.com/web2py/web2py(Source code)
 - 
 https://code.google.com/p/**web2py/issues/listhttps://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/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .


  --
 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/groups/opt_out.


-- 
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/groups/opt_out.


[web2py] want to Understanding web2py model by noob

2013-10-07 Thread Bapi Roy
I am from PHP with good knowledge of MVC. I am new to python and web2py.

In PHP model is made from class, does same apply to web2py model ?

Should I design the web2py model as i did in PHP or something I am missing.


-- 
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/groups/opt_out.


[web2py] Re: Tracking the date/time of a field change.

2013-10-07 Thread James Thompson
I thought default=request.now and update=request.net reflect changes in the 
record as a whole?
I'm looking for something that only updates when the value of the status 
field changes. 

On Monday, October 7, 2013 3:31:33 AM UTC-10, 黄祥 wrote:

 i think you can achieve it with default.
 e.g. 
 Field('f_status_change_dt', type='datetime',
   label=T('Status Change Dt')*, default=request.now*)

 or if you set auth.signature or record_versioning, web2py automatically do 
 that for you.

 ref:

 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning

 http://web2py.com/books/default/chapter/29/09/access-control#Record-versioning

 best regards,
 stifan


-- 
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/groups/opt_out.


[web2py] Re: Tracking the date/time of a field change.

2013-10-07 Thread Niphlod
why don't you use callbacks ? they are the most useful feature in DAL's in 
my POV.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks

On Monday, October 7, 2013 8:55:29 PM UTC+2, James Thompson wrote:

 I thought default=request.now and update=request.net reflect changes in 
 the record as a whole?
 I'm looking for something that only updates when the value of the status 
 field changes. 

 On Monday, October 7, 2013 3:31:33 AM UTC-10, 黄祥 wrote:

 i think you can achieve it with default.
 e.g. 
 Field('f_status_change_dt', type='datetime',
   label=T('Status Change Dt')*, default=request.now*)

 or if you set auth.signature or record_versioning, web2py automatically 
 do that for you.

 ref:

 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning

 http://web2py.com/books/default/chapter/29/09/access-control#Record-versioning

 best regards,
 stifan



-- 
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/groups/opt_out.


[web2py] Admin export as csv generates broken file under nginx

2013-10-07 Thread Vinicius Assef
Hi guys.

I'm experiencing a problem I think is not web2py fault, but uwsgi or
nginx configuration.

I'm running web2py inside a Vagrant box (Virtualbox) with nginx.

I have a table with more than 50k lines and when I try to export as
csv in admin, the generated file doesn't have all records. Each time
it generates a
different number of rows.


Reading logs, I found something:

in /var/log/nginx/error.log:
2013/10/07 20:25:15 [crit] 955#0: *291 open()
/var/lib/nginx/uwsgi/9/00/09 failed (13: Permission denied)
while reading upstream, client: 10.11.12.1, server: wsl, request: GET
/wsl/appadmin/csv/db?query=db.publicacao.id%3E0 HTTP/1.1, upstream:
uwsgi://unix:///tmp/web2py.socket:, host: 10.11.12.13, referrer:
https://10.11.12.13/wsl/appadmin/select/db?query=db.publicacao.id%3E0;


in /var/log/uwsgi/uwsgi.log:
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request
/wsl/appadmin/csv/db?query=db.publicacao.id%3E0 (ip 10.11.12.1) !!!
uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 296]
IOError: write error
[pid: 2168|app: 0|req: 53/153] 10.11.12.1 () {46 vars in 1015 bytes}
[Mon Oct  7 20:25:06 2013] GET
/wsl/appadmin/csv/db?query=db.publicacao.id%3E0 = generated 0 bytes
in 9064 msecs (HTTP/1.1 200) 7 headers in 371 bytes (4 switches on
core 0)
...The work of process 2168 is done. Seeya!
worker 4 killed successfully (pid: 2168)
Respawned uWSGI worker 4 (new pid: 2326)
mapping worker 4 to CPUs: 1




What is happening? It seems somehow the socket connection is being
lost. Do you have an idea to fix that?

BTW, I'm using webp2y v2.4.6 on Ubuntu 12.04 server and it was configured by
setup-web2py-nginx-uwsgi-ubuntu.sh distributed along with web2py.

My /etc/uwsgi/web2py.ini file is:
[uwsgi]
socket = /tmp/web2py.socket
pythonpath = /home/vagrant/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = vagrant
gid = vagrant
cron = 0 0 -1 -1 -1 python /home/vagrant/web2py/web2py.py -Q -S
welcome -M -R scripts/sessions2trash.py -A -o
no-orphans = true



Any help?

-- 
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/groups/opt_out.


Re: [web2py] want to Understanding web2py model by noob

2013-10-07 Thread Vinicius Assef
Actually, PHP doesn't have models. PHP Frameworks do.

But, answering your question, in web2py you don't need classes to
define your models. See in documentation [1].

[1] 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-representation



On Mon, Oct 7, 2013 at 11:39 AM, Bapi Roy askb...@gmail.com wrote:
 I am from PHP with good knowledge of MVC. I am new to python and web2py.

 In PHP model is made from class, does same apply to web2py model ?

 Should I design the web2py model as i did in PHP or something I am missing.


 --
 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/groups/opt_out.

-- 
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/groups/opt_out.


[web2py] Re: Admin export as csv generates broken file under nginx

2013-10-07 Thread Niphlod
did you try upping the memory limits ? 
limit-as, reload-on-as, reload-on-rss 


PS: dumping 50k records in a csv is definitely not something for a 
webserver (timeout, anyone ?) 

On Monday, October 7, 2013 10:46:34 PM UTC+2, viniciusban wrote:

 Hi guys. 

 I'm experiencing a problem I think is not web2py fault, but uwsgi or 
 nginx configuration. 

 I'm running web2py inside a Vagrant box (Virtualbox) with nginx. 

 I have a table with more than 50k lines and when I try to export as 
 csv in admin, the generated file doesn't have all records. Each time 
 it generates a 
 different number of rows. 


 Reading logs, I found something: 

 in /var/log/nginx/error.log: 
 2013/10/07 20:25:15 [crit] 955#0: *291 open() 
 /var/lib/nginx/uwsgi/9/00/09 failed (13: Permission denied) 
 while reading upstream, client: 10.11.12.1, server: wsl, request: GET 
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 HTTP/1.1, upstream: 
 uwsgi://unix:///tmp/web2py.socket:, host: 10.11.12.13, referrer: 
 https://10.11.12.13/wsl/appadmin/select/db?query=db.publicacao.id%3E0; 


 in /var/log/uwsgi/uwsgi.log: 
 SIGPIPE: writing to a closed pipe/socket/fd (probably the client 
 disconnected) on request 
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 (ip 10.11.12.1) !!! 
 uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 296] 
 IOError: write error 
 [pid: 2168|app: 0|req: 53/153] 10.11.12.1 () {46 vars in 1015 bytes} 
 [Mon Oct  7 20:25:06 2013] GET 
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 = generated 0 bytes 
 in 9064 msecs (HTTP/1.1 200) 7 headers in 371 bytes (4 switches on 
 core 0) 
 ...The work of process 2168 is done. Seeya! 
 worker 4 killed successfully (pid: 2168) 
 Respawned uWSGI worker 4 (new pid: 2326) 
 mapping worker 4 to CPUs: 1 




 What is happening? It seems somehow the socket connection is being 
 lost. Do you have an idea to fix that? 

 BTW, I'm using webp2y v2.4.6 on Ubuntu 12.04 server and it was configured 
 by 
 setup-web2py-nginx-uwsgi-ubuntu.sh distributed along with web2py. 

 My /etc/uwsgi/web2py.ini file is: 
 [uwsgi] 
 socket = /tmp/web2py.socket 
 pythonpath = /home/vagrant/web2py/ 
 mount = /=wsgihandler:application 
 processes = 4 
 master = true 
 harakiri = 60 
 reload-mercy = 8 
 cpu-affinity = 1 
 stats = /tmp/stats.socket 
 max-requests = 2000 
 limit-as = 512 
 reload-on-as = 256 
 reload-on-rss = 192 
 uid = vagrant 
 gid = vagrant 
 cron = 0 0 -1 -1 -1 python /home/vagrant/web2py/web2py.py -Q -S 
 welcome -M -R scripts/sessions2trash.py -A -o 
 no-orphans = true 



 Any help? 


-- 
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/groups/opt_out.


Re: [web2py] Re: Admin export as csv generates broken file under nginx

2013-10-07 Thread Michele Comitini
There is not enough information to say much.
if possible try to stream directly rather than buffering data first in a
variable, this should make things faster and lighter.


2013/10/7 Niphlod niph...@gmail.com

 did you try upping the memory limits ?
 limit-as, reload-on-as, reload-on-rss


 PS: dumping 50k records in a csv is definitely not something for a
 webserver (timeout, anyone ?)

 On Monday, October 7, 2013 10:46:34 PM UTC+2, viniciusban wrote:

 Hi guys.

 I'm experiencing a problem I think is not web2py fault, but uwsgi or
 nginx configuration.

 I'm running web2py inside a Vagrant box (Virtualbox) with nginx.

 I have a table with more than 50k lines and when I try to export as
 csv in admin, the generated file doesn't have all records. Each time
 it generates a
 different number of rows.


 Reading logs, I found something:

 in /var/log/nginx/error.log:
 2013/10/07 20:25:15 [crit] 955#0: *291 open()
 /var/lib/nginx/uwsgi/9/00/**09 failed (13: Permission denied)
 while reading upstream, client: 10.11.12.1, server: wsl, request: GET
 /wsl/appadmin/csv/db?query=db.**publicacao.id http://db.publicacao.id%3E0
 HTTP/1.1, upstream:
 uwsgi://unix:///tmp/web2py.**socket:, host: 10.11.12.13, referrer:
 https://10.11.12.13/wsl/**appadmin/select/db?query=db.**
 publicacao.id%3E0https://10.11.12.13/wsl/appadmin/select/db?query=db.publicacao.id%3E0



 in /var/log/uwsgi/uwsgi.log:
 SIGPIPE: writing to a closed pipe/socket/fd (probably the client
 disconnected) on request
 /wsl/appadmin/csv/db?query=db.**publicacao.id http://db.publicacao.id%3E0
 (ip 10.11.12.1) !!!
 uwsgi_response_write_body_do()**: Broken pipe [core/writer.c line 296]
 IOError: write error
 [pid: 2168|app: 0|req: 53/153] 10.11.12.1 () {46 vars in 1015 bytes}
 [Mon Oct  7 20:25:06 2013] GET
 /wsl/appadmin/csv/db?query=db.**publicacao.id http://db.publicacao.id%3E0
 = generated 0 bytes
 in 9064 msecs (HTTP/1.1 200) 7 headers in 371 bytes (4 switches on
 core 0)
 ...The work of process 2168 is done. Seeya!
 worker 4 killed successfully (pid: 2168)
 Respawned uWSGI worker 4 (new pid: 2326)
 mapping worker 4 to CPUs: 1




 What is happening? It seems somehow the socket connection is being
 lost. Do you have an idea to fix that?

 BTW, I'm using webp2y v2.4.6 on Ubuntu 12.04 server and it was configured
 by
 setup-web2py-nginx-uwsgi-**ubuntu.sh distributed along with web2py.

 My /etc/uwsgi/web2py.ini file is:
 [uwsgi]
 socket = /tmp/web2py.socket
 pythonpath = /home/vagrant/web2py/
 mount = /=wsgihandler:application
 processes = 4
 master = true
 harakiri = 60
 reload-mercy = 8
 cpu-affinity = 1
 stats = /tmp/stats.socket
 max-requests = 2000
 limit-as = 512
 reload-on-as = 256
 reload-on-rss = 192
 uid = vagrant
 gid = vagrant
 cron = 0 0 -1 -1 -1 python /home/vagrant/web2py/web2py.py -Q -S
 welcome -M -R scripts/sessions2trash.py -A -o
 no-orphans = true



 Any help?

  --
 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/groups/opt_out.


-- 
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/groups/opt_out.


[web2py] Re: want to Understanding web2py model by noob

2013-10-07 Thread Anthony
web2py does not have an ORM (object relational mapper), so you won't be 
creating classes to define models. Instead, web2py has a DAL (database 
abstraction layer). Different conceptualization/implementation, but mostly 
the same functionality as an ORM. Instead of defining classes, you create 
instances of the Table class to define data models (a Table object 
represents a database table or view). Read the book chapter on the DAL for 
more details: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer
.

Anthony

On Monday, October 7, 2013 10:39:36 AM UTC-4, Bapi Roy wrote:

 I am from PHP with good knowledge of MVC. I am new to python and web2py.

 In PHP model is made from class, does same apply to web2py model ?

 Should I design the web2py model as i did in PHP or something I am missing.




-- 
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/groups/opt_out.


[web2py] 'SQLFORM' object has no attribute 'error'

2013-10-07 Thread raferbop
# Model/db.py

db = DAL('sqlite://storage.sqlite')

db.define_table(
'person',
Field('name', requires=IS_NOT_EMPTY(error_message=auth.messages.is_empty
)),
Field('email', requires=IS_EMAIL(error_message=auth.messages.
invalid_email)),
Field('password', requires=[IS_STRONG(), CRYPT()]))

# Contoller/default.py 

def form_a():
form = SQLFORM(db.person)
if form.process(session=None).accepted:
response.flash = 'form accepted'
elif form.error:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)

# View

{{extend 'layout.html'}}
h1Register Now/h1

br /
{{=form}}
br /


The code highlighted above returns the following error; 

type 'exceptions.AttributeError' 'SQLFORM' object has no attribute 'error'

-- 
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/groups/opt_out.


[web2py] Re: 'SQLFORM' object has no attribute 'error'

2013-10-07 Thread lesssugar
Shouldn't it be *form.errors*?

On Monday, October 7, 2013 11:20:32 PM UTC+2, raferbop wrote:

 # Model/db.py

 db = DAL('sqlite://storage.sqlite')

 db.define_table(
 'person',
 Field('name', requires=IS_NOT_EMPTY(error_message=auth.messages.
 is_empty)),
 Field('email', requires=IS_EMAIL(error_message=auth.messages.
 invalid_email)),
 Field('password', requires=[IS_STRONG(), CRYPT()]))

 # Contoller/default.py 

 def form_a():
 form = SQLFORM(db.person)
 if form.process(session=None).accepted:
 response.flash = 'form accepted'
 elif form.error:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill out the form'
 return dict(form=form)

 # View

 {{extend 'layout.html'}}
 h1Register Now/h1

 br /
 {{=form}}
 br /


 The code highlighted above returns the following error; 

 type 'exceptions.AttributeError' 'SQLFORM' object has no attribute 
 'error'


-- 
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/groups/opt_out.


[web2py] Re: 'SQLFORM' object has no attribute 'error'

2013-10-07 Thread raferbop
Thanks a lot lesssugar...it worked!

On Monday, October 7, 2013 4:48:25 PM UTC-5, lesssugar wrote:

 Shouldn't it be *form.errors*?

 On Monday, October 7, 2013 11:20:32 PM UTC+2, raferbop wrote:

 # Model/db.py

 db = DAL('sqlite://storage.sqlite')

 db.define_table(
 'person',
 Field('name', requires=IS_NOT_EMPTY(error_message=auth.messages.
 is_empty)),
 Field('email', requires=IS_EMAIL(error_message=auth.messages.
 invalid_email)),
 Field('password', requires=[IS_STRONG(), CRYPT()]))

 # Contoller/default.py 

 def form_a():
 form = SQLFORM(db.person)
 if form.process(session=None).accepted:
 response.flash = 'form accepted'
 elif form.error:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill out the form'
 return dict(form=form)

 # View

 {{extend 'layout.html'}}
 h1Register Now/h1

 br /
 {{=form}}
 br /


 The code highlighted above returns the following error; 

 type 'exceptions.AttributeError' 'SQLFORM' object has no attribute 
 'error'



-- 
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/groups/opt_out.


Re: [web2py] Re: Admin export as csv generates broken file under nginx

2013-10-07 Thread Vinicius Assef
Michele, I'm using the admin feature to export as csv.

Niphlod, records are not big. With rocket it works nice.

On Mon, Oct 7, 2013 at 6:17 PM, Michele Comitini
michele.comit...@gmail.com wrote:
 There is not enough information to say much.
 if possible try to stream directly rather than buffering data first in a
 variable, this should make things faster and lighter.


 2013/10/7 Niphlod niph...@gmail.com

 did you try upping the memory limits ?
 limit-as, reload-on-as, reload-on-rss


 PS: dumping 50k records in a csv is definitely not something for a
 webserver (timeout, anyone ?)

 On Monday, October 7, 2013 10:46:34 PM UTC+2, viniciusban wrote:

 Hi guys.

 I'm experiencing a problem I think is not web2py fault, but uwsgi or
 nginx configuration.

 I'm running web2py inside a Vagrant box (Virtualbox) with nginx.

 I have a table with more than 50k lines and when I try to export as
 csv in admin, the generated file doesn't have all records. Each time
 it generates a
 different number of rows.


 Reading logs, I found something:

 in /var/log/nginx/error.log:
 2013/10/07 20:25:15 [crit] 955#0: *291 open()
 /var/lib/nginx/uwsgi/9/00/09 failed (13: Permission denied)
 while reading upstream, client: 10.11.12.1, server: wsl, request: GET
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 HTTP/1.1, upstream:
 uwsgi://unix:///tmp/web2py.socket:, host: 10.11.12.13, referrer:
 https://10.11.12.13/wsl/appadmin/select/db?query=db.publicacao.id%3E0;


 in /var/log/uwsgi/uwsgi.log:
 SIGPIPE: writing to a closed pipe/socket/fd (probably the client
 disconnected) on request
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 (ip 10.11.12.1) !!!
 uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 296]
 IOError: write error
 [pid: 2168|app: 0|req: 53/153] 10.11.12.1 () {46 vars in 1015 bytes}
 [Mon Oct  7 20:25:06 2013] GET
 /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 = generated 0 bytes
 in 9064 msecs (HTTP/1.1 200) 7 headers in 371 bytes (4 switches on
 core 0)
 ...The work of process 2168 is done. Seeya!
 worker 4 killed successfully (pid: 2168)
 Respawned uWSGI worker 4 (new pid: 2326)
 mapping worker 4 to CPUs: 1




 What is happening? It seems somehow the socket connection is being
 lost. Do you have an idea to fix that?

 BTW, I'm using webp2y v2.4.6 on Ubuntu 12.04 server and it was configured
 by
 setup-web2py-nginx-uwsgi-ubuntu.sh distributed along with web2py.

 My /etc/uwsgi/web2py.ini file is:
 [uwsgi]
 socket = /tmp/web2py.socket
 pythonpath = /home/vagrant/web2py/
 mount = /=wsgihandler:application
 processes = 4
 master = true
 harakiri = 60
 reload-mercy = 8
 cpu-affinity = 1
 stats = /tmp/stats.socket
 max-requests = 2000
 limit-as = 512
 reload-on-as = 256
 reload-on-rss = 192
 uid = vagrant
 gid = vagrant
 cron = 0 0 -1 -1 -1 python /home/vagrant/web2py/web2py.py -Q -S
 welcome -M -R scripts/sessions2trash.py -A -o
 no-orphans = true



 Any help?

 --
 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/groups/opt_out.


 --
 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/groups/opt_out.

-- 
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/groups/opt_out.


[web2py] Re: How to create Testimonials page using web2py?

2013-10-07 Thread Dave S


On Monday, October 7, 2013 1:26:56 PM UTC-7, Massimo Di Pierro wrote:

 What's a testimonial page?

 On Monday, 7 October 2013 10:58:06 UTC-5, Jayakumar Bellie wrote:

 Hi,

 Have anyone created a testimonial page using web2py?


My first thought is a page that visitors could use to post descriptions of 
the person who is the guest of honor of the testimonial page.  I'm 
thinking of the context of remembering the deceased, and such a page 
might occur in conjunction with an online obituary or a funeral home (or 
mortuary or even a church) as part of the announcement of a client's 
internment.

I'd think that a starting point would be the examples for posting comments 
to an article, as in section 3.3 of the manual (An Image Blog), but with 
the following changes:

a) visitors would not have to have an account, although listing an email 
address is a common requirement
b) comments would not be displayed to other visitors immediately, but would 
be vetted before release (add an approved-by field to the db)
c) only admin users could approve or remove entries.

(The same considerations would apply if the guest of honor was still 
alive, and this was in preparation for a ceremonial occasion ... perhaps a 
dinner ... celebrating the awarding of some official honor.)

/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/groups/opt_out.


[web2py] Re: How to create Testimonials page using web2py?

2013-10-07 Thread Dave S
On Monday, October 7, 2013 3:06:27 PM UTC-7, Dave S wrote:



 On Monday, October 7, 2013 1:26:56 PM UTC-7, Massimo Di Pierro wrote:

 What's a testimonial page?

 On Monday, 7 October 2013 10:58:06 UTC-5, Jayakumar Bellie wrote:

 Hi,

 Have anyone created a testimonial page using web2py?


 My first thought is a page that visitors could use to post descriptions of 
 the person who is the guest of honor of the testimonial page.  I'm 
 thinking of the context of remembering the deceased, and such a page 
 might occur in conjunction with an online obituary or a funeral home (or 
 mortuary or even a church) as part of the announcement of a client's 
 internment.

 I'd think that a starting point would be the examples for posting comments 
 to an article, as in section 3.3 of the manual (An Image Blog), but with 
 the following changes:

 a) visitors would not have to have an account, although listing an email 
 address is a common requirement
 b) comments would not be displayed to other visitors immediately, but 
 would be vetted before release (add an approved-by field to the db)
 c) only admin users could approve or remove entries.

 (The same considerations would apply if the guest of honor was still 
 alive, and this was in preparation for a ceremonial occasion ... perhaps a 
 dinner ... celebrating the awarding of some official honor.)


For the online version of the book, comments start showing up just before
http://web2py.com/books/default/chapter/29/03/overview#Adding-authentication

/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/groups/opt_out.


[web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?

2013-10-07 Thread Simon Ashley
w2p is a great framework with many bells and whistles. 
Examples/ defaults are full of them. 
One of the issue when you're learning the framework, you need to take baby 
steps, and study them one at a time. 
(particularly if, like myself, you are new to python, js, CSS3, Bootstrap, 
etc, etc and feel, at times, you dumber than dogs...)

The example posted was stripped from a larger system, sanitised and tested. 
Unfortunately, I didn't strip out a few (i.e truncate) testing lines.
 
I find simple, one or 2 line code snippets, great (the smaller the better).
Its easier to join/ merge later.

Similar comments go for troubleshooting and posting issues.
Its always easier for others if you reduce code just to key elements, to 
illustrate the point.
Slices are good, but they are a bit static/ non interactive.

I'm now wondering how difficult it would be to clone and host a jsfiddle 
type sandbox in w2p, whereby we could post, share, test and modify code 
snippets within the community?

-- 
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/groups/opt_out.


Re: [web2py] Re: Admin export as csv generates broken file under nginx

2013-10-07 Thread Niphlod
still, I think web2py fetches the entire set in memory . did you inspect 
how much memory in rocket it takes ?

On Tuesday, October 8, 2013 12:01:02 AM UTC+2, viniciusban wrote:

 Michele, I'm using the admin feature to export as csv. 

 Niphlod, records are not big. With rocket it works nice. 

 On Mon, Oct 7, 2013 at 6:17 PM, Michele Comitini 
 michele@gmail.com javascript: wrote: 
  There is not enough information to say much. 
  if possible try to stream directly rather than buffering data first in a 
  variable, this should make things faster and lighter. 
  
  
  2013/10/7 Niphlod nip...@gmail.com javascript: 
  
  did you try upping the memory limits ? 
  limit-as, reload-on-as, reload-on-rss 
  
  
  PS: dumping 50k records in a csv is definitely not something for a 
  webserver (timeout, anyone ?) 
  
  On Monday, October 7, 2013 10:46:34 PM UTC+2, viniciusban wrote: 
  
  Hi guys. 
  
  I'm experiencing a problem I think is not web2py fault, but uwsgi or 
  nginx configuration. 
  
  I'm running web2py inside a Vagrant box (Virtualbox) with nginx. 
  
  I have a table with more than 50k lines and when I try to export as 
  csv in admin, the generated file doesn't have all records. Each time 
  it generates a 
  different number of rows. 
  
  
  Reading logs, I found something: 
  
  in /var/log/nginx/error.log: 
  2013/10/07 20:25:15 [crit] 955#0: *291 open() 
  /var/lib/nginx/uwsgi/9/00/09 failed (13: Permission denied) 
  while reading upstream, client: 10.11.12.1, server: wsl, request: GET 
  /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 HTTP/1.1, upstream: 
  uwsgi://unix:///tmp/web2py.socket:, host: 10.11.12.13, referrer: 
  https://10.11.12.13/wsl/appadmin/select/db?query=db.publicacao.id%3E0; 

  
  
  in /var/log/uwsgi/uwsgi.log: 
  SIGPIPE: writing to a closed pipe/socket/fd (probably the client 
  disconnected) on request 
  /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 (ip 10.11.12.1) !!! 
  uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 296] 
  IOError: write error 
  [pid: 2168|app: 0|req: 53/153] 10.11.12.1 () {46 vars in 1015 bytes} 
  [Mon Oct  7 20:25:06 2013] GET 
  /wsl/appadmin/csv/db?query=db.publicacao.id%3E0 = generated 0 bytes 
  in 9064 msecs (HTTP/1.1 200) 7 headers in 371 bytes (4 switches on 
  core 0) 
  ...The work of process 2168 is done. Seeya! 
  worker 4 killed successfully (pid: 2168) 
  Respawned uWSGI worker 4 (new pid: 2326) 
  mapping worker 4 to CPUs: 1 
  
  
  
  
  What is happening? It seems somehow the socket connection is being 
  lost. Do you have an idea to fix that? 
  
  BTW, I'm using webp2y v2.4.6 on Ubuntu 12.04 server and it was 
 configured 
  by 
  setup-web2py-nginx-uwsgi-ubuntu.sh distributed along with web2py. 
  
  My /etc/uwsgi/web2py.ini file is: 
  [uwsgi] 
  socket = /tmp/web2py.socket 
  pythonpath = /home/vagrant/web2py/ 
  mount = /=wsgihandler:application 
  processes = 4 
  master = true 
  harakiri = 60 
  reload-mercy = 8 
  cpu-affinity = 1 
  stats = /tmp/stats.socket 
  max-requests = 2000 
  limit-as = 512 
  reload-on-as = 256 
  reload-on-rss = 192 
  uid = vagrant 
  gid = vagrant 
  cron = 0 0 -1 -1 -1 python /home/vagrant/web2py/web2py.py -Q -S 
  welcome -M -R scripts/sessions2trash.py -A -o 
  no-orphans = true 
  
  
  
  Any help? 
  
  -- 
  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 javascript:. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  
  -- 
  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 javascript:. 
  For more options, visit https://groups.google.com/groups/opt_out. 


-- 
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/groups/opt_out.


[web2py] Postgres DAL-generated Join syntax woes

2013-10-07 Thread Alex W
I'm seeing an odd (bug?) issue with performing selects with alias'd joins, 
using a postgres db. 


db.define_table('fqdn_word_part',
Field('word', 'string', unique=True)
)

db.define_table('fqdn_word_combine',
Field('fqdn_id', 'reference fqdn'),
Field('fqdn_word_part_id', 'reference fqdn_word_part'),
Field('place', 'integer')
)

aliases created;
 first
Table first (id,fqdn_id,fqdn_word_part_id,place)
 second
Table second (id,fqdn_id,fqdn_word_part_id,place)
 firstp
Table firstp (id,word)
 secondp
Table secondp (id,word)

...selecting a record:

db(firstp.word == 'google').select(firstp.word, 
join=(first.on(first.fqdn_word_part_id==firstp.id)))

...generates the correct SQL:

SELECT  firstp.word 
FROM fqdn_word_part AS firstp 
JOIN fqdn_word_combine AS first ON (first.fqdn_word_part_id = firstp.id) 
WHERE (firstp.word = 'google');

...selecting a record using a self-join: 
db(firstp.word == 'google')(secondp.word == 'com').select(firstp.word, 
secondp.word, 
join=(first.on(first.fqdn_word_part_id==firstp.id),second.on(second.fqdn_word_part_id==secondp.id)))

...generates SQL with a syntax error:

SELECT  firstp.word, secondp.word 
FROM fqdn_word_part AS firstp, fqdn_word_part AS secondp 
JOIN fqdn_word_combine AS first ON (first.fqdn_word_part_id = firstp.id) 
JOIN fqdn_word_combine AS second ON (second.fqdn_word_part_id = secondp.id) 
WHERE ((firstp.word = 'google') AND (secondp.word = 'com'));

ProgrammingError: ('ERROR', '42P01', 'invalid reference to FROM-clause 
entry for table firstp')

I can re-arrange the SQL to work correctly:

SELECT  firstp.word, secondp.word 
FROM fqdn_word_part AS firstp 
JOIN fqdn_word_combine AS first ON (first.fqdn_word_part_id = firstp.id), 
fqdn_word_part AS secondp JOIN fqdn_word_combine AS second ON 
(second.fqdn_word_part_id = secondp.id) 
WHERE ((firstp.word = 'google') AND (secondp.word = 'com'));


Is there a more effective way to do this with the DAL?

-- 
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/groups/opt_out.


[web2py] Blank screen from app/admin/edit button

2013-10-07 Thread Dave S
When using the app's admin page, the button to view default.py works 
nicely, but the edit button gives a blank page, except for the secondary 
navigation bar
(Files Toggle, - | A | +, back | online designer | docs | 
settingsicon) and a slide-out panel for the file list.

I can turn off the file list.

I'm not sure what -/A/+ is for.

Did I forget to copy something from the welcome app?  I plopped 
welcome/static/js/web2py.js into my app with no change to the behavior.

This is 2.7.2, and I saw it with 2.6.4 as well.  Running on Rocket and 
Sqlite3

/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/groups/opt_out.


[web2py] Re: Blank screen from app/admin/edit button

2013-10-07 Thread Dave S
On Monday, October 7, 2013 5:01:30 PM UTC-7, Dave S wrote:

 When using the app's admin page, the button to view default.py works 
 nicely, but the edit button gives a blank page, except for the secondary 
 navigation bar
 (Files Toggle, - | A | +, back | online designer | docs | 
 settingsicon) and a slide-out panel for the file list.

 I can turn off the file list.

 I'm not sure what -/A/+ is for.

 Did I forget to copy something from the welcome app?  I plopped 
 welcome/static/js/web2py.js into my app with no change to the behavior.

 This is 2.7.2, and I saw it with 2.6.4 as well.  Running on Rocket and 
 Sqlite3


I posted that with the settings-editor still default, but I get about 
the same results if I change it to emacs.

/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/groups/opt_out.


[web2py] Re: How to create Testimonials page using web2py?

2013-10-07 Thread 黄祥
had you already checked web2py appliances?

ref:
http://www.web2py.com/appliances

best regards,
stifan

-- 
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/groups/opt_out.


[web2py] openid + local default auth

2013-10-07 Thread Cesar Devera
hi,

I'm new to web2py, so I'm afraid this is a silly question to ask, but I'm 
having a hard time trying to put some pieces together.

web2py documentation seems really complete most of times, but the chapter 
about Access Control relies too much in Janrain, which I would love to 
avoid using if possible (I have no problem with Janrain).

what I want to do is offer the default auth using local database features 
*plus* OpenID Auth (for Yahoo and Google) and if possible, later, also 
support Facebook too (again, I have no problem with Facebook, I just 
happened to try OpenID Auth first).

so, first, I used only the default auth with local database, and build my 
login form html layout by hand, like this:


*db.py:*
from gluon.tools import Auth
auth = Auth(db)
auth.define_tables(username=False, signature=False)


*default.py:*
def index():
if auth.is_logged_in():
redirect(URL('home'))
return dict(form=auth())
def user():
return dict(form=auth())
def home():
return dict()


*index.html:*
...
  form method=post action=/myapp/default/user/login 
enctype=multipart/form-data
  input type=text name=email 
  input type=password name=password 
  input name=_next type=hidden 
value=/acompanhacao/default/index
  input name=_formkey type=hidden 
value={{=form.formkey}}
  input name=_formname type=hidden value=login
  button type=submitSubmit/button
  /form
...

and everything worked just fine (I had to fire the register url once, so I 
got an account to use, but I plan to improve this step later).

I could login, logout, check if the user is_logged_in, etc. fine!

now the problem starts. I wanted to add suport to OpenID without Janrain. 
so, I checked the Access Control chapter in the documentation, got some 
hints but no full examples, then I downloaded and checked the sources for 
the files openid_auth.py and extended_login_form.py (both from 
gluon.contrib.login_methods), got some other hints, googled something and 
ended up with this:


*db.py:*
from gluon.tools import Auth
auth = Auth(db)
auth.define_tables(username=False, signature=False)

from gluon.contrib.login_methods.openid_auth import OpenIDAuth
openid_login_form = OpenIDAuth(auth)

from gluon.contrib.login_methods.extended_login_form import 
ExtendedLoginForm
extended_login_form = ExtendedLoginForm(auth, openid_login_form, 
signals=['oid'])

auth.settings.login_form = extended_login_form


*default.py:*
# no change in the previous methods, but added this:
def test():
return dict(form=auth())

*test.html:*
{{=form}}


ok. now, when I browse /myapp/default/test I see a page with a form in two 
parts, the first one with username/password fields, and the bottom with a 
new field to input my openid provider url.

the first thing I noticed is that I could not just use the tag: 
{{=form.formkey}} and build my form by hand, because I get a strange error 
like: AttributeError: 'DIV' object has no attribute 'formkey'

some some reason, I believe my auth form is wrapped in such a way I cannot 
access its _formkey attribute anymore (and that's I endded up with that 
simple test.html)

also, I could find no place to input beforehand the openid provider url. in 
fact, this is not completelly bad, because I plan to use two providers 
(yahoo and google) and so I'll probably put two forms (or just one 
javascript-managed) in my page.

anyway, I still want to be able to build my forms by hand, and I cannot do 
this without access to the formkey. (I believe)


other thing I noticed is that there is no place where I inform which 
attributes I want from the openid provider (email, nickname, etc). 


...
anyway, I populated the automatically built form, submitted, and was 
redirected to the openid provider (I tested with yahoo, using url: 
https://me.yahoo.com). 

then I informed my username and password and was redirected back to my app, 
as if I logged in. 

but when I tested is_logged_in(), I got false. then, I checked the 
db.alt_logins table, and db.auth_user table, I found nothing new there (no 
new record with a new user or anything).



so, I believe I almost did it, but something is still missing.

what need to be answered is:

1. is it possible to use both auth methods (default and openid) together 
without Janrain? how do I setup this?

2. is it possible to build my forms by hand, without depending on the 
auto-generated forms?

3. if I got it right, the only thing I need is the form._formkey attribute, 
and for all the rest I can write my own html. I just need to know how to 
get the formkey from the extended_login_form;

4. the ExtendedLoginForm class seems to support only two auth methods, so 
how could I support three? for example: default auth, plus openid 
(yahoo/google), plus oauth (facebook)? can I chain ExtendedLoginForms?

5. I could find no docs about the signals used in the ExtendedLoginForm. 
could this be the problem in my setup? I 

[web2py] DAL query for this SQL

2013-10-07 Thread Dave S
I have figured out that I'm interested in queries like

results = db.executesql(SELECT * FROM logtable where logtime  
date('now','-1 day') AND logtime  date('now','-2 days') ORDER BY logtime 
DESC) ;


How would I rewrite that as DAL query?

Thanks.

/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/groups/opt_out.


[web2py] Re: DAL query for this SQL

2013-10-07 Thread Dave S
On Monday, October 7, 2013 6:44:44 PM UTC-7, Dave S wrote:

 I have figured out that I'm interested in queries like

 results = db.executesql(SELECT * FROM logtable where logtime  
 date('now','-1 day') AND logtime  date('now','-2 days') ORDER BY logtime 
 DESC) ;


 How would I rewrite that as DAL query?
  


And if I were to stick with the executesql() phrase,  how would I get 
colnames so I could plug this into an SQLTABLE?

/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/groups/opt_out.


[web2py] Re: DAL query for this SQL

2013-10-07 Thread lesssugar
In general:

db(your_condition).select(db.table_name.ALL, orderby=~db.table_name.logtime)

As for your_condition, Python's timedelta should be useful: 
http://docs.python.org/2/library/datetime.html#datetime.timedelta

On Tuesday, October 8, 2013 3:56:33 AM UTC+2, Dave S wrote:

 On Monday, October 7, 2013 6:44:44 PM UTC-7, Dave S wrote:

 I have figured out that I'm interested in queries like

 results = db.executesql(SELECT * FROM logtable where logtime  
 date('now','-1 day') AND logtime  date('now','-2 days') ORDER BY logtime 
 DESC) ;


 How would I rewrite that as DAL query?
  


 And if I were to stick with the executesql() phrase,  how would I get 
 colnames so I could plug this into an SQLTABLE?

 /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/groups/opt_out.


[web2py] Re: DAL query for this SQL

2013-10-07 Thread Anthony


 And if I were to stick with the executesql() phrase,  how would I get 
 colnames so I could plug this into an SQLTABLE?


Check out 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#executesql
 -- 
if you supply the fields or colnames arguments as described, you will get 
back a standard Rows object, just like any DAL select.

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/groups/opt_out.


[web2py] Re: DAL query for this SQL

2013-10-07 Thread Dave S
On Monday, October 7, 2013 7:53:35 PM UTC-7, Anthony wrote:


 And if I were to stick with the executesql() phrase,  how would I get 
 colnames so I could plug this into an SQLTABLE?


 Check out 
 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#executesql
  -- 
 if you supply the fields or colnames arguments as described, you will get 
 back a standard Rows object, just like any DAL select.


Thanks, Anthony.  It is obvious that the first time I read the colnames 
paragraph, it didn't stick with me.  Then I had to play around with how I 
wrote the call in order to get the right dots on the right tees, and all my 
eyes crossed, but I got there.

/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/groups/opt_out.


[web2py] Re: DAL query for this SQL

2013-10-07 Thread Anthony
On Tuesday, October 8, 2013 12:18:41 AM UTC-4, Dave S wrote:

 On Monday, October 7, 2013 7:53:35 PM UTC-7, Anthony wrote:


 And if I were to stick with the executesql() phrase,  how would I get 
 colnames so I could plug this into an SQLTABLE?


 Check out 
 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#executesql
  -- 
 if you supply the fields or colnames arguments as described, you will get 
 back a standard Rows object, just like any DAL select.


 Thanks, Anthony.  It is obvious that the first time I read the colnames 
 paragraph, it didn't stick with me.  Then I had to play around with how I 
 wrote the call in order to get the right dots on the right tees, and all my 
 eyes crossed, but I got there.


Admittedly, that write-up is a bit hard to follow without any examples.
 

-- 
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/groups/opt_out.


[web2py] 1071, 'Specified key was too long; max key length is 767 bytes

2013-10-07 Thread Mike Veltman


My gut feeling says mysql 5.1 -- mysql 5.5 upgrade is the cause. Am I right ? 
And how do I solve it. :-)

*Error ticket for adeploy*
*Ticket ID*
192.168.2.106.2013-10-08.12-46-19.24f3f1a5-d637-4522-965b-fed4958115ed
*class '_mysql_exceptions.OperationalError' (1071, 'Specified key was too 
long; max key length is 767 bytes')*
*Version*
*web2py™*
Version 2.7.2-stable+timestamp.2013.10.07.13.52.24

*Traceback*

1.

Traceback *(*most recent call last*):  *File 
/srv/web-apps/web2py/gluon/restricted.py*, *line 217*, in *restricted
*exec *ccode *in *environment  File 
/srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 178*, 
in *module*  *File /srv/web-apps/web2py/gluon/dal.py*, *line 7911*, in 
*define_tabletable *= 
**self.*lazy_define_table*(*tablename*,**fields*,***args*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 7948*, in *lazy_define_table
polymodel*=*polymodel*)  *File /srv/web-apps/web2py/gluon/dal.py*, *line 
1029*, in *create_tablefake_migrate*=*fake_migrate*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 1136*, in *migrate_table
*self.*execute*(*sub_query*)  *File /srv/web-apps/web2py/gluon/dal.py*, *line 
1836*, in *execute*return self.*log_execute*(**a*, ***b*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 1830*, in *log_executeret *= 
**self.*cursor*.*execute*(*command*, **a*[*1*:], ***b*)  *File 
/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py*, *line 173*, in 
*execute*self.*errorhandler*(self, *exc*, *value*)  *File 
/usr/lib64/python2.6/site-packages/MySQLdb/connections.py*, *line 36*, in 
*defaulterrorhandler*raise *errorclass*, *errorvalueOperationalError*: 
(*1071*, *'Specified key was too long; max key length is 767 bytes'*)

*

*In file: /srv/web-apps/web2py/applications/adeploy/compiled/models/db.pyc*
1.
**code object **module* *at 0x168c468*, *file 
/srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 28**

 


-- 
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/groups/opt_out.


[web2py] 1071, 'Specified key was too long; max key length is 767 bytes'

2013-10-07 Thread Mike Veltman
Ok, I am now fighting with it for two days and it drives me crazy.
My gut feeling says mysql 5.1 -- mysql 5.5 upgrade is the cause. Am I right ? 
And how do I solve it. :-)

*Error ticket for adeploy*
*Ticket ID*
192.168.2.106.2013-10-08.12-46-19.24f3f1a5-d637-4522-965b-fed4958115ed
*class '_mysql_exceptions.OperationalError' (1071, 'Specified key was too 
long; max key length is 767 bytes')*
*Version*
*web2py™*
Version 2.7.2-stable+timestamp.2013.10.07.13.52.24

*Traceback*

1.

Traceback *(*most recent call last*):  *File 
/srv/web-apps/web2py/gluon/restricted.py*, *line 217*, in *restricted
*exec *ccode *in *environment  File 
/srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 178*, 
in *module*  *File /srv/web-apps/web2py/gluon/dal.py*, *line 7911*, in 
*define_tabletable *= 
**self.*lazy_define_table*(*tablename*,**fields*,***args*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 7948*, in *lazy_define_table
polymodel*=*polymodel*)  *File /srv/web-apps/web2py/gluon/dal.py*, *line 
1029*, in *create_tablefake_migrate*=*fake_migrate*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 1136*, in *migrate_table
*self.*execute*(*sub_query*)  *File /srv/web-apps/web2py/gluon/dal.py*, *line 
1836*, in *execute*return self.*log_execute*(**a*, ***b*)  *File 
/srv/web-apps/web2py/gluon/dal.py*, *line 1830*, in *log_executeret *= 
**self.*cursor*.*execute*(*command*, **a*[*1*:], ***b*)  *File 
/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py*, *line 173*, in 
*execute*self.*errorhandler*(self, *exc*, *value*)  *File 
/usr/lib64/python2.6/site-packages/MySQLdb/connections.py*, *line 36*, in 
*defaulterrorhandler*raise *errorclass*, *errorvalueOperationalError*: 
(*1071*, *'Specified key was too long; max key length is 767 bytes'*)

*

*In file: /srv/web-apps/web2py/applications/adeploy/compiled/models/db.pyc*
1.
**code object **module* *at 0x168c468*, *file 
/srv/web-apps/web2py/applications/adeploy/compiled/models/db.py*, *line 28**

 

-- 
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/groups/opt_out.