[web2py] Re: VARCHAR or NVARCHAR?

2015-04-15 Thread Paolo Valleri
mssql adapters are quite messy.
MSSQL2Adapter is the adapter that uses 'nvarchar' as type, however it 
inherits from MSSQLAdapter, given that it doesn't have the features of 
MSSQL4Adapter.
For backward compatibility I don't think MSSQL2Adapter will be never 
updated to inherits from MSSQL4Adapter.
My suggestion is to create your own adapter, something like that should work
from pydal.adapters import ADAPTERS, MSSQL4Adapter, MSSQL2Adapter
class MyMSSQLAdapter(MSSQL2Adapter, MSSQL4Adapter):
pass

ADAPTERS.update( {
'mymssql': MyMSSQLAdapter
})
db = DAL('mymssql://user:pass@host/database')

Your new adapter will have the types of MSSQL2Adapter, the methods of both.

Paolo

On Wednesday, April 15, 2015 at 3:22:10 AM UTC+2, Ray (a.k.a. Iceberg) 
wrote:
>
> Hi there,
>
> Long story short, I am now working in a project with web2py trying to 
> connect to a MSSQL database. My team tends to use the connect string as 
> "mssql4://..." to take the advantage of the (latest and greatest?) 
> MSSQL4Adapter, however we also notice from the dal source code mssql.py 
> that, MSSQL4Adapter defines "string" as "VARCHAR", while an older 
> MSSQL2Adapter defines "string" as "*N*VARCHAR".
>
> It seems there is some other opinion in favor of "NVARCHAR" 
> 
>  for 
> internationalization reason. But then why the web2py MSSQL4dapter chooses 
> "VARCHAR" instead of "NVARCHAR"? Any insight?
>
> Thanks in advance!
>
> Regards,
> Ray
>

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


[web2py] variables outside any function

2015-04-15 Thread Annet
In a controller I got functions that use the same variables.
I want to assign a value to them outside any function:


if request.args(0) == 'openinghours':
  rdrctUrl = URL('opening_hours')
function_header = 'Opening hours'
function_icon = 'fa-clock-o'
table = db.cal_opening_hours
elif request.args(0) == 'eventlist':
rdrctUrl = URL('event_list')
function_header = 'Event list'
function_icon = 'fa-calendar-o'
table = db.cal_event_list

def insert():

return locals()

def update():

return locals()

def opening_hours():

return locals()

etc.


The variables rdrctUrl en table are available in the functions, however, 
function_header 
and function_icon which I need in views are not available in the views. 
Where do I store
them to make them available in the views.

Kind regards,

Annet

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


[web2py] Re: variables outside any function

2015-04-15 Thread Anthony
The views are executed in an environment that includes anything defined in 
models as well as whatever items are passed in the dictionary from the 
controller function. Other objects defined in the controller are not 
available in the view environment. So, you must pass items directly from 
the controller functions. You could put all the parameters in a single 
dictionary or Storage object and pass that one object from each function, 
or you could consider putting the parameters in the response object. 
Another option might be to have your functions return 
response.render(globals()).

Anthony

On Wednesday, April 15, 2015 at 7:35:00 AM UTC-4, Annet wrote:
>
> In a controller I got functions that use the same variables.
> I want to assign a value to them outside any function:
>
>
> if request.args(0) == 'openinghours':
>   rdrctUrl = URL('opening_hours')
> function_header = 'Opening hours'
> function_icon = 'fa-clock-o'
> table = db.cal_opening_hours
> elif request.args(0) == 'eventlist':
> rdrctUrl = URL('event_list')
> function_header = 'Event list'
> function_icon = 'fa-calendar-o'
> table = db.cal_event_list
>
> def insert():
> 
> return locals()
>
> def update():
> 
> return locals()
>
> def opening_hours():
> 
> return locals()
>
> etc.
>
>
> The variables rdrctUrl en table are available in the functions, however, 
> function_header 
> and function_icon which I need in views are not available in the views. 
> Where do I store
> them to make them available in the views.
>
> Kind regards,
>
> Annet
>

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


[web2py] Need advice/help with url rewrite: multiple domains, multiple apps, two apps per domain

2015-04-15 Thread Lisandro
I have multiple domains with multiple applications. I've gotten it to work 
using routes.py, with both approaches: parameter-based and pattern-based 
system. However, there's a couple of things that still I can't achieve.


1) Two applications per each domain
In my case, each domain serves two applications: the main one, and a second 
one. I need the main one to be accessible through / url. And I need the 
second one to be accessible through an url that  is different to the 
application name. To clarify:

  *http://site1.dev*> should serve *site1* app
  *http://site1.dev/panel*  > should serve *panel1* app

  *http://site2.dev*> should serve *site2* app
  *http://site2.dev/panel*  > should serve *panel2* app

Notice that every domain should have the /panel url pointing to the 
corresponding application (panel1, panel2, etc). 


2) Restrict access to specific application according the domain
Whether is parameter-based or pattern-based system, all domains endup 
having access to all applications, for example, http://site1.dev/site2/  is 
showing site2 application. But I would like that the domain *site1.dev* can 
only access the applications site1 and panel1, and nothing else.



What have I achieved so far? 

 routes.py using parameter-based system -
# -*- coding: utf-8 -*-

routers = dict(BASE = dict(\
domains = {\
  'site1.dev':'site1', \
  'site2.dev':'site2', \
}))


This approach is working, however I don't know how to make */panel* url to 
serve *panel1* application. Also, the problem of the point 2 remains: all 
domains can access all applications.


 routes.py using pattern-based system -
# -*- coding: utf-8 -*-

routes_in = (
('.*http://site1.dev.* /*', '/site1'),
('.*http://site2.dev.* /*', '/site2'))


In this case, in addition to the aforementioned problems, I see an error on 
every url that is not default/index. That is, http://site1.dev/ shows the 
default/index, but if I click, let's say, on the register url, the browser 
attempts to load site1.dev/site1/default/user/register but I receive an 
"invalid function" error.


At this point, I'm a bit lost. I'm using nginx, and I asume all this could 
be done through nginx's rewrite module (however I would like to keep it 
inside web2py, for portability reasons).
Also, I must say I've never worked with regular expressions, and in 
addition, as you can see, this scenario is a little bit different than the 
classic one-app-per-domain. 

So, I would really appreciate any advice or help on this. 

P/S: if someone feels sufficiently trained to resolve the situation, please 
contact me by private, I'm willing to spend some money to resolve this 
situation in a professional manner.

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


Re: [web2py] Application Arquitecture advices

2015-04-15 Thread Richard Vézina
Sébastien,

Start by making something then when you will need performance you can work
on it. I have 155 tables in my app and it is not the model that slow down
things... It is more the number of records in these tables that matter so
far... I mean, I should use SQLFORM.grid which use paging and load only
small amount of records at a time which limit the loading time of grid page
which are the page that requires the most processing. You better not define
function or class in models files which really degrad performance. You can
activate lazy table by respecting some rules when defining your table and
set lazy table flag to true (this has no cost and should improve
performance). You may also consider models/subfolder which make models file
parsing conditionnal to the controller called though it has many chances to
make your app less dry (I avoid that)... So as Steve mention there is
"Model less app" for which you should found many thread on the mailing-list
detailing how to use it. But as I said, just go that way once you really
need it. It bring much more work for you and will slow down your pace of
developpement if you do that too early.

Richard

On Tue, Apr 14, 2015 at 8:03 PM, 黄祥  wrote:

> yes, you are right, models executed on every request. but you can use,
> model less application (define table using modules, best practice if you
> have the same table that been used by more than 1 web2py app) or
> conditional models (response.models_to_run)
> In book you can see an advice :
>
>- Minimize the code in models: do not define functions there, define
>functions in the controllers that need them or - even better - define
>functions in modules, import them and use those functions as needed.
>
>
> ref:
> http://web2py.com/books/default/chapter/29/04/the-core#Conditional-models
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications
>
> http://web2py.com/books/default/chapter/29/13/deployment-recipes#Efficiency-tricks
>
> 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/d/optout.
>

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


[web2py] Re: Bug in SQLFORM.factory bootstrap3 formstyles ?

2015-04-15 Thread Gary Cowell
It makes it end up looking like this when using a dropdown:

Wide Dropdown 



On Monday, 13 April 2015 06:35:05 UTC+1, Gary Cowell wrote:
>
> Hi
>
> Running with:
>
>
> 2.10.3-stable+timestamp.2015.04.02.21.42.07
>
> (Running on Rocket 1.2.6, Python 2.7.5) 
>
>
> I find that this code:
>
> xadb = DAL('sqlite:memory:')
> xadb.define_table('regiontable', Field('region', length=20,label=
> 'Region'))
>
> form = SQLFORM.factory(SQLField('Region', label='Select a region', 
> length=20,
>requires=IS_IN_DB(xadb,'regiontable.region',orderby=xadb.
> regiontable.region)),
>formstyle='bootstrap3_inline'
> )
>
> Produces a drop-down that is the entire width of the page when viewed in 
> Firefox.  Same for bootstrap3_stacked
>
> The 'classic' formstyles, of table2cols, table3cols etc. don't look as 
> nice, don't have the bootstrap button, but they produce fields of the 
> correct width.
>
> Is this a bug in the bootstrap3 , or did I need to do more to my 
> SQLFORM.factory to get the correct width?
>
> Thanks
>

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


[web2py] Re: Issue with lookup foreign key / format statement in 2.10.3

2015-04-15 Thread wish7code
Thats's good news!

Thanks for taking care!
Cheers
Toby

Am Dienstag, 14. April 2015 23:29:48 UTC+2 schrieb Niphlod:
>
> being a bug, we need to ship a new web2py. it got fixed already. we're 
> waiting for Massimo to release a 2.10.4.
>
> On Tuesday, April 14, 2015 at 10:51:31 PM UTC+2, wish...@gmail.com wrote:
>>
>> I just discovered, there's already a issue posted..
>>
>> https://groups.google.com/forum/#!topic/web2py/Tog4tdUl400
>> https://github.com/web2py/web2py/issues/904 
>>
>> Are there already any solutions yet?
>>
>> Thanks & cheers
>> Toby
>>
>> wish...@gmail.com:
>>>
>>> Hey guys!
>>>
>>> Did 2.10.3-stable+timestamp.2015.04.02.21.42.07 change something in the 
>>> way* format statements *%(fields)s are handled?
>>>
>>> When referencing another table, the *format statement now seems to be 
>>> ignored*. Instead only the foreign key id is displayed.
>>>
>>> Example 
>>>
>>> I have the following lookup table
>>>
>>> db.define_table('countries',
>>> Field('country', 'string'),
>>> Field('the_geom', 'geometry()'),
>>> Field.Virtual('latitude', lambda row: db(db.countries.id == 
>>> row.countries.id
>>> ).select(db.countries.centroid.st_y()).first()[db.countries.centroid.st_y()]),
>>> Field.Virtual('longitude', lambda row: db(db.countries.id == 
>>> row.countries.id
>>> ).select(db.countries.centroid.st_x()).first()[db.countries.centroid.st_x()]),
>>>* format='%(country)s'*, migrate=True)
>>> 
>>> Another table is referencing this lookup table
>>>
>>> db.define_table('uploads',
>>> Field('country',* db.countries*),
>>> Field('uploaded','date'),
>>> ...
>>> migrate=True)
>>> 
>>> Now I would like to count the number of uploads per country.
>>>
>>> def count_uploads_by_country():
>>> import datetime
>>> from datetime import timedelta
>>> count = db.wifi_zone.id.count()
>>> result = db(db.uploads.uploaded > datetime.date.today() -  
>>> timedelta(days=7)).select(*db.uploads.country*, count, groupby = 
>>> db.uploads.country).render()
>>> return dict(result=result)
>>> 
>>> I would expect that a query on the uploads table would display the 
>>> country name as specified in the format statement, i.e.
>>> *Country  Uploads per Country*
>>> *France* 123
>>> *Italy   *45 
>>> *Germany   *10
>>>
>>> Until recently this worked perfectly, but following the update to 2.10.3 
>>> only the country ids are returned, i.e.
>>>
>>> *Country  Uploads per Country**1*   <-- foreign id instead of name
>>> *2*   <--45 
>>> *3*   <--10
>>>
>>> db._lastsql shows that the country name isn't even queried:
>>> SELECT uploads.country, COUNT(uploads.id) FROM uploads WHERE 
>>> (uploads.last_updated > '2015-04-04') GROUP BY uploads.country;
>>>
>>> Does anybody have a clue, why only the foreign id is displayed, but not 
>>> the country name according to the format statement?
>>>
>>> Cheers 
>>> Toby
>>>
>>>

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


[web2py] Re: Run linux ssh script

2015-04-15 Thread Gary Cowell
I might be inclined (have done, in fact) to use a python ssh implementation 
to do this, rather than using shell.

paramiko would be one such module, 'spur' module is easier to use.  Not 
using shell gives the python greater control over error handling and 
recovery, among other things.

Of course, if it's a complex shell script, there's reimplementation to do.  



On Tuesday, 14 April 2015 21:51:31 UTC+1, Andreea Gheorghiu wrote:
>
>
> Hello!
>
> I want to run a Linux script which uses ssh to connect to another server .
> The script is correctly implemented ( i tested on Putty) ,  but when i 
> execute it with Web2py nothing is happening.
>
>
>
> My module is:
> from gluon import *
> import subprocess
> import os
> import shlex
> def ssh_script():
> return subprocess.call(['/home/web2py/../demo/modules/ssh.sh'], shell 
> = True)
>
> the linux script:
> #!/usr/bin/expect
>
> spawn ssh test@serverip 'ls' '-l'>>ssh.log
> expect "password"
> send "mypassword"
> interact
>
> do you have any idea what i'm 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/d/optout.


[web2py] HTML helpers to build a bootstrap dropdown button?

2015-04-15 Thread Gary Cowell
Hello

I use code such as this:

status = 'Delete'
buttonTitle='Delete'
buttonURL='deleteStack'
buttonClass='button btn btn-danger'
buttonIcon='icon trash icon-trash glyphicon glyphicon-trash'
button = A(
 SPAN(_class=buttonIcon)
 ,buttonTitle
 ,_class=buttonClass
 ,_title=buttonTitle
 ,_onclick = "return confirm('Are you sure? Really delete 
{0}?');".format(tenant)
 ,_enabled=False
 ,_href=URL("tenant","deleteStack",args=[tenant] , 
user_signature=True )
 )
 return button

To return a button to a SQLFORM.grid, that has bootstrap style and this 
works well.

What I'd like to do is get rid of all the buttons in my links= parameter, 
and replace with one single dropdown button.

I've been trying to follow this 
http://getbootstrap.com/components/#btn-groups:


  1
  2

  

  Dropdown
  


  Dropdown link
  Dropdown link

  



To create a drop down, but I'm trying myself in knots trying to work out 
how to nest the necessary DIV, SPAN, UL, and LI  HTML helpers.  It seems 
similar to how the menu dropdowns work.

Can this idea even work as q SQLFORM.grid links button?

Thanks :)


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


[web2py] Re: Admin disabled because too many invalid login attempts

2015-04-15 Thread Massimo Di Pierro
In admin/models/access.py

deny_file = os.path.join(request.folder, 'private', 'hosts.deny')

allowed_number_of_attempts = 5

expiration_failed_logins = 3600


You can remove/edit the file private/hosts.deny, or increase the number of 
attempts

On Friday, 10 April 2015 23:00:33 UTC-5, Shreyas Pandya wrote:
>
> same problem here, 
>
> Anybody?
>
> On Sunday, 22 September 2013 22:27:51 UTC+5:30, Pascal wrote:
>>
>> Hello mate,
>>
>> I  forgot the password of the https online admin page of my Web2py 
>> application and I tried several password. 
>> After few attempt it disable the Admin. 
>> Please can you let me know how to solve this issue ?
>>
>> Thank you.
>>
>

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


[web2py] Re: Sequential ajax search problem

2015-04-15 Thread Massimo Di Pierro
I think you want to replace

links = [A(a.title, _href=URL('next_select', args=[a.id, a.title])) for a 
in images]

with

links = [A(a.title, _href=URL('next_select', args=[a.id, 
a.title]),_target=;_top') for a in images]




On Friday, 10 April 2015 23:00:39 UTC-5, P Page-McCaw wrote:
>
> I'm a biologist, very much not a programmer, I wanted to make some web 
> based databases for the lab and found web2py and I've been having a lot of 
> fun and success learning. But I have a problem that I really do not 
> understand. I have a lot of zebrafish (zebrafish are remarkably good models 
> of human disease) and we breed them. One male and one female. I thought I 
> would search for one parent using the ajax search found in the book, then 
> search for the next parent. 
>
> I thought I was a genius when I copied and pasted successfully and could 
> search for one parent. But when I go to search for the next parent a 
> problem happens. Instead of the list of parents showing up under the search 
> field, i.e. in the target div, it seems a new version of the page opens as 
> an iframe in the div. 
>
> I've tried all kinds of goofy things and nothing so far allows me to get a 
> second list of ajax found rows. I'm not sure what code to include to help 
> out. I've tried to separate each step into different functions in the 
> controller, I can reproduce this in the images blog example with the 
> controller functions pasted below.
>
> I'm clearly missing something obvious, any help appreciated. 
>
> Even more helpful than correcting my problem would probably be an 
> explanation of how I have gone so wrong! I generally have trouble figuring 
> out where my errors are which is quite frustrating to me. 
>
> Many thanks 
>
>
> def start_selection():
> form = FORM(INPUT(_id='keyword',_name='keyword',
>   _onkeyup="ajax('first_selection_callback', 
> ['keyword'], 'target');"))
> target_div=DIV(_id='target')
> return dict(form=form, target_div=target_div)
>
> def first_selection_callback():
> query = db.image.title.contains(request.vars.keyword)
> images = db(query).select()
> links = [A(a.title, _href=URL('next_select', args=[a.id, a.title])) 
> for a in images]
> return UL(*links)
>
> def next_select():
> form2 = FORM(INPUT(_id='keyword2',_name='keyword2',
>   _onkeyup="ajax('next_selection_callback', 
> ['keyword2'], 'target2');"))
> target_div2=DIV(_id='target2')
> return dict(form2=form2, target_div2=target_div2)
>
> def next_selection_callback():
> query = db.image.title.contains(request.vars.keyword)
> images = db(query).select()
> links = [A(b.title, _href=URL('index', args=[b.id, b.title])) for b 
> in images]
> return UL(*links)
>
>
>

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


Re: [web2py] Re: WEB2PY Certificate ?

2015-04-15 Thread Massimo Di Pierro
This is an excellent idea.

On Friday, 10 April 2015 23:00:40 UTC-5, KPlusPlus wrote:
>
> Can we start the same initiative around the world for the educational 
> institutions ,  where the institution can be recognized  by web2py ? 
>
>
> On Friday, April 10, 2015 at 10:41:56 AM UTC+3, Mariano Reingart wrote:
>>
>> FYI, in Argentina we're starting a similar initiative, "Diploma in Free & 
>> Open Source Software" in a local university (Spanish language): 
>>
>> http://www.softwarelibre.org.ar/diplomatura/
>>
>>
>> http://www.ude.edu.ar/index.php?option=com_content&view=article&id=615&Itemid=55
>>
>> It is more extensive, the courses are:
>>
>>- Web development (web2py)
>>- Introduction to programming I & II (Python)
>>- Databases (PostgreSQL)
>>- Computer Networks (GNU/Linux)
>>- Operating Systems (GNU/Linux)
>>- Free & Open Source Software introduction 
>>- Free & Open Source Software Engineering
>>
>> I'd be glad to help automating / translating an unified certification 
>> process for web2py ;-) 
>>
>> BTW, teaching assistants collaborators are welcome too (feel free to 
>> contact me by private email)
>>
>> Best regards
>>
>> Mariano Reingart
>> http://www.sistemasagiles.com.ar
>> http://reingart.blogspot.com
>>
>>
>> On Tue, Mar 24, 2015 at 4:34 AM, Massimo Di Pierro  
>> wrote:
>> > Yes.
>> > 
>> http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython.aspx
>> >
>> > I teach it and it is basically a course on web2py. Problem is, I am too 
>> busy
>> > to teach it and I have not been teaching it in one year.
>> >
>> > Anyway, past lectures are all online. I am considering automating the
>> > certification process. I have a large database of questions/problems.
>> >
>> > Massimo
>> >
>> >
>> > On Monday, 23 March 2015 21:53:16 UTC-5, KPlusPlus wrote:
>> >>
>> >> Hello
>> >>
>> >> I was wondering if there's an organization/institution can offer a 
>> WEB2PY
>> >> Certificate with or without Course ?
>> >>
>> > --
>> > Resources:
>> > - http://web2py.com
>> > - http://web2py.com/book (Documentation)
>> > - http://github.com/web2py/web2py (Source code)
>> > - https://code.google.com/p/web2py/issues/list (Report Issues)
>> > ---
>> > You received this message because you are subscribed to the Google 
>> Groups
>> > "web2py-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an
>> > email to web2py+un...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>

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


[web2py] Re: Bug in SQLFORM.factory bootstrap3 formstyles ?

2015-04-15 Thread Massimo Di Pierro
Please open a ticket

On Wednesday, 15 April 2015 08:18:16 UTC-5, Gary Cowell wrote:
>
> It makes it end up looking like this when using a dropdown:
>
> Wide Dropdown 
>
>
>
> On Monday, 13 April 2015 06:35:05 UTC+1, Gary Cowell wrote:
>>
>> Hi
>>
>> Running with:
>>
>>
>> 2.10.3-stable+timestamp.2015.04.02.21.42.07
>>
>> (Running on Rocket 1.2.6, Python 2.7.5) 
>>
>>
>> I find that this code:
>>
>> xadb = DAL('sqlite:memory:')
>> xadb.define_table('regiontable', Field('region', length=20,label=
>> 'Region'))
>>
>> form = SQLFORM.factory(SQLField('Region', label='Select a region', 
>> length=20,
>>requires=IS_IN_DB(xadb,'regiontable.region',orderby=xadb.
>> regiontable.region)),
>>formstyle='bootstrap3_inline'
>> )
>>
>> Produces a drop-down that is the entire width of the page when viewed in 
>> Firefox.  Same for bootstrap3_stacked
>>
>> The 'classic' formstyles, of table2cols, table3cols etc. don't look as 
>> nice, don't have the bootstrap button, but they produce fields of the 
>> correct width.
>>
>> Is this a bug in the bootstrap3 , or did I need to do more to my 
>> SQLFORM.factory to get the correct width?
>>
>> Thanks
>>
>

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


Re: [web2py] LOAD component inside component

2015-04-15 Thread Massimo Di Pierro
Never tried. My guess is that  

jQuery.web2py.trap_form is not called for the inner forms.

If you call it manually using jQuery you can make it work.

But I would not. I would figure out how to use ractive.js instead.

On Monday, 13 April 2015 15:00:39 UTC-5, Richard wrote:
>
> Hello,
>
> I create a page with multiple components inside of it (the index page is 
> basically an empty shell for the components)... But one of there is a form 
> in one of the embed component which as a field with a widget that trigger 
> modal form allowing to insert a value in another table and select this 
> inserted value (something like SELECT_OR_ADD() would do). The problem is 
> that my form embeded in the modal which the widget append to the page with 
> LOAD() don't load... It hang on "loading..."
>
> Any idea?
>
> Is it even possible to trigger a LOAD inside a LOAD?
>
> Thanks
>
> Richard
>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Massimo Di Pierro
The problem is that it is not web2py but the user code that access the 
record.
Web2py does not know that the user has been removed from the DB.
This cannot be solved without checking if the user is still there and it 
can cause performance issues.

Suggestions?

On Tuesday, 14 April 2015 11:29:37 UTC-5, Leonel Câmara wrote:
>
> Upon further investigation a way to cause a variant of this bug seems to 
> be:
>
> 1. Register and login with a user.
> 2. Drop the user from the database (do not clean sessions)
> 3. Try to logout the user created in 1
> 4. Have a ticket error because you have the session with the user but it 
> isn't in the database.
>

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


[web2py] Re: Prepolulate datetime field internationalization problem

2015-04-15 Thread Massimo Di Pierro
One solution is:

form.vars.from = IS_DATETIME()(request.now)[0]

On Tuesday, 14 April 2015 17:39:01 UTC-5, Sebastián Tromer wrote:
>
> Hello everyone!
>
> I'm prepopulating a form made with the FORM helper.
> In the form I have 2 INPUTs of type DATETIME:
>
> INPUT(_name='from', _class='datetime', requires = IS_DATETIME())
>
> I'm prepolutaing this field with:
>
> form.vars.from = request.now
>
> and I'm getting something like this:* 2015-04-14 19:31:36.242654*
>
> this works OK if the locale is '*en*' but when I have my browser with 
> locale '*es*'
> the input should be prepopulated with the format *'%d/%m/%Y 
> %H:%M:%S.mm' *
> because web2py (somehow) knows that it must validate using '*es*' locale.
>
> So, the question is: How can I prepopulate a datetime input field that 
> pass validation in any locale?
>
> Thanks!
>

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


[web2py] Re: Beginners question about multiple applications

2015-04-15 Thread Massimo Di Pierro


On Tuesday, 14 April 2015 15:51:31 UTC-5, Peter Gibson wrote:
>
> I am a beginner with Web2py but am very impressed with what I have seen 
> and read so far.  
>
> I have plans to use Web2py for a sizable web project.
>
> My project requires a wiki (the built in one will do just fine) and what I 
> would refer to as a number of 'models'.  For example Twitter, Facebook, 
> Accounts, Calendar.
>
> I have three questions which I would appreciate guidance on:
>
> 1. Is it advisable to define each of my 'models' as separate applications 
> or to incorporate them all into one (my instinct would be to have them 
> separate as their respective functionality is separate).
>

You can have multiple applications share a DB but if they require each in 
order to work, probably they should just be one application with different 
controllers and conditional models.
 

>
> 2. My project will consist of multiple applications (at least 2 but 
> depends on answer to 1st question).  It seems that every application 
> defines it own database.  How do I specify I want every application to use 
> the same database?  In particular,  I only require one set of auth files.
>

I would not because you may run into some migration issues (which of the 
two apps does migrations?) but you can. The DAL(uri, folder=folder). Make 
sure uri is the same and folder point to one and se same folder where to 
store .table files.

Attention. If they are two separate applications it means each of then must 
be able to run without the others. This means each of them must have a 
db.py and must define the tables it needs. They can overlap but do not have 
to.
 

> 3. The menu items will mainly be the same irrespective of which part of 
> the site you are on (e.g. public links, wiki links, member links) - what is 
> the best way to get the respective menu.py modules to generate the menu 
> items?
>
>
Do not understand. 

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


[web2py] Re: VARCHAR or NVARCHAR?

2015-04-15 Thread Massimo Di Pierro
yes but be aware this will affect all the applications. not just this one.

On Wednesday, 15 April 2015 02:43:48 UTC-5, Paolo Valleri wrote:
>
> mssql adapters are quite messy.
> MSSQL2Adapter is the adapter that uses 'nvarchar' as type, however it 
> inherits from MSSQLAdapter, given that it doesn't have the features of 
> MSSQL4Adapter.
> For backward compatibility I don't think MSSQL2Adapter will be never 
> updated to inherits from MSSQL4Adapter.
> My suggestion is to create your own adapter, something like that should 
> work
> from pydal.adapters import ADAPTERS, MSSQL4Adapter, MSSQL2Adapter
> class MyMSSQLAdapter(MSSQL2Adapter, MSSQL4Adapter):
> pass
>
> ADAPTERS.update( {
> 'mymssql': MyMSSQLAdapter
> })
> db = DAL('mymssql://user:pass@host/database')
>
> Your new adapter will have the types of MSSQL2Adapter, the methods of both.
>
> Paolo
>
> On Wednesday, April 15, 2015 at 3:22:10 AM UTC+2, Ray (a.k.a. Iceberg) 
> wrote:
>>
>> Hi there,
>>
>> Long story short, I am now working in a project with web2py trying to 
>> connect to a MSSQL database. My team tends to use the connect string as 
>> "mssql4://..." to take the advantage of the (latest and greatest?) 
>> MSSQL4Adapter, however we also notice from the dal source code mssql.py 
>> that, MSSQL4Adapter defines "string" as "VARCHAR", while an older 
>> MSSQL2Adapter defines "string" as "*N*VARCHAR".
>>
>> It seems there is some other opinion in favor of "NVARCHAR" 
>> 
>>  for 
>> internationalization reason. But then why the web2py MSSQL4dapter chooses 
>> "VARCHAR" instead of "NVARCHAR"? Any insight?
>>
>> Thanks in advance!
>>
>> Regards,
>> Ray
>>
>

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


[web2py] Re: Need advice/help with url rewrite: multiple domains, multiple apps, two apps per domain

2015-04-15 Thread Massimo Di Pierro
Did you look into multi tenancy in web2py?

You can use routes to map the domain into applications but do not use it to 
map domains. Use multi tenancy to have different domains map into different 
slices of the database with their own permissions.

On Wednesday, 15 April 2015 08:00:35 UTC-5, Lisandro wrote:
>
> I have multiple domains with multiple applications. I've gotten it to work 
> using routes.py, with both approaches: parameter-based and pattern-based 
> system. However, there's a couple of things that still I can't achieve.
>
>
> 1) Two applications per each domain
> In my case, each domain serves two applications: the main one, and a 
> second one. I need the main one to be accessible through / url. And I need 
> the second one to be accessible through an url that  is different to the 
> application name. To clarify:
>
>   *http://site1.dev *> should serve 
> *site1* app
>   *http://site1.dev/panel *  > should serve 
> *panel1* app
>
>   *http://site2.dev *> should serve 
> *site2* app
>   *http://site2.dev/panel *  > should serve 
> *panel2* app
>
> Notice that every domain should have the /panel url pointing to the 
> corresponding application (panel1, panel2, etc). 
>
>
> 2) Restrict access to specific application according the domain
> Whether is parameter-based or pattern-based system, all domains endup 
> having access to all applications, for example, http://site1.dev/site2/ 
>  is showing site2 application. But I would like that the domain 
> *site1.dev* can only access the applications site1 and panel1, and 
> nothing else.
>
>
>
> What have I achieved so far? 
>
>  routes.py using parameter-based system -
> # -*- coding: utf-8 -*-
>
> routers = dict(BASE = dict(\
> domains = {\
>   'site1.dev':'site1', \
>   'site2.dev':'site2', \
> }))
>
>
> This approach is working, however I don't know how to make */panel* url 
> to serve *panel1* application. Also, the problem of the point 2 remains: 
> all domains can access all applications.
>
>
>  routes.py using pattern-based system -
> # -*- coding: utf-8 -*-
>
> routes_in = (
> ('.*http://site1.dev.* /*', '/site1'),
> ('.*http://site2.dev.* /*', '/site2'))
>
>
> In this case, in addition to the aforementioned problems, I see an error 
> on every url that is not default/index. That is, http://site1.dev/ shows 
> the default/index, but if I click, let's say, on the register url, the 
> browser attempts to load site1.dev/site1/default/user/register but I 
> receive an "invalid function" error.
>
>
> At this point, I'm a bit lost. I'm using nginx, and I asume all this could 
> be done through nginx's rewrite module (however I would like to keep it 
> inside web2py, for portability reasons).
> Also, I must say I've never worked with regular expressions, and in 
> addition, as you can see, this scenario is a little bit different than the 
> classic one-app-per-domain. 
>
> So, I would really appreciate any advice or help on this. 
>
> P/S: if someone feels sufficiently trained to resolve the situation, 
> please contact me by private, I'm willing to spend some money to resolve 
> this situation in a professional manner.
>

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


[web2py] Re: VARCHAR or NVARCHAR?

2015-04-15 Thread Niphlod
I'm on top of this "issue" in these days, but in the end we will just have 
to create yet another adapter (maybe a mssql*u* , mssql3*u* and mssql4*u*).
The problem is subtle, and goes pretty unnoticed.
If - as I - you create an app with mssql: (or mssql3, or mssql4) which have 
"varchar" type the odbc underlying mappings store happily the utf8 
representation when needed and they fetch it back. Sure, it's garbled but 
from web2py's standpoint what you insert is what you retrieve, so no 
problems there. Bonus points of messiness because on linux there's often 
another middleware involved (freetds), which does the conversion 
implicitely without telling a soul about it.
The problem arises with existing databases when trying to store and fetch 
from nvarchar values, that are NOT inherently converted to/from unicode 
utf8. They need to be passed as u'something' and you'll get back a unicode. 
No str whatsoever.
Still, web2py by default SHOULD use *n*varchar fields for "modern" 
applications, to enable integration with existing databases or just letting 
other applications read correctly the data stored in 'string' fields.

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


[web2py] Re: Prepolulate datetime field internationalization problem

2015-04-15 Thread Sebastián Tromer
That didn't work, but looking at the code of appadmin and 
gluon/validators.py I found a possible solution:

form.vars.from = IS_DATETIME().formatter(request.now)

this is working OK.

Thanks Massimo!

Am Mittwoch, 15. April 2015 10:44:00 UTC-3 schrieb Massimo Di Pierro:
>
> One solution is:
>
> form.vars.from = IS_DATETIME()(request.now)[0]
>
> On Tuesday, 14 April 2015 17:39:01 UTC-5, Sebastián Tromer wrote:
>>
>> Hello everyone!
>>
>> I'm prepopulating a form made with the FORM helper.
>> In the form I have 2 INPUTs of type DATETIME:
>>
>> INPUT(_name='from', _class='datetime', requires = IS_DATETIME())
>>
>> I'm prepolutaing this field with:
>>
>> form.vars.from = request.now
>>
>> and I'm getting something like this:* 2015-04-14 19:31:36.242654*
>>
>> this works OK if the locale is '*en*' but when I have my browser with 
>> locale '*es*'
>> the input should be prepopulated with the format *'%d/%m/%Y 
>> %H:%M:%S.mm' *
>> because web2py (somehow) knows that it must validate using '*es*' locale.
>>
>> So, the question is: How can I prepopulate a datetime input field that 
>> pass validation in any locale?
>>
>> Thanks!
>>
>

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


Re: [web2py] Re: Need advice/help with url rewrite: multiple domains, multiple apps, two apps per domain

2015-04-15 Thread Lisandro Rostagno
Thanks for your time Massimo.
I didn't know about multi-tenancy in web2py, I've just read a little about
that. However I think it's not what I need in this case (but I've just read
about multi-tenancy).

Let me give some additional details of my case regarding databases (I
realised that I didn't mention it in the previous post):

Each domain uses its own database.
Each domain serves two applications.
This two applications share the same database , through symlinks the
following folders: databases, models and private.

So in web2py/applications/ I would have:
...
panel1/
panel1/databases/
panel1/models/
panel1/private/
site1/
site1/databases   --> symlink to ../panel1/databases
site1/models--> symlink to ../panel1/models
site1/private --> symlink to ../panel1/models

... and the same structure repeats itself for site2, site3, etc. A new site
is added from time to time.


Then I would like each domain accesses applications like this:

http://site1.dev/   --->
/site1/default/index
http://site1.dev/panel  --->
/panel1/default/index
http://site1.dev/panel/default/user/login  ---> /panel1/default/user/login

http://site2.dev/   --->
/site2/default/index
http://site2.dev/panel  --->
/panel2/default/index
http://site2.dev/panel/default/user/login  ---> /panel2/default/user/login


So, each domain (each pair of "siteX" and "panelX" applications) will have
its own database, with its own users and permissions.
I don't know if this info helps or I've missed the point somewhere :P


2015-04-15 10:51 GMT-03:00 Massimo Di Pierro :

> Did you look into multi tenancy in web2py?
>
> You can use routes to map the domain into applications but do not use it
> to map domains. Use multi tenancy to have different domains map into
> different slices of the database with their own permissions.
>
>
> On Wednesday, 15 April 2015 08:00:35 UTC-5, Lisandro wrote:
>>
>> I have multiple domains with multiple applications. I've gotten it to
>> work using routes.py, with both approaches: parameter-based and
>> pattern-based system. However, there's a couple of things that still I
>> can't achieve.
>>
>>
>> 1) Two applications per each domain
>> In my case, each domain serves two applications: the main one, and a
>> second one. I need the main one to be accessible through / url. And I need
>> the second one to be accessible through an url that  is different to the
>> application name. To clarify:
>>
>>   *http://site1.dev *> should serve
>> *site1* app
>>   *http://site1.dev/panel *  > should serve
>> *panel1* app
>>
>>   *http://site2.dev *> should serve
>> *site2* app
>>   *http://site2.dev/panel *  > should serve
>> *panel2* app
>>
>> Notice that every domain should have the /panel url pointing to the
>> corresponding application (panel1, panel2, etc).
>>
>>
>> 2) Restrict access to specific application according the domain
>> Whether is parameter-based or pattern-based system, all domains endup
>> having access to all applications, for example, http://site1.dev/site2/
>>  is showing site2 application. But I would like that the domain
>> *site1.dev* can only access the applications site1 and panel1, and
>> nothing else.
>>
>>
>>
>> What have I achieved so far?
>>
>>  routes.py using parameter-based system -
>> # -*- coding: utf-8 -*-
>>
>> routers = dict(BASE = dict(\
>> domains = {\
>>   'site1.dev':'site1', \
>>   'site2.dev':'site2', \
>> }))
>>
>>
>> This approach is working, however I don't know how to make */panel* url
>> to serve *panel1* application. Also, the problem of the point 2 remains:
>> all domains can access all applications.
>>
>>
>>  routes.py using pattern-based system -
>> # -*- coding: utf-8 -*-
>>
>> routes_in = (
>> ('.*http://site1.dev.* /*', '/site1'),
>> ('.*http://site2.dev.* /*', '/site2'))
>>
>>
>> In this case, in addition to the aforementioned problems, I see an error
>> on every url that is not default/index. That is, http://site1.dev/ shows
>> the default/index, but if I click, let's say, on the register url, the
>> browser attempts to load site1.dev/site1/default/user/register but I
>> receive an "invalid function" error.
>>
>>
>> At this point, I'm a bit lost. I'm using nginx, and I asume all this
>> could be done through nginx's rewrite module (however I would like to keep
>> it inside web2py, for portability reasons).
>> Also, I must say I've never worked with regular expressions, and in
>> addition, as you can see, this scenario is a little bit different than the
>> classic one-app-per-domain.
>>
>> So, I would really appreciate any advice or help on this.
>>
>> P/S: if someone feels sufficiently trained to resolve the situation,
>> please contact me by priva

Re: [web2py] LOAD component inside component

2015-04-15 Thread Richard Vézina
Yes I should give it a real try, though I found usage example scarce after
tutorial...

I need to improve my ractive skill

:)

Richard

On Wed, Apr 15, 2015 at 9:36 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Never tried. My guess is that
>
> jQuery.web2py.trap_form is not called for the inner forms.
>
> If you call it manually using jQuery you can make it work.
>
> But I would not. I would figure out how to use ractive.js instead.
>
> On Monday, 13 April 2015 15:00:39 UTC-5, Richard wrote:
>>
>> Hello,
>>
>> I create a page with multiple components inside of it (the index page is
>> basically an empty shell for the components)... But one of there is a form
>> in one of the embed component which as a field with a widget that trigger
>> modal form allowing to insert a value in another table and select this
>> inserted value (something like SELECT_OR_ADD() would do). The problem is
>> that my form embeded in the modal which the widget append to the page with
>> LOAD() don't load... It hang on "loading..."
>>
>> Any idea?
>>
>> Is it even possible to trigger a LOAD inside a LOAD?
>>
>> Thanks
>>
>> Richard
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Leonel Câmara
I think we have to take the performance hit. Hopefully the database will be 
smart enough to keep the records for the users in cache so the slowdown 
won't be that big. Right now this is sort of a security issue:

1. Add @auth.requires_login() to the welcome index function.
2. Register and login, check that you can access index.
3. Remove the user created in 2 from the database.
4. Verify that you can still access login even though your user was removed 
(possibly by the website administrator who doesn't want you to be able to 
see the contents anymore)

If you want you can replace step 3 with:
3. In appadmin set the registration_key to 'blocked' which supposedly would 
block the user.


A lighter alternative could be to add an _after_delete/_after_update 
callback to auth_table that would search and delete any sessions owned by 
the user which would be slow but would not happen very often, this of 
course would only detect and fix this bug if you use the DAL to delete the 
row and not some external database tool. 

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


Re: [web2py] Re: Beginners question about multiple applications

2015-04-15 Thread Richard Vézina
Point 3...

Copy models/menu.py from one app to the other... But it is a bad idea...

Richard

On Wed, Apr 15, 2015 at 9:48 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

>
>
> On Tuesday, 14 April 2015 15:51:31 UTC-5, Peter Gibson wrote:
>>
>> I am a beginner with Web2py but am very impressed with what I have seen
>> and read so far.
>>
>> I have plans to use Web2py for a sizable web project.
>>
>> My project requires a wiki (the built in one will do just fine) and what
>> I would refer to as a number of 'models'.  For example Twitter, Facebook,
>> Accounts, Calendar.
>>
>> I have three questions which I would appreciate guidance on:
>>
>> 1. Is it advisable to define each of my 'models' as separate applications
>> or to incorporate them all into one (my instinct would be to have them
>> separate as their respective functionality is separate).
>>
>
> You can have multiple applications share a DB but if they require each in
> order to work, probably they should just be one application with different
> controllers and conditional models.
>
>
>>
>> 2. My project will consist of multiple applications (at least 2 but
>> depends on answer to 1st question).  It seems that every application
>> defines it own database.  How do I specify I want every application to use
>> the same database?  In particular,  I only require one set of auth files.
>>
>
> I would not because you may run into some migration issues (which of the
> two apps does migrations?) but you can. The DAL(uri, folder=folder). Make
> sure uri is the same and folder point to one and se same folder where to
> store .table files.
>
> Attention. If they are two separate applications it means each of then
> must be able to run without the others. This means each of them must have a
> db.py and must define the tables it needs. They can overlap but do not have
> to.
>
>
>> 3. The menu items will mainly be the same irrespective of which part of
>> the site you are on (e.g. public links, wiki links, member links) - what is
>> the best way to get the respective menu.py modules to generate the menu
>> items?
>>
>>
> Do not understand.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Use model without DAL

2015-04-15 Thread Alessio Varalta
Hi, i have to use the class model but not the connection with the database 
exist and method to take the model and insert the value without 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/d/optout.


Re: [web2py] Application Arquitecture advices

2015-04-15 Thread Sébastien Loix
Thank you Richard, I really appreciate your time to explain it to me.
I think I start understanding it all slowly...

You're right that until I don't have any performance issue I shouldn't try 
to optimize anything. I already created some modules that I import when 
needed (mainly for API calls that I make from Angular, it works really 
great) so a lot of code and functions are there. I will now try to see if 
creating plugins would help at this point or if it is an optimization I 
should do latter on.

As you said, the idea of having conditional models quiet pushes me away as 
I would have to rethink exactly what models depend on others to be able to 
put them in folders... I might get crazy before time :)

Once again thank you for the help!
Best,
Sébastien.

@Steve: I will have a look in the mailing about defining tables inside 
modules. It sounds interesting. Thanks for the info!

On Wednesday, 15 April 2015 15:18:50 UTC+2, Richard wrote:
>
> Sébastien,
>
> Start by making something then when you will need performance you can work 
> on it. I have 155 tables in my app and it is not the model that slow down 
> things... It is more the number of records in these tables that matter so 
> far... I mean, I should use SQLFORM.grid which use paging and load only 
> small amount of records at a time which limit the loading time of grid page 
> which are the page that requires the most processing. You better not define 
> function or class in models files which really degrad performance. You can 
> activate lazy table by respecting some rules when defining your table and 
> set lazy table flag to true (this has no cost and should improve 
> performance). You may also consider models/subfolder which make models file 
> parsing conditionnal to the controller called though it has many chances to 
> make your app less dry (I avoid that)... So as Steve mention there is 
> "Model less app" for which you should found many thread on the mailing-list 
> detailing how to use it. But as I said, just go that way once you really 
> need it. It bring much more work for you and will slow down your pace of 
> developpement if you do that too early.
>
> Richard
>
> On Tue, Apr 14, 2015 at 8:03 PM, 黄祥 > 
> wrote:
>
>> yes, you are right, models executed on every request. but you can use, 
>> model less application (define table using modules, best practice if you 
>> have the same table that been used by more than 1 web2py app) or 
>> conditional models (response.models_to_run)
>> In book you can see an advice :
>>
>>- Minimize the code in models: do not define functions there, define 
>>functions in the controllers that need them or - even better - define 
>>functions in modules, import them and use those functions as needed.
>>
>>
>> ref:
>> http://web2py.com/books/default/chapter/29/04/the-core#Conditional-models
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications
>>
>> http://web2py.com/books/default/chapter/29/13/deployment-recipes#Efficiency-tricks
>>
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread 'sasogeek' via web2py-users
"A lighter alternative could be to add an _after_delete/_after_update 
callback to auth_table that would search and delete any sessions owned by 
the user"
isn't that what cascade does?

On Wednesday, 15 April 2015 16:12:01 UTC+1, Leonel Câmara wrote:
>
> I think we have to take the performance hit. Hopefully the database will 
> be smart enough to keep the records for the users in cache so the slowdown 
> won't be that big. Right now this is sort of a security issue:
>
> 1. Add @auth.requires_login() to the welcome index function.
> 2. Register and login, check that you can access index.
> 3. Remove the user created in 2 from the database.
> 4. Verify that you can still access login even though your user was 
> removed (possibly by the website administrator who doesn't want you to be 
> able to see the contents anymore)
>
> If you want you can replace step 3 with:
> 3. In appadmin set the registration_key to 'blocked' which supposedly 
> would block the user.
>
>
> A lighter alternative could be to add an _after_delete/_after_update 
> callback to auth_table that would search and delete any sessions owned by 
> the user which would be slow but would not happen very often, this of 
> course would only detect and fix this bug if you use the DAL to delete the 
> row and not some external database tool. 
>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Leonel Câmara
Well there's no cascading even if the sessions are in the DB (which they 
don't need to be) since the web2py_session table doesn't reference 
auth_user.

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


[web2py] in model or controller?

2015-04-15 Thread Alex Glaros
Here is a regular requires is_in_db statement:


gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)

db.GovOrgJurisdiction.organizationID.requires = IS_IN_DB(db(gov_org_query), 
'Organization.id', '%(organizationFullName)s',zero=T('choose one'))


is it more efficient to put these two in the controller so they are called 
only when used?

I don't understand if they would get executed needlessly if placed in the 
model if the function that needs it is not used for many sessions

thanks

Alex Glaros

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


[web2py] Re: How to write dynamic part of a select?

2015-04-15 Thread Sébastien Loix
Great thank you!
Quiet new to Python so this one will help me a lot...

On Wednesday, 15 April 2015 00:52:53 UTC+2, Limedrop wrote:
>
> You can do this by building a list of fields and then using the python 
> unpack operator.  For example:
>
> field_list = [db.auth_user.first_name]
> if ask_for_lastname:
> field_list.append(db.auth_user.last_name)
> rows = db(query).select(*field_list)
>
> See 
> https://docs.python.org/2/tutorial/controlflow.html#unpacking-argument-lists
>
>

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


[web2py] Re: Issue with lookup foreign key / format statement in 2.10.3

2015-04-15 Thread Dave S


On Tuesday, April 14, 2015 at 2:29:48 PM UTC-7, Niphlod wrote:
>
> being a bug, we need to ship a new web2py. it got fixed already. we're 
> waiting for Massimo to release a 2.10.4.
>

Is that fix included in the nightly builds yet?
 
/dps


> On Tuesday, April 14, 2015 at 10:51:31 PM UTC+2, wish...@gmail.com wrote:
>>
>> I just discovered, there's already a issue posted..
>>
>> https://groups.google.com/forum/#!topic/web2py/Tog4tdUl400
>> https://github.com/web2py/web2py/issues/904 
>>
>> Are there already any solutions yet?
>>
>> Thanks & cheers
>> Toby
>>
>> wish...@gmail.com:
>>>
>>> Hey guys!
>>>
>>> Did 2.10.3-stable+timestamp.2015.04.02.21.42.07 change something in the 
>>> way* format statements *%(fields)s are handled?
>>>
>>> When referencing another table, the *format statement now seems to be 
>>> ignored*. Instead only the foreign key id is displayed.
>>>
>>> Example 
>>>
>>> I have the following lookup table
>>>
>>> db.define_table('countries',
>>> Field('country', 'string'),
>>> Field('the_geom', 'geometry()'),
>>> Field.Virtual('latitude', lambda row: db(db.countries.id == 
>>> row.countries.id
>>> ).select(db.countries.centroid.st_y()).first()[db.countries.centroid.st_y()]),
>>> Field.Virtual('longitude', lambda row: db(db.countries.id == 
>>> row.countries.id
>>> ).select(db.countries.centroid.st_x()).first()[db.countries.centroid.st_x()]),
>>>* format='%(country)s'*, migrate=True)
>>> 
>>> Another table is referencing this lookup table
>>>
>>> db.define_table('uploads',
>>> Field('country',* db.countries*),
>>> Field('uploaded','date'),
>>> ...
>>> migrate=True)
>>> 
>>> Now I would like to count the number of uploads per country.
>>>
>>> def count_uploads_by_country():
>>> import datetime
>>> from datetime import timedelta
>>> count = db.wifi_zone.id.count()
>>> result = db(db.uploads.uploaded > datetime.date.today() -  
>>> timedelta(days=7)).select(*db.uploads.country*, count, groupby = 
>>> db.uploads.country).render()
>>> return dict(result=result)
>>> 
>>> I would expect that a query on the uploads table would display the 
>>> country name as specified in the format statement, i.e.
>>> *Country  Uploads per Country*
>>> *France* 123
>>> *Italy   *45 
>>> *Germany   *10
>>>
>>> Until recently this worked perfectly, but following the update to 2.10.3 
>>> only the country ids are returned, i.e.
>>>
>>> *Country  Uploads per Country**1*   <-- foreign id instead of name
>>> *2*   <--45 
>>> *3*   <--10
>>>
>>> db._lastsql shows that the country name isn't even queried:
>>> SELECT uploads.country, COUNT(uploads.id) FROM uploads WHERE 
>>> (uploads.last_updated > '2015-04-04') GROUP BY uploads.country;
>>>
>>> Does anybody have a clue, why only the foreign id is displayed, but not 
>>> the country name according to the format statement?
>>>
>>> Cheers 
>>> Toby
>>>
>>>

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


[web2py] Re: in model or controller?

2015-04-15 Thread Lisandro
I think you won't notice any difference in the performance. 
If you care about that query, you don't have to worry, because the query 
will only be executed when the field needs to be rendered (in a form), or 
in the moment of the validation (when submitting the form). 

So I would say that you leave those lines in the model. For mantainance and 
debugging purposes, it will be more practical to keep all database 
definition and restrictions in the model/s file/s. 
The only reason I can imagine to put that requires in the controller is if 
you have different requires in different controller/functions for the same 
db field.

Hope that helps.


El miércoles, 15 de abril de 2015, 14:50:34 (UTC-3), Alex Glaros escribió:
>
> Here is a regular requires is_in_db statement:
>
>
> gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)
>
> db.GovOrgJurisdiction.organizationID.requires = 
> IS_IN_DB(db(gov_org_query), 'Organization.id', 
> '%(organizationFullName)s',zero=T('choose one'))
>
>
> is it more efficient to put these two in the controller so they are called 
> only when used?
>
> I don't understand if they would get executed needlessly if placed in the 
> model if the function that needs them is not used for many sessions
>
> thanks
>
> Alex Glaros
>

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


[web2py] Re: in model or controller?

2015-04-15 Thread Niphlod
putting

db.tablename.fieldname.requires = VALIDATOR()

doesn't do anything BUT if you have lazy_tables turned on, this syntax 
would trigger the "unlazyification" of the table. 
"Minus points" (the reverse concept of "bonus points") for 

db.tablename.fieldname.requires = IS_IN_DB(db.othertable)

syntax that will trigger the "unlazyification" of both tables.

For all intents and purposes, a fixed validator that needs to be there in 
every piece of code interacting with that field is better placed in the 
table definition itself, i.e.

db.define_table('tablename', Field('fieldname', requires=VALIDATOR()))

in this way, when you enable lazy_tables the "unlazyification" would only 
be triggered at the first access of db.tablename throughout your code.

Then again, if for some strict requirement you aren't able to define a 
validator "inside" the table definition, again for the solely purposes of 
lazy_tables, you should use the on_define argument

All of this is explained in the book at chapter 6 (the "on_define" is here 
)
 


On Wednesday, April 15, 2015 at 7:50:34 PM UTC+2, Alex Glaros wrote:
>
> Here is a regular requires is_in_db statement:
>
>
> gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)
>
> db.GovOrgJurisdiction.organizationID.requires = 
> IS_IN_DB(db(gov_org_query), 'Organization.id', 
> '%(organizationFullName)s',zero=T('choose one'))
>
>
> is it more efficient to put these two in the controller so they are called 
> only when used?
>
> I don't understand if they would get executed needlessly if placed in the 
> model if the function that needs them is not used for many sessions
>
> thanks
>
> Alex Glaros
>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Niphlod
I really don't know how to put it without hurting anyone's feeling, but the 
mere fact is that ATM sessions are NOT tied to users. 
This is correct from a logical standpoint because not every site needs 
authentication by default, but still needs to use sessions. 
This is the same kind of situation with auth_groups cached at login: I 
really (and I mean really-really) don't want to check for every request if 
a user is still the member of group A and group B, for the only usecase 
scenario of the administrator dropping the membership on group B for the 
duration of the user session
Given the scenario that the error occurs only when a user is dropped in the 
middle of her/him being authenticated on the site, I wouldn't take a 
performance hit for each and every request. 
The only viable solution would be to tie in some way the user to the 
session (or, even better, sessions to the user, as "homer" can be logged in 
from his mobile AND his laptop at the same time, using two different 
sessions), and try to prune every session associated with the user as soon 
as the record is dropped. Using sessions on db it may be simple. Given that 
sessions can be in cookies, files, databases or memcache/redis too... I'd 
really don't know how to do it without hurting performances.

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


[web2py] Re: Use model without DAL

2015-04-15 Thread Dave S


On Wednesday, April 15, 2015 at 9:56:46 AM UTC-7, Alessio Varalta wrote:
>
> Hi, i have to use the class model but not the connection with the database 
> exist and method to take the model and insert the value without DAL?
>


I'm not sure I understand the question.  The two 2 readings that I think 
you might mean are:

1) "My application doesn't have a database but does use a class design; how 
do I do this in Web2Py?"

I don't know the answer, but I think the book covers part of it.  You might 
begin by reading here:
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications>
No-DB operation is also a topic that shows up in the list from time to 
time.  (As does the the model-less topic.)
I wouldn't go back farther in the archives than 2012, because further back 
the techniques were less well-developed
and not as well supported.

2) "My application already has a database; how do I work with that in 
Web2Py?"

This gets into the question of importing models and migrations, both of 
which have been covered recently in the list.
I would start out with reading
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables>
to look at what is expected of the database.
There are some tools for helping to import models, but they aren't 
completely reliable according to the recent discussions, so you should 
expect that some manual adjustment will be needed.  Once you have the 
models, then a one-time migration should give you the table files Web2Py 
uses to understand your schema, and should then be in a normal maintenance 
mode.

If I completely misunderstood your question, I offer my apologies.  Also, 
I'm pretty much a basic user, and my applications just use simple databases 
on top of the SQLite shipped with Web2Py, but there are many experienced 
users who can give more detail as your questions get more specific.

Good luck!

Dave
/dps

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Leonel Câmara

>
> I really don't know how to put it without hurting anyone's feeling, but 
> the mere fact is that ATM sessions are NOT tied to users


Ahahah I realize that, but when you have authentication they end up being 
tied to the user indirectly in the user variable stored there.


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


Re: [web2py] Re: in model or controller?

2015-04-15 Thread Alex Glaros
Thanks guys,

Alex

On Wed, Apr 15, 2015 at 11:37 AM, Niphlod  wrote:

> putting
>
> db.tablename.fieldname.requires = VALIDATOR()
>
> doesn't do anything BUT if you have lazy_tables turned on, this syntax
> would trigger the "unlazyification" of the table.
> "Minus points" (the reverse concept of "bonus points") for
>
> db.tablename.fieldname.requires = IS_IN_DB(db.othertable)
>
> syntax that will trigger the "unlazyification" of both tables.
>
> For all intents and purposes, a fixed validator that needs to be there in
> every piece of code interacting with that field is better placed in the
> table definition itself, i.e.
>
> db.define_table('tablename', Field('fieldname', requires=VALIDATOR()))
>
> in this way, when you enable lazy_tables the "unlazyification" would only
> be triggered at the first access of db.tablename throughout your code.
>
> Then again, if for some strict requirement you aren't able to define a
> validator "inside" the table definition, again for the solely purposes of
> lazy_tables, you should use the on_define argument
>
> All of this is explained in the book at chapter 6 (the "on_define" is here
> )
>
>
> On Wednesday, April 15, 2015 at 7:50:34 PM UTC+2, Alex Glaros wrote:
>>
>> Here is a regular requires is_in_db statement:
>>
>>
>> gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)
>>
>> db.GovOrgJurisdiction.organizationID.requires =
>> IS_IN_DB(db(gov_org_query), 'Organization.id', 
>> '%(organizationFullName)s',zero=T('choose
>> one'))
>>
>>
>> is it more efficient to put these two in the controller so they are
>> called only when used?
>>
>> I don't understand if they would get executed needlessly if placed in the
>> model if the function that needs them is not used for many sessions
>>
>> thanks
>>
>> Alex Glaros
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/-GAJKa-1yHI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Alex Glaros
Does Lazy Tables setting only have relevance if migration = True?

Is it not necessary if migration = False?

thanks

Alex Glaros

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


[web2py] Re: Ractive example

2015-04-15 Thread Richard
Hello Massimo,

I am looking at w3 right now... I have been able to make it works... I 
would like to know how your plan to integrate this into web2py... What it 
needs to be consider relatively stable for user to use it... Does your 
experiment is sufficiently well thought, it could be generalize and include 
in web2py core? Or could we start working on this bleeding edge concept to 
get away from server side form?

I am want to help as much as I can in the coming days to make this in 
web2py core somehow soon...

I will look to let someone use semantic ui as you point where we can help...

Thanks

Richard

Le samedi 28 mars 2015 12:17:35 UTC-4, Massimo Di Pierro a écrit :
>
> yes it is orthogonal. In fact it uses very little of web2py, almost 
> exclusively the DAL and marginally the web2py template language. 
>
> On Thursday, 26 March 2015 02:48:05 UTC-5, Tim Richardson wrote:
>>
>>
>>
>> On Tuesday, 24 March 2015 13:55:25 UTC+11, Massimo Di Pierro wrote:
>>>
>>> Please look into this: https://github.com/mdipierro/w3
>>> I could very much use your opinions. I am working on it actively these 
>>> days.
>>>


>> Massimo,
>> the w3 'project': it seems to be orthogonal to bootstrap3 support, so in 
>> other words any widget changes won't have anything to do with ractive 
>> support?
>> I'm a bit confused about the ambition for the use of ractive.
>> tim
>>
>

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


[web2py] Re: Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Anthony
No, it saves time in both cases (turning off migrations saves additional 
time).

Anthony

On Wednesday, April 15, 2015 at 3:29:52 PM UTC-4, Alex Glaros wrote:
>
> Does Lazy Tables setting only have relevance if migration = True?
>
> Is it not necessary if migration = False?
>
> thanks
>
> Alex Glaros
>
>

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


[web2py] Re: Ractive example

2015-04-15 Thread Richard
If I understand to style and create a semantic ui form style I would have 
to create new layout and form template?

forms.bs3.html -> forms.semntaic-ui.html

?

Richard

Le mercredi 15 avril 2015 15:30:40 UTC-4, Richard a écrit :
>
> Hello Massimo,
>
> I am looking at w3 right now... I have been able to make it works... I 
> would like to know how your plan to integrate this into web2py... What it 
> needs to be consider relatively stable for user to use it... Does your 
> experiment is sufficiently well thought, it could be generalize and include 
> in web2py core? Or could we start working on this bleeding edge concept to 
> get away from server side form?
>
> I am want to help as much as I can in the coming days to make this in 
> web2py core somehow soon...
>
> I will look to let someone use semantic ui as you point where we can 
> help...
>
> Thanks
>
> Richard
>
> Le samedi 28 mars 2015 12:17:35 UTC-4, Massimo Di Pierro a écrit :
>>
>> yes it is orthogonal. In fact it uses very little of web2py, almost 
>> exclusively the DAL and marginally the web2py template language. 
>>
>> On Thursday, 26 March 2015 02:48:05 UTC-5, Tim Richardson wrote:
>>>
>>>
>>>
>>> On Tuesday, 24 March 2015 13:55:25 UTC+11, Massimo Di Pierro wrote:

 Please look into this: https://github.com/mdipierro/w3
 I could very much use your opinions. I am working on it actively these 
 days.

>
>
>>> Massimo,
>>> the w3 'project': it seems to be orthogonal to bootstrap3 support, so in 
>>> other words any widget changes won't have anything to do with ractive 
>>> support?
>>> I'm a bit confused about the ambition for the use of ractive.
>>> tim
>>>
>>

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


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-15 Thread Niphlod
granted, but discussing to fix this is like - kinda, please grant me a bit 
of exxageration - forcing a user to logout if the developer changes the 
password in the database. 
Identity verification (and the consequent "authorization") is meant to 
happen at a time "x" to enable  accessing the app throughout an - 
optionally limited - period of time, spanning from x onwards. 
The concept is that if you alter the auth_user record at "x + 2" (or a 
membership to a group associated to that user) means that that user can't 
be IDENTIFIABLE and GAIN AUTHORIZATIONS at "x + 3", not that he shouldn't 
be able to use the app from "x + 2" onwards.
On "x + 1" his login and permissions were available.
Maybe the concept to push forward for those kind of strict security 
requirements is - at most - to re-verify identification and authorizations 
once in a while (optionally), as opposed to the current behaviour that is 
to keep the sessions alive indefinitely if the user is continuosly using 
the app.


On Wednesday, April 15, 2015 at 9:14:12 PM UTC+2, Leonel Câmara wrote:
>
> I really don't know how to put it without hurting anyone's feeling, but 
>> the mere fact is that ATM sessions are NOT tied to users
>
>
> Ahahah I realize that, but when you have authentication they end up being 
> tied to the user indirectly in the user variable stored there.
>
>
>

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


[web2py] Re: Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Alex Glaros
When setting lazy_tables = True

I get this error 
 'NoneType' object has no attribute 'upload'

Traceback (most recent call last):
  File "gluon/restricted.py", line 224, in restricted
  File "C:/alex/web2py/web2py/web2py/applications/ES1/models/db.py", line 
56, in 
ckeditor.define_tables()
  File "applications\ES1\modules\plugin_ckeditor.py", line 69, in 
define_tables
minsize=self.settings.file_length_min),
AttributeError: 'NoneType' object has no attribute 'upload'



from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)
ckeditor.define_tables()  ## here is my line # 56
ckeditor.settings.url_upload = URL(request.app, 'plugin_ckeditor', 
'upload', extension='html')
ckeditor.settings.url_browse = URL(request.app, 'plugin_ckeditor', 
'browse', extension='html')

Alex


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


[web2py] Re: Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Niphlod
the code to post to be helped is the INNER exception, not the OUTER one. 
What's on line 69 of plugin_ckeditor ?

On Wednesday, April 15, 2015 at 11:37:35 PM UTC+2, Alex Glaros wrote:
>
> When setting lazy_tables = True
>
> I get this error 
>  'NoneType' object has no attribute 'upload'
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 224, in restricted
>   File "C:/alex/web2py/web2py/web2py/applications/ES1/models/db.py", line 
> 56, in 
> ckeditor.define_tables()
>   File "applications\ES1\modules\plugin_ckeditor.py", line 69, in 
> define_tables
> minsize=self.settings.file_length_min),
> AttributeError: 'NoneType' object has no attribute 'upload'
>
>
>
> from plugin_ckeditor import CKEditor
> ckeditor = CKEditor(db)
> ckeditor.define_tables()  ## here is my line # 56
> ckeditor.settings.url_upload = URL(request.app, 'plugin_ckeditor', 
> 'upload', extension='html')
> ckeditor.settings.url_browse = URL(request.app, 'plugin_ckeditor', 
> 'browse', extension='html')
>
> Alex
>
>
>

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


Re: [web2py] Re: Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Alex Glaros
)
#lazy tables breaks this. Need to force the load of the table
self.settings.table_upload.upload.requires = [
IS_NOT_EMPTY(),
IS_LENGTH(maxsize=self.settings.file_length_max,
  minsize=self.settings.file_length_min),  ## this is
line #69
]


def widget(self, field, value, **attributes):

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


[web2py] AWS S3 SSLv3 Deprecation

2015-04-15 Thread Mark Graves
Hey everyone, 

I realize this is more of a server administration question than web2py in 
specific, but I want to make sure I cover all my bases,

I recently received an email from AWS about their deprecation of SSLv3 in 
connecting to S3.

I have an app deployed behind nginx, but the only ssl protocols I have 
enabled are TLS.

The app does have publicly available URLS for images that are served out of 
s3 which could conceivably be getting crawled somehow, but there is no 
connection that I make over SSLv3 since the POODLE attack to which I'm 
aware.

Anyone have thoughts on how this might be happening, or do you think this 
was just an AWS auto-generated message?

-Mark

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


Re: [web2py] Application Arquitecture advices

2015-04-15 Thread Richard Vézina
Wait if you use Angular you won't really need to care about performance
issue before a lot of time... Since you are not going to experiment be
performance issue except when you reload page...

Richard

On Wed, Apr 15, 2015 at 12:55 PM, Sébastien Loix  wrote:

> Thank you Richard, I really appreciate your time to explain it to me.
> I think I start understanding it all slowly...
>
> You're right that until I don't have any performance issue I shouldn't try
> to optimize anything. I already created some modules that I import when
> needed (mainly for API calls that I make from Angular, it works really
> great) so a lot of code and functions are there. I will now try to see if
> creating plugins would help at this point or if it is an optimization I
> should do latter on.
>
> As you said, the idea of having conditional models quiet pushes me away as
> I would have to rethink exactly what models depend on others to be able to
> put them in folders... I might get crazy before time :)
>
> Once again thank you for the help!
> Best,
> Sébastien.
>
> @Steve: I will have a look in the mailing about defining tables inside
> modules. It sounds interesting. Thanks for the info!
>
> On Wednesday, 15 April 2015 15:18:50 UTC+2, Richard wrote:
>>
>> Sébastien,
>>
>> Start by making something then when you will need performance you can
>> work on it. I have 155 tables in my app and it is not the model that slow
>> down things... It is more the number of records in these tables that matter
>> so far... I mean, I should use SQLFORM.grid which use paging and load only
>> small amount of records at a time which limit the loading time of grid page
>> which are the page that requires the most processing. You better not define
>> function or class in models files which really degrad performance. You can
>> activate lazy table by respecting some rules when defining your table and
>> set lazy table flag to true (this has no cost and should improve
>> performance). You may also consider models/subfolder which make models file
>> parsing conditionnal to the controller called though it has many chances to
>> make your app less dry (I avoid that)... So as Steve mention there is
>> "Model less app" for which you should found many thread on the mailing-list
>> detailing how to use it. But as I said, just go that way once you really
>> need it. It bring much more work for you and will slow down your pace of
>> developpement if you do that too early.
>>
>> Richard
>>
>> On Tue, Apr 14, 2015 at 8:03 PM, 黄祥  wrote:
>>
>>> yes, you are right, models executed on every request. but you can use,
>>> model less application (define table using modules, best practice if you
>>> have the same table that been used by more than 1 web2py app) or
>>> conditional models (response.models_to_run)
>>> In book you can see an advice :
>>>
>>>- Minimize the code in models: do not define functions there, define
>>>functions in the controllers that need them or - even better - define
>>>functions in modules, import them and use those functions as needed.
>>>
>>>
>>> ref:
>>> http://web2py.com/books/default/chapter/29/04/the-
>>> core#Conditional-models
>>> http://web2py.com/books/default/chapter/29/06/the-
>>> database-abstraction-layer#Model-less-applications
>>> http://web2py.com/books/default/chapter/29/13/
>>> deployment-recipes#Efficiency-tricks
>>>
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: in model or controller?

2015-04-15 Thread Alex Glaros
regarding validator "better placed in the table definition itself"

what about the "represents" and "readable/writable" statements?  Is there 
efficiency in moving those to the table definition?

Alex


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


Re: [web2py] Re: in model or controller?

2015-04-15 Thread Richard Vézina
@Simone,

Is that true unlazy... if the .requires = Something is place in controller
file??

I mean, models/files are parsed before controller and if ".requires =
something" is in controller the model should be unlazy anyway...

Richard

On Wed, Apr 15, 2015 at 2:37 PM, Niphlod  wrote:

> putting
>
> db.tablename.fieldname.requires = VALIDATOR()
>
> doesn't do anything BUT if you have lazy_tables turned on, this syntax
> would trigger the "unlazyification" of the table.
> "Minus points" (the reverse concept of "bonus points") for
>
> db.tablename.fieldname.requires = IS_IN_DB(db.othertable)
>
> syntax that will trigger the "unlazyification" of both tables.
>
> For all intents and purposes, a fixed validator that needs to be there in
> every piece of code interacting with that field is better placed in the
> table definition itself, i.e.
>
> db.define_table('tablename', Field('fieldname', requires=VALIDATOR()))
>
> in this way, when you enable lazy_tables the "unlazyification" would only
> be triggered at the first access of db.tablename throughout your code.
>
> Then again, if for some strict requirement you aren't able to define a
> validator "inside" the table definition, again for the solely purposes of
> lazy_tables, you should use the on_define argument
>
> All of this is explained in the book at chapter 6 (the "on_define" is here
> )
>
>
> On Wednesday, April 15, 2015 at 7:50:34 PM UTC+2, Alex Glaros wrote:
>>
>> Here is a regular requires is_in_db statement:
>>
>>
>> gov_org_query = (db.Organization.organizationPrimaryTypeID ==1)
>>
>> db.GovOrgJurisdiction.organizationID.requires =
>> IS_IN_DB(db(gov_org_query), 'Organization.id', 
>> '%(organizationFullName)s',zero=T('choose
>> one'))
>>
>>
>> is it more efficient to put these two in the controller so they are
>> called only when used?
>>
>> I don't understand if they would get executed needlessly if placed in the
>> model if the function that needs them is not used for many sessions
>>
>> thanks
>>
>> Alex Glaros
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Does Lazy Tables setting only have relevance if migration = True?

2015-04-15 Thread Anthony
Looks like the current plugin code is not compatible with lazy tables. A 
quick fix is to just move the "requires" assignment into the field 
definition within the table definition, rather than doing it after the 
table definition.

Anthony

On Wednesday, April 15, 2015 at 5:52:54 PM UTC-4, Alex Glaros wrote:
>
> )
> #lazy tables breaks this. Need to force the load of the table
> self.settings.table_upload.upload.requires = [
> IS_NOT_EMPTY(),
> IS_LENGTH(maxsize=self.settings.file_length_max,
>   minsize=self.settings.file_length_min),  ## this is 
> line #69
> ]
>
>
> def widget(self, field, value, **attributes):
>

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


[web2py] Re: in model or controller?

2015-04-15 Thread Rod Watkins
I have this question as well. And, also, what bout custom widgets assigned 
after the table definition? Does that trigger the unlazification as well?
TIA

On Wednesday, April 15, 2015 at 3:05:23 PM UTC-7, Alex Glaros wrote:
>
> regarding validator "better placed in the table definition itself"
>
> what about the "represents" and "readable/writable" statements?  Is there 
> efficiency in moving those to the table definition?
>
> Alex
>
>
>

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


Re: [web2py] Re: in model or controller?

2015-04-15 Thread Niphlod
in order:

@alex: same thing. if you can stuff everything inside the define_table() 
call you'll be sure to have everything working in the speediest way with 
lazy_tables.

@richard: if you put a requires in the controller, the second that line is 
executed, the table is unlazyed. The whole point of the thread should 
obviously "fenced" into the scenario *what can I do to speedup model 
execution, since the controller function is executed anyway*.

@rod: same thing.

 for everybody: tables stay lazy until someone does db.tablename. 
Pythonicly-speaking, the getattr(tablename) on "db" triggers the 
unlazyification. 

 for evertbody, part two. the toolbar (response.toolbar()) has a 
nice section that lists lazy and non-lazy tables. Checking if your models 
are "in order" just takes three simple steps:
- create a fresh controller, i.e. controllers/testlazy.py
- create a test function in that controller, i.e. 
def does_nothing():
return dict()
- hit appname/testlazy/does_nothing: by default the generic view shows the 
toolbar. If you have all the tables listed as lazy you did a goo job. If 
not, inspect your app to find any db.tablename call.

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


Re: [web2py] Application Arquitecture advices

2015-04-15 Thread Niphlod
this is the uttmost unproper and biased statement I've seen in a while. 
Angular doesn't make your app fast by default, and neither snappier, and 
neither more resource-friendly on the server. If you're good with Angular 
you're just pushing your logic client-side, and avoiding page reloads. This 
doesn't impact performances AT ALL on the server-side.
BTW: Hopefully you're not pushing your entire "smart code bits" of the app 
client-side, either it'll be copied away in a split second. If your 
assumptions are that moving the UI and unimportant parts of your app to the 
client makes your backend faster...well, you have too much unimportant 
code in your app.

On Thursday, April 16, 2015 at 12:02:12 AM UTC+2, Richard wrote:
>
> Wait if you use Angular you won't really need to care about performance 
> issue before a lot of time... Since you are not going to experiment be 
> performance issue except when you reload page...
>

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


[web2py] Re: AWS S3 SSLv3 Deprecation

2015-04-15 Thread Niphlod
the problem would arise only if you connect to S3 to fetch whatever is 
stored there AND you use a library that allows ONLY SSLv3. 
Since most of python modules manage other https algorithms without issues 
AND you're using S3 just as a repo to serve basically static assets, 
there's no issue: Amazon is simply stating that they'll reject ANY request 
made to S3 files from whatever client (usually, your users browsers) using 
SSLv3. 

 Don't worry.  

On Wednesday, April 15, 2015 at 11:54:26 PM UTC+2, Mark Graves wrote:
>
> Hey everyone, 
>
> I realize this is more of a server administration question than web2py in 
> specific, but I want to make sure I cover all my bases,
>
> I recently received an email from AWS about their deprecation of SSLv3 in 
> connecting to S3.
>
> I have an app deployed behind nginx, but the only ssl protocols I have 
> enabled are TLS.
>
> The app does have publicly available URLS for images that are served out 
> of s3 which could conceivably be getting crawled somehow, but there is no 
> connection that I make over SSLv3 since the POODLE attack to which I'm 
> aware.
>
> Anyone have thoughts on how this might be happening, or do you think this 
> was just an AWS auto-generated message?
>
> -Mark
>

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


Re: [web2py] Re: in model or controller?

2015-04-15 Thread Rod Watkins
Thanks Niphlod. That was very useful, especially the toolbar trick. I was 
not aware of that. Many thanks!
Rod

On Wednesday, April 15, 2015 at 3:26:36 PM UTC-7, Niphlod wrote:
>
> in order:
>
> @alex: same thing. if you can stuff everything inside the define_table() 
> call you'll be sure to have everything working in the speediest way with 
> lazy_tables.
>
> @richard: if you put a requires in the controller, the second that line is 
> executed, the table is unlazyed. The whole point of the thread should 
> obviously "fenced" into the scenario *what can I do to speedup model 
> execution, since the controller function is executed anyway*.
>
> @rod: same thing.
>
>  for everybody: tables stay lazy until someone does db.tablename. 
> Pythonicly-speaking, the getattr(tablename) on "db" triggers the 
> unlazyification. 
>
>  for evertbody, part two. the toolbar (response.toolbar()) has a 
> nice section that lists lazy and non-lazy tables. Checking if your models 
> are "in order" just takes three simple steps:
> - create a fresh controller, i.e. controllers/testlazy.py
> - create a test function in that controller, i.e. 
> def does_nothing():
> return dict()
> - hit appname/testlazy/does_nothing: by default the generic view shows the 
> toolbar. If you have all the tables listed as lazy you did a goo job. If 
> not, inspect your app to find any db.tablename call.
>

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


[web2py] A bug in _after_insert callback's document (book)? And more.

2015-04-15 Thread Ray (a.k.a. Iceberg)
Hi folks,

The book describes DAL's _after_insert() callback 

 
as:

The caveat is that depending on the functionality, the callback has 
> different signature.
> This is best explained via some examples.
> >>> db.define_table('person',Field('name'))
> >>> def pprint(*args): print args
> >>> db.person._before_insert.append(lambda f: pprint(f))
> >>> db.person._after_insert.append(lambda f,id: pprint(f,id))   # WRONG 
> SIGNATURE?
> >>> db.person._before_update.append(lambda s,f: pprint(s,f))
> >>> db.person._after_update.append(lambda s,f: pprint(s,f))
> >>> db.person._before_delete.append(lambda s: pprint(s))
> >>> db.person._after_delete.append(lambda s: pprint(s))
> Here f is a dict of fields passed to insert or update, id is the id of 
> the newly inserted record, s is the Set object used for update or delete.
> >>> db.person.insert(name='John')
> ({'name': 'John'},)
> ({'name': 'John'}, 1)# WRONG EXAMPLE?


However, I believe (at least in web2py 2.9.12) the first parameter in 
_after_insert() is NOT a dict, but a Row object. Because, my web2py app 
uses the following code in db.py, trying to send out a validation email to 
new registrated user:

def customized_email_verification(row, row_id):
>
db(db.auth_user.id==row_id).update(registration_key="a random string") 
>  # I need this because my users are not registered from web UI 

db.commit()  # commit BEFORE the time consuming email action, otherwise 
> a parallel requests could cause duplicated record in DB?!

auth.settings.mailer.send(to=row["email"], subject="Hi", 
*message=customized_message 
> % row*)
> db.auth_user._after_insert.append(customized_email_verification)


and it ends up with a very confusing error as:

TypeError: format requires a mapping


Finally I located that line and changed it into:

... customized_message % row.as_dict()


and then it works.

So I am asking for your confirmation and suggest to fix the book 
accordingly.


A followup question. The reason I need my clumsy 
customized_email_verification() in the first place, is because I seemingly 
have to do db.commit() BEFORE the time consuming email sending job. 
Otherwise I saw some randomly duplicated records in my auth_user table. I 
don't know the exact reason but my guess is, the tools.py's define_tables() 
uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
NOT define any "unique=True" in the DB level. Is this considered as a 
defect? Think about this sequence.

Now: the first user creation request is validated but by default not yet 
committed, and now sending email which will likely take 2 seconds
Now + 1 second: Somehow the client could resent same request. This request 
also passes validation, because there is no duplication in DB so far.
Now + 2 second: The email for request #1 has been sent. And record #1 is 
committed into DB.
Now + 3 second: The email for request #2 has been sent. And duplicated 
record #2 is committed into DB.

How can I improve such pattern? Thanks!

Regards,
Ray

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-15 Thread Anthony

>
> However, I believe (at least in web2py 2.9.12) the first parameter in 
> _after_insert() is NOT a dict, but a Row object. Because, my web2py app 
> uses the following code in db.py, trying to send out a validation email to 
> new registrated user:
>
> def customized_email_verification(row, row_id):
>>
> db(db.auth_user.id==row_id).update(registration_key="a random 
>> string")  # I need this because my users are not registered from web UI 
>
> db.commit()  # commit BEFORE the time consuming email action, 
>> otherwise a parallel requests could cause duplicated record in DB?!
>
> auth.settings.mailer.send(to=row["email"], subject="Hi", 
> *message=customized_message 
>> % row*)
>> db.auth_user._after_insert.append(customized_email_verification)
>
>
> and it ends up with a very confusing error as:
>
> TypeError: format requires a mapping
>
>
> Finally I located that line and changed it into:
>
> ... customized_message % row.as_dict()
>
>
> and then it works.
>
> So I am asking for your confirmation and suggest to fix the book 
> accordingly.
>

Yes, the first argument is a Row object, so we should probably update the 
book. However, your error is odd because you can generally use a Row object 
in that way without explicitly converting it to a dictionary. What is the 
content of customized_message and the Row object when this error is 
generated?
 

> A followup question. The reason I need my clumsy 
> customized_email_verification() in the first place, is because I seemingly 
> have to do db.commit() BEFORE the time consuming email sending job. 
> Otherwise I saw some randomly duplicated records in my auth_user table. I 
> don't know the exact reason but my guess is, the tools.py's define_tables() 
> uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
> NOT define any "unique=True" in the DB level. Is this considered as a 
> defect?
>

It's not a defect, just something you have to handle properly in your code. 
You can separately set the unique=True argument when creating the model, 
and that will be enforced by the database, but your problem then is that an 
attempted duplicate entry will end up raising an exception and returning a 
500 response unless you catch and handle the error.

Now: the first user creation request is validated but by default not yet 
> committed, and now sending email which will likely take 2 seconds
> Now + 1 second: Somehow the client could resent same request. This request 
> also passes validation, because there is no duplication in DB so far.
> Now + 2 second: The email for request #1 has been sent. And record #1 is 
> committed into DB.
> Now + 3 second: The email for request #2 has been sent. And duplicated 
> record #2 is committed into DB.
>
> How can I improve such pattern? Thanks!
>

You can do the commit early, as you are now, or you could have the email 
sent asynchronously by putting it in a queue (this would also create a 
better user experience, eliminating the long wait).

Anthony

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


Re: [web2py] Application Arquitecture advices

2015-04-15 Thread Richard Vézina
Ok, you are right... I only said that as long as that page not reload and
he call web2py functions which are not requesting a new page load it will
reduce the amount of server side processing since the function call will
have limited web2py API call...

Richard

On Wed, Apr 15, 2015 at 6:35 PM, Niphlod  wrote:

> this is the uttmost unproper and biased statement I've seen in a while.
> Angular doesn't make your app fast by default, and neither snappier, and
> neither more resource-friendly on the server. If you're good with Angular
> you're just pushing your logic client-side, and avoiding page reloads. This
> doesn't impact performances AT ALL on the server-side.
> BTW: Hopefully you're not pushing your entire "smart code bits" of the app
> client-side, either it'll be copied away in a split second. If your
> assumptions are that moving the UI and unimportant parts of your app to the
> client makes your backend faster...well, you have too much unimportant
> code in your app.
>
> On Thursday, April 16, 2015 at 12:02:12 AM UTC+2, Richard wrote:
>>
>> Wait if you use Angular you won't really need to care about performance
>> issue before a lot of time... Since you are not going to experiment be
>> performance issue except when you reload page...
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: AWS S3 SSLv3 Deprecation

2015-04-15 Thread Mark Graves
Thank you!

Mark Graves

> On Apr 15, 2015, at 5:42 PM, Niphlod  wrote:
> 
> the problem would arise only if you connect to S3 to fetch whatever is stored 
> there AND you use a library that allows ONLY SSLv3. 
> Since most of python modules manage other https algorithms without issues AND 
> you're using S3 just as a repo to serve basically static assets, there's no 
> issue: Amazon is simply stating that they'll reject ANY request made to S3 
> files from whatever client (usually, your users browsers) using SSLv3. 
> 
>  Don't worry.  
> 
>> On Wednesday, April 15, 2015 at 11:54:26 PM UTC+2, Mark Graves wrote:
>> Hey everyone, 
>> 
>> I realize this is more of a server administration question than web2py in 
>> specific, but I want to make sure I cover all my bases,
>> 
>> I recently received an email from AWS about their deprecation of SSLv3 in 
>> connecting to S3.
>> 
>> I have an app deployed behind nginx, but the only ssl protocols I have 
>> enabled are TLS.
>> 
>> The app does have publicly available URLS for images that are served out of 
>> s3 which could conceivably be getting crawled somehow, but there is no 
>> connection that I make over SSLv3 since the POODLE attack to which I'm aware.
>> 
>> Anyone have thoughts on how this might be happening, or do you think this 
>> was just an AWS auto-generated message?
>> 
>> -Mark
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/Gz_8hg9Pv7Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-15 Thread Ray (a.k.a. Iceberg)


On Wednesday, April 15, 2015 at 5:11:22 PM UTC-7, Anthony wrote:
>
> However, I believe (at least in web2py 2.9.12) the first parameter in 
>> _after_insert() is NOT a dict, but a Row object. Because, my web2py app 
>> uses the following code in db.py, trying to send out a validation email to 
>> new registrated user:
>>
>> def customized_email_verification(row, row_id):
>>>
>> db(db.auth_user.id==row_id).update(registration_key="a random 
>>> string")  # I need this because my users are not registered from web UI 
>>
>> db.commit()  # commit BEFORE the time consuming email action, 
>>> otherwise a parallel requests could cause duplicated record in DB?!
>>
>> auth.settings.mailer.send(to=row["email"], subject="Hi", 
>> *message=customized_message 
>>> % row*)
>>> db.auth_user._after_insert.append(customized_email_verification)
>>
>>
>> and it ends up with a very confusing error as:
>>
>> TypeError: format requires a mapping
>>
>>
>> Finally I located that line and changed it into:
>>
>> ... customized_message % row.as_dict()
>>
>>
>> and then it works.
>>
>> So I am asking for your confirmation and suggest to fix the book 
>> accordingly.
>>
>
> Yes, the first argument is a Row object, so we should probably update the 
> book. However, your error is odd because you can generally use a Row object 
> in that way without explicitly converting it to a dictionary. What is the 
> content of customized_message and the Row object when this error is 
> generated?
>

Thanks for the hint, Anthony. You are right, normally "Welcome 
%(first_name)s" % row will just work.

In my case, it looks like the error also has some something to do with the 
i18n, although I did not really use the translation feature. This is the 
last part of the error trace.

  File "C:\REPO\web2py\applications\v1\models\db.py", line 134, in 
email_verification
message=auth.messages.verify_email % row  # .as_dict()
  File "C:\REPO\web2py\gluon\tools.py", line 468, in send
elif message.strip().startswith('",)

No wonder. Now we can use the following line to demonstrate the problem.

>>> "Welcome %(first_name)s, pls click %(link)s" % ("whatever string",)
TypeError: format requires a mapping

I did not further investigate what goes wrong inside the languages.py.


 
>
>> A followup question. The reason I need my clumsy 
>> customized_email_verification() in the first place, is because I seemingly 
>> have to do db.commit() BEFORE the time consuming email sending job. 
>> Otherwise I saw some randomly duplicated records in my auth_user table. I 
>> don't know the exact reason but my guess is, the tools.py's define_tables() 
>> uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
>> NOT define any "unique=True" in the DB level. Is this considered as a 
>> defect?
>>
>
> It's not a defect, just something you have to handle properly in your 
> code. You can separately set the unique=True argument when creating the 
> model, and that will be enforced by the database, 
>

I know I can always define my OTHER tables properly. But now we are talking 
about the web2py built-in auth_user table. Do I have to redefine them in my 
models/db.py EVERY TIME I start a new project? That doesn't sound right. Is 
there any reason we don't want to do that inside gluon/tools.py?

 

> but your problem then is that an attempted duplicate entry will end up 
> raising an exception and returning a 500 response unless you catch and 
> handle the error.
>

I can do this part.
 

>
>
>> Anthony
>

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