Re: [web2py] Re: Django models into web2py

2015-03-28 Thread Phyo Arkar
Web2py DAL is actually a lot more powerful. i use web2py DAL anywhere even
if it is not for web or non web2py project.

On Sun, Mar 29, 2015 at 1:47 AM, Ron Chatterjee achatterjee...@gmail.com
wrote:

 That will be great. Then we can also do django development using web2py
 interface. you rock massimo!




 On Saturday, March 28, 2015 at 12:23:55 PM UTC-4, Massimo Di Pierro wrote:

 This is a backward compatibility problem in the latest web2py. Should be
 fixed in the nightly build (for testers)

 On Friday, 27 March 2015 15:56:05 UTC-5, Ron Chatterjee wrote:

 This is an old web2py blog.

 http://www.web2py.com/AlterEgo/default/show/189

 Did anyone went through the steps and was able to generate the tables? I
 tried but it failed. It didn't work. Is it only valid for polls example
 only or any django models can be used in web2py this way? Not sure.

 I know its not a recommended and I will never deploy an application
 using this method. But wanted to try few django projects and code them up
 in web2py to learn more but I am and kind of feeling lazy to write the
 table from scratch. thought copy and paste will be nice if I can get this
 method to work. Any web2pier wants to try and see what I am doing wrong?

 *I get an error saying:*

 models/db.py 
 http://127.0.0.1:8000/admin/default/edit/try_django_polls/models/db.py, 
 line 62, in module
 class Poll(Model):
   File applications\try_django_polls\modules\django.py, line 145, in 
 __new__
 fields=[db.Field(key,**value.serial(name,db)) for key,value in 
 attrs.items() if hasattr(value,'serial') and not 
 isinstance(value,ManyToManyField)]
   File ...\Desktop\web2py_src\web2py\gluon\dal\base.py, line 893, in 
 __getattr__
 return ogetattr(self, key)

 AttributeError: 'DAL' object has no attribute 'Field'

  --
 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: Web2py: Create a CSV file to download for an executesql result

2015-03-28 Thread Brian M
Here's an old post with the solution that I use for this

https://groups.google.com/d/msg/web2py/4QhEULmJ8YE/aNBcJv81RocJ

Yep, I've got a processing app that spits out all sorts of csv files based 
on data gathered from multiple sources.

Here's a little helper function I use

def csv_export(records, column_names, fields, mode = 'dal'):
Export DAL result set, list of dicts or list of lists to CSV stream 
for returning to user
Arguments:
records = the data to be returned
column_names (list)= the column names/headings for the first row in the 
CSV file
Example ['First Name', 'Last Name', 'Email']
fields (list) = the names of the fields (as they appear in records) in 
the order they
should be in the CSV. Example ['f_name', 'l_name', 
'email']
or ['table_a.f_name', 'table_a.l_name', 'table_b.email']
If mode = 'list' and your records are in the correct 
order then fields may be None
otherwise use [1,3,0] if you list is in a different 
order
mode (string) = what type of data is in records? 'dal' (Default), 
'dict' or 'list'
'dal' if records came from a regular dal query (Default)
'dict' if records are a list of dicts (for example 
using db.executesql() with as_dict = True)
'list' if records are a list of lists/tuples (for 
example using db.executesql() with as_dict = False)



#create fake file object
import cStringIO
file = cStringIO.StringIO()
#setup csv writer
import csv
csv_file = csv.writer(file)
#write first row withspecified column headings/names
csv_file.writerow(column_names)
#which mode - dal or dict?
if mode.lower() == 'dal' or mode.lower() == 'dict':
for record in records:
csv_file.writerow([record[field] for field in fields])
elif mode.lower() == 'list':
if fields == None:
csv_file.writerows(records)
else:
for record in records:
csv_file.writerow([record[field] for field in fields])
return file





Then in a controller you can have something like


csv_stream = csv_export(processed_dataset, column_names, fields, mode = 
'dict')
response.headers['Content-Type']='application/vnd.ms-excel'
response.headers['Content-Disposition']='attachment; 
filename=data_for_%s.csv' % date.today()
return csv_stream.getvalue()  



which will cause browser to download the csv file with your chosen filename

you could also turn around and save the datafile to the filesystem if you 
wanted.

Hope this helps!
Brian

On Saturday, March 28, 2015 at 11:14:44 AM UTC-5, Adam Scarlat wrote:

 Hi, 

 I use an external mysql database in my application and use the 
 executesql(str(query), as_dict=True)) to run queries on it.
 I want to have a download link for a csv files of different queries in my 
 application. If I were to work locally I would have used the following 
 mysql command:

 'SELECT * FROM SOME_TABLE INTO OUTFILE '/tmp/test1.csv' FIELDS TERMINATED 
 BY ',' ENCLOSED BY '' LINES TERMINATED BY '\n''

 In my application a user can select certain criteria, a query is built in 
 the controller according to the criteria and is executed with the 
 executesql() method
 which returns a dictionary like object. 

 My question is: is there a way to make a download link in the view to 
 download a csv file of results returned by the executesql() method?

 Thank you!
 Adam


-- 
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: Belongs not working

2015-03-28 Thread Leonardo Pires Felix
Even on documentation has belongs checking if a value(or iterable obj) is 
in the field:
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs

belongs

The SQL IN operator is realized via the belongs method which returns true 
when the field value belongs to the specified set (list or tuples):

 for row in db(db.log.severity.belongs((1, 2))).select():
print row.event
port scan
xss injection



Em sábado, 28 de março de 2015 18:31:31 UTC-3, Anthony escreveu:

 If you want to see if a particular item is in the stored list, the correct 
 method has always been .contains(), not .belongs(). Using the later doesn't 
 really make sense in this context (.belongs() is for checking whether a 
 single value stored in a database field is in a list of values -- we are 
 doing the opposite here, checking whether a single value is in a list 
 stored in a database field).

 Anthony

 On Saturday, March 28, 2015 at 12:26:55 PM UTC-4, Leonardo Pires Felix 
 wrote:

 Looks like that the belongs function to the list:type has changed to 
 the contains, that's correct?

 Em sábado, 28 de março de 2015 12:43:56 UTC-3, Leonardo Pires Felix 
 escreveu:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, 
 requires=[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(
 days=1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM
 .widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not 
 None else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, 
 default=True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, 
 label=db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.
 notificacao_sms,regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.
 notificacao_sms,regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Django models into web2py

2015-03-28 Thread Ron Chatterjee
I agree with Phyo. Syntax is lot better and readable and close to sql than 
ORM

On Saturday, March 28, 2015 at 4:28:24 PM UTC-4, Phyo Arkar wrote:

 Web2py DAL is actually a lot more powerful. i use web2py DAL anywhere even 
 if it is not for web or non web2py project.

 On Sun, Mar 29, 2015 at 1:47 AM, Ron Chatterjee achatte...@gmail.com 
 javascript: wrote:

 That will be great. Then we can also do django development using web2py 
 interface. you rock massimo!




 On Saturday, March 28, 2015 at 12:23:55 PM UTC-4, Massimo Di Pierro wrote:

 This is a backward compatibility problem in the latest web2py. Should be 
 fixed in the nightly build (for testers)

 On Friday, 27 March 2015 15:56:05 UTC-5, Ron Chatterjee wrote:

 This is an old web2py blog.

 http://www.web2py.com/AlterEgo/default/show/189

 Did anyone went through the steps and was able to generate the tables? 
 I tried but it failed. It didn't work. Is it only valid for polls example 
 only or any django models can be used in web2py this way? Not sure. 

 I know its not a recommended and I will never deploy an application 
 using this method. But wanted to try few django projects and code them up 
 in web2py to learn more but I am and kind of feeling lazy to write the 
 table from scratch. thought copy and paste will be nice if I can get this 
 method to work. Any web2pier wants to try and see what I am doing wrong?

 *I get an error saying:*

 models/db.py 
 http://127.0.0.1:8000/admin/default/edit/try_django_polls/models/db.py, 
 line 62, in module
 class Poll(Model):
   File applications\try_django_polls\modules\django.py, line 145, in 
 __new__
 fields=[db.Field(key,**value.serial(name,db)) for key,value in 
 attrs.items() if hasattr(value,'serial') and not 
 isinstance(value,ManyToManyField)]
   File ...\Desktop\web2py_src\web2py\gluon\dal\base.py, line 893, in 
 __getattr__
 return ogetattr(self, key)

 AttributeError: 'DAL' object has no attribute 'Field' 

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/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: WEB2PY Certificate ?

2015-03-28 Thread Ron Chatterjee
I see. Thats a great idea. So people who will be certified will be able to 
post as a registered developer for web2py. That will be nice. Last time I 
went to a vet he almost took my kidney out, and all I was complaining about 
was an ankle twist! lol.

you rock massimo!

On Saturday, March 28, 2015 at 12:21:03 PM UTC-4, Massimo Di Pierro wrote:

 Since experts4solutions is now a registered company, I use it for 
 consulting. I am planning to offer web2py certifications (I know I have 
 said before but I am actually almost ready) and I plan to list certified 
 developers and host the developers web pages.

 Massimo

 On Saturday, 28 March 2015 11:14:44 UTC-5, Carlos Costa wrote:

 And what is the future of experts4solutions ?

 2015-03-25 0:19 GMT-03:00 Massimo Di Pierro massimo@gmail.com 
 javascript::

 Looks like you did. :-O

 Anyway, the point of a university is that we do not usually teach 
 courses about specific technologies. We use specific technologies to serve 
 more abstract purposes. For example I teach CSC438 which is about the 
 internal design of web frameworks and I use web2py as one of the (main) 
 examples.

 We use Python in many classes but the goal is not teach python. The goal 
 is to teach programming (for, if, def, return).

 Anyway, it would be nice to have more material about teaching web2py 
 and/or teaching with web2py. Perhaps we could crowdsource the effort. If I 
 have a list of 10 topics that people would want me to cover in detail I can 
 make some short videos. I am sure other people here would be willing to 
 help.

 Massimo



 On Tuesday, 24 March 2015 12:39:02 UTC-5, Ron Chatterjee wrote:

 We should clone you saying!? lol. jk:-). Would be nice to have an 
 advance course like that. Someone should write to the dean and sign me up.



 On Tuesday, March 24, 2015 at 12:19:23 PM UTC-4, Massimo Di Pierro 
 wrote:

 No. Perhaps there should be. But not yet. 

 On Tuesday, 24 March 2015 08:40:40 UTC-5, Ron Chatterjee wrote:

 Massimo,

 On that note. I have seen some of that lecture and it seems very 
 undergrad level. Is there a grad level course that you can offer where 
 we 
 can go through each API (or the most important one). Lets create few 
 stand 
 alone code and go line by line to understand how the framework is made? 
 Get 
 into more depth and complexity. Lets say someone is already a web2py 
 developer but he wants to push the envelop and become an expert or even 
 better (since no one can't clone you. lol). Is there a course like that?

 Ron


 On Tuesday, March 24, 2015 at 3:34:26 AM UTC-4, 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 


 Carlos J. Costa
 Cientista da Computação  | BS Computer Science 
 Esp. Gestão em Telecom   | PgC Telecom Mangement
 º))
  


-- 
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: Django models into web2py

2015-03-28 Thread Ron Chatterjee
That will be great. Then we can also do django development using web2py 
interface. you rock massimo!



On Saturday, March 28, 2015 at 12:23:55 PM UTC-4, Massimo Di Pierro wrote:

 This is a backward compatibility problem in the latest web2py. Should be 
 fixed in the nightly build (for testers)

 On Friday, 27 March 2015 15:56:05 UTC-5, Ron Chatterjee wrote:

 This is an old web2py blog.

 http://www.web2py.com/AlterEgo/default/show/189

 Did anyone went through the steps and was able to generate the tables? I 
 tried but it failed. It didn't work. Is it only valid for polls example 
 only or any django models can be used in web2py this way? Not sure. 

 I know its not a recommended and I will never deploy an application using 
 this method. But wanted to try few django projects and code them up in 
 web2py to learn more but I am and kind of feeling lazy to write the table 
 from scratch. thought copy and paste will be nice if I can get this method 
 to work. Any web2pier wants to try and see what I am doing wrong?

 *I get an error saying:*

 models/db.py 
 http://127.0.0.1:8000/admin/default/edit/try_django_polls/models/db.py, 
 line 62, in module
 class Poll(Model):
   File applications\try_django_polls\modules\django.py, line 145, in 
 __new__
 fields=[db.Field(key,**value.serial(name,db)) for key,value in 
 attrs.items() if hasattr(value,'serial') and not 
 isinstance(value,ManyToManyField)]
   File ...\Desktop\web2py_src\web2py\gluon\dal\base.py, line 893, in 
 __getattr__
 return ogetattr(self, key)

 AttributeError: 'DAL' object has no attribute 'Field' 



-- 
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: Belongs not working

2015-03-28 Thread Anthony
If you want to see if a particular item is in the stored list, the correct 
method has always been .contains(), not .belongs(). Using the later doesn't 
really make sense in this context (.belongs() is for checking whether a 
single value stored in a database field is in a list of values -- we are 
doing the opposite here, checking whether a single value is in a list 
stored in a database field).

Anthony

On Saturday, March 28, 2015 at 12:26:55 PM UTC-4, Leonardo Pires Felix 
wrote:

 Looks like that the belongs function to the list:type has changed to 
 the contains, that's correct?

 Em sábado, 28 de março de 2015 12:43:56 UTC-3, Leonardo Pires Felix 
 escreveu:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, requires
 =[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(
 days=1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM.
 widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not 
 None else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, default
 =True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, 
 label=db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms
 ,regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms
 ,regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Belongs not working

2015-03-28 Thread Paolo Valleri
Which web2py version was working ? What was the sql output?
As you mentioned, replacing belongs with contains fixed the problem.



On Saturday, March 28, 2015 at 6:53:50 PM UTC+1, Leonardo Pires Felix wrote:

 Not working too on the version for testers, in this case using sqlite. 
 Example:

 db.define_table(business_day,
Field(description, notnull=True),
Field(week_days, list:integer, notnull=True))

 db.business_day.insert(description='first week january 2015', week_days=[3
 ,4])
 1L
  print db(db.business_day.id0).select()
 business_day.id,business_day.description,business_day.week_days
 1,first week january 2015,|3|4|

  db(db.business_day.week_days.belongs([3])).select()
 Rows (0)

  db(db.business_day.week_days.belongs([3]))._select()
 SELECT  business_day.id, business_day.description, 
 business_day.week_days FROM business_day WHERE (business_day.week_days IN 
 ('|3|'));


 Em sábado, 28 de março de 2015 13:27:28 UTC-3, Massimo Di Pierro escreveu:

 Can you please try the for testers version on the web site? Can you 
 provide a simpler example to reproduce the problem?

 On Saturday, 28 March 2015 10:43:56 UTC-5, Leonardo Pires Felix wrote:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, 
 requires=[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(
 days=1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM
 .widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not 
 None else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, 
 default=True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, 
 label=db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.
 notificacao_sms,regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.
 notificacao_sms,regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Belongs not working

2015-03-28 Thread Anthony
Yes, but you are doing the opposite here. You are not checking whether a field 
value belongs to a list - you are checking whether a list stored in a field 
contains a particular value. The book section on the list:-type fields 
specifically says to use .contains for this purpose. This is not a job for 
.belongs.

Anthony

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


[web2py] saving and dumping variables

2015-03-28 Thread Ron Chatterjee
Wondering how to save and dump variables from web2py to a static python 
ide. In other words, 

 import cPickle
  b = cPickle.dumps(a)
  c = cPickle.loads(b)

That seems to work only inside a web2py session. Once I close the web2py 
application and if I want to load up the saved variable using an external 
IDE. c=cPickle.loads(b) doesn't work. 

Any thoughts?:-)


-- 
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: Django models into web2py

2015-03-28 Thread Massimo Di Pierro
This is a backward compatibility problem in the latest web2py. Should be 
fixed in the nightly build (for testers)

On Friday, 27 March 2015 15:56:05 UTC-5, Ron Chatterjee wrote:

 This is an old web2py blog.

 http://www.web2py.com/AlterEgo/default/show/189

 Did anyone went through the steps and was able to generate the tables? I 
 tried but it failed. It didn't work. Is it only valid for polls example 
 only or any django models can be used in web2py this way? Not sure. 

 I know its not a recommended and I will never deploy an application using 
 this method. But wanted to try few django projects and code them up in 
 web2py to learn more but I am and kind of feeling lazy to write the table 
 from scratch. thought copy and paste will be nice if I can get this method 
 to work. Any web2pier wants to try and see what I am doing wrong?

 *I get an error saying:*

 models/db.py 
 http://127.0.0.1:8000/admin/default/edit/try_django_polls/models/db.py, 
 line 62, in module
 class Poll(Model):
   File applications\try_django_polls\modules\django.py, line 145, in __new__
 fields=[db.Field(key,**value.serial(name,db)) for key,value in 
 attrs.items() if hasattr(value,'serial') and not 
 isinstance(value,ManyToManyField)]
   File ...\Desktop\web2py_src\web2py\gluon\dal\base.py, line 893, in 
 __getattr__
 return ogetattr(self, key)

 AttributeError: 'DAL' object has no attribute 'Field' 


-- 
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: Belongs not working

2015-03-28 Thread Leonardo Pires Felix
Looks like that the belongs function to the list:type has changed to 
the contains, that's correct?

Em sábado, 28 de março de 2015 12:43:56 UTC-3, Leonardo Pires Felix 
escreveu:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, requires
 =[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(days
 =1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM.
 widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not None 
 else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, default=
 True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, label
 =db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
 regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
 regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Web2py security questions

2015-03-28 Thread Massimo Di Pierro
perhaps we should but being able to frame pages is something that people 
always want as a feature.

On Saturday, 28 March 2015 09:52:58 UTC-5, Anthony wrote:

 On Friday, March 27, 2015 at 7:12:02 PM UTC-4, Scott Hunter wrote:

 1. Does web2py employ, allow or support any anti-framing measures, to 
 prevent an attack that can trick the user into clicking on the link by 
 framing the original page and showing a layer on top of it with dummy 
 buttons.  If so, any pointers to either documentation describing how these 
 are present, or how one would enable them, would be appreciated. 
  Supposedly not employing such measures can allow clickjacking and/or CSRF.


 I don't think web2py does anything by default, but you can add protection 
 yourself by setting the X-Frame-Options and/or Content-Security-Policy 
 headers in a model file:

 response.headers['X-Frame-Options'] = SAMEORIGIN
 response.headers['Content-Security-Policy'] = frame-ancestors 'self'

 Perhaps web2py should set the Content-Security-Policy header by default, 
 maybe with an optional configurable whitelist of allowed ancestors.

 Note, you can also configure your server (e.g., nginx, Apache) to 
 automatically set the above headers.

 You can also implement a Javascript defense, such as this one 
 https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script
 .
  


 2. Does, or can, web2py prevent the browser from prompting the user to 
 save populated values for later reuse?


 It doesn't by default (as that is a user preference configurable in the 
 browser), but nothing stops you from using the various available solutions, 
 such as setting the autocomplete attribute of form and input elements to 
 off (which can be done on the server or via Javascript) or using 
 Javascript to reset the form after rendering.

 Anthony



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


[web2py] Re: Belongs not working

2015-03-28 Thread Massimo Di Pierro
Can you please try the for testers version on the web site? Can you 
provide a simpler example to reproduce the problem?

On Saturday, 28 March 2015 10:43:56 UTC-5, Leonardo Pires Felix wrote:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, requires
 =[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(days
 =1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM.
 widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not None 
 else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, default=
 True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, label
 =db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
 regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
 regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Table Migration on GAE

2015-03-28 Thread Massimo Di Pierro
http://web2py.com/examples/default/download

On Saturday, 28 March 2015 11:14:44 UTC-5, Sébastien Loix wrote:

 Hello Massimo,
 Where can I find the version for tester?
 Also I am using SQL with MySQL with GAE through Cloud SQL, so the 
 check_reserved keywords is necessary right?

 Once I have the new version I will test it and report here.
 Thanks


 El martes, 24 de marzo de 2015, 17:32:09 (UTC+1), Massimo Di Pierro 
 escribió:

 I spoke too soon. Please wait I post a new version for testers. I will 
 email this list.
 Then try:

 db = DAL('google:sql://[app-name]:[db-name]/[table-name]')
 ...
 auth.settings.extra_fields['auth_user'] = [Field('username_fb', 
 length=128, default=, unique=True, writable=False, readable=False)]
 auth.define_tables(username=False, signature=False)

 consider that migrate_enabled is true by default so no need to set it. 
 Also the check_reserved keywords is designed for SQL and not GAE. It does 
 not hurt but it is not necessary. I do not swear by lazy_table because they 
 have some caveats. Let's try without that.

 Can you help us check if this work? If, not what behaviour do you see? Do 
 you get a traceback?


 On Tuesday, 24 March 2015 11:18:06 UTC-5, Sébastien Loix wrote:

 Thank you for the answer.
 Could you explain a bit more the there are no migrations on GAE, is it 
 only for the actual version and the fixed version will solve it?
 I realised that I am using the 2.10.0-beta version of web2py. The one 
 downloaded from the main download page.
 Thanks for the help

 El martes, 24 de marzo de 2015, 8:31:51 (UTC+1), Massimo Di Pierro 
 escribió:

 1) there are no migrations on GAE, web2py will still create .table 
 files but they serve no purpose.
 2) GAE support is broken in 2.9.12. It works in trunk pydal and we will 
 released a fixed version this week

 On Monday, 23 March 2015 21:53:04 UTC-5, Sébastien Loix wrote:

 Hi,

 I am having difficulties with table migration on GAE.

 I deployed perfectly in the Google App Engine and everything is 
 working fine.

 I then needed to make some change in the auth_user adding some extra 
 field but when I deploy again the new version, the migration doesn't 
 occur 
 and the new column is not created.

 Here is the code used:

 db = DAL('google:sql://[app-name]:[db-name]/[table-name]', 
 migrate_enabled=True, check_reserved=['all'], lazy_tables=True)

 then below:

 auth.settings.extra_fields['auth_user'] = [Field('username_fb', 
 length=128, default=, unique=True, writable=False, readable=False)]
 auth.define_tables(username=False, signature=False, migrate=True)

 Any idea why the migration doesn't occur?

 Is there a way to force web2py to do migration somehow?

 Thanks for the help!
 Best,
 Sebastian



-- 
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: Help with two Python operators

2015-03-28 Thread Massimo Di Pierro
   query = db.flatpage.f==request.function

is the same as 

   query = query  (db.flatpage.f==request.function)

Build a query from another query
Instead

   alphabetical = User.first_name|User.last_name

is the same as 

   alphabetical = [User.first_name, User.last_name]

makes a list of fields to use for sorting.

On Saturday, 28 March 2015 11:14:52 UTC-5, Paul McDonald wrote:

 In the Web2py Application Development Cookbook:

  p82the  =  operators


  if not form:

 # search flatpage according to the current request

 query = db.flatpage.c==request.controller

 query = db.flatpage.f==request.function *-  what is going on 
 here?*

 if request.args:

 query = db.flatpage.args==request.args(0)

 else:

 query = (db.flatpage.args==None)|(db.flatpage.args=='')

 query = db.flatpage.lang==lang


  Alos, p69the   |   bianary or operator

 alphabetical = User.first_name|User.last_name   * --  what is 
 going on here?   *
   

   Can anyone explain what these are doing?
 Thank you in advance


 Paul
   


-- 
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: Write dynamic query in DAL without extra nested parentheses

2015-03-28 Thread JorgeH
from Massimo, in another reply today 
(https://groups.google.com/forum/#!topic/web2py/RqSBO2dZU4E) :

 query = db.flatpage.f==request.function



is the same as 


   query = query  (db.flatpage.f==request.function)


Build a query from another query


On Saturday, March 28, 2015 at 11:14:44 AM UTC-5, gb wrote:

 What is the DAL Code to generate a query like this:
 SELECT * FROM product WHERE product.id=1 OR product.id=2 OR product.id=3 
 OR product.id product.id=4 OR product.id=5;
 or even:
 SELECT * FROM product WHERE (product.id=1) OR (product.id=2) OR (
 product.id=3) OR (product.id=4) OR (product.id=5);

 I've tried both the DAL code approaches below and I always end up with 
 crazy parentheses nesting which will eventually crash the DB driver e.g. in 
 sqlite: class 'sqlite3.OperationalError' parser stack overflow

 Is there another way to use the DAL, or is my only option to write the 
 SQL manually?

 db.define_table(product)

 selected_ids = [1,2,3,4,5]
 query = []
 for pid in selected_ids:
 query.append(db.product.id == pid)

 query = reduce(lambda a,b:a|b,query)
 #Ouputs this : (product.id = 1) OR (product.id = 2)) OR (
 product.id = 3)) OR (product.id = 4)) OR (product.id = 5))


 
 selected_ids = [1,2,3,4,5]
 query = []
 for pid in selected_ids:
 query |= db.product.id == pid

 #I get a bonus parenthesis with this method ((product.id = 1) OR 
 ) OR (product.id = 2)) OR (product.id = 3)) OR (product.id = 4)) OR (
 product.id = 5))


-- 
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: Is web2py is good for below requirements?

2015-03-28 Thread JorgeH
Web2py meet those requirements easily.

As for a comparison, I let that answer to others.

On Saturday, March 28, 2015 at 11:14:44 AM UTC-5, Anandhakumar 
Radhakrishnan wrote:

 Hi,


 I have planned to create a website with certain requirement please tell 
 whether this will support in web2py.

 1. Dynamic Page
 2. Multi Vendors like olx.com
 3. Email Services 
 4. Comparison charts

 And please tell why the web2py is best compare to other frame works in 
 python.


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


[web2py] Re: Web2py security questions

2015-03-28 Thread Anthony
On Friday, March 27, 2015 at 7:12:02 PM UTC-4, Scott Hunter wrote:

 1. Does web2py employ, allow or support any anti-framing measures, to 
 prevent an attack that can trick the user into clicking on the link by 
 framing the original page and showing a layer on top of it with dummy 
 buttons.  If so, any pointers to either documentation describing how these 
 are present, or how one would enable them, would be appreciated. 
  Supposedly not employing such measures can allow clickjacking and/or CSRF.


I don't think web2py does anything by default, but you can add protection 
yourself by setting the X-Frame-Options and/or Content-Security-Policy 
headers in a model file:

response.headers['X-Frame-Options'] = SAMEORIGIN
response.headers['Content-Security-Policy'] = frame-ancestors 'self'

Perhaps web2py should set the Content-Security-Policy header by default, 
maybe with an optional configurable whitelist of allowed ancestors.

Note, you can also configure your server (e.g., nginx, Apache) to 
automatically set the above headers.

You can also implement a Javascript defense, such as this one 
https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script
.
 


 2. Does, or can, web2py prevent the browser from prompting the user to 
 save populated values for later reuse?


It doesn't by default (as that is a user preference configurable in the 
browser), but nothing stops you from using the various available solutions, 
such as setting the autocomplete attribute of form and input elements to 
off (which can be done on the server or via Javascript) or using 
Javascript to reset the form after rendering.

Anthony

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


[web2py] Re: IMPORTANT - WEB2PY CONSULTING

2015-03-28 Thread DJ
Hi Dave,

We are based in New York City since 2009. 

www.10biosystems.com

-Sebastian

On Tuesday, March 17, 2015 at 1:39:00 PM UTC-4, Dave S wrote:



 On Monday, March 16, 2015 at 6:57:54 PM UTC-7, DJ wrote:

 Hi Massimo,

 10Biosystems.com has been doing web2Py consulting  bioinformatics 
 product development for lifesciences  healthcare for a few years now. 
 Kindly add us!

 Thanks,
 Sebastian




 Is there a website or contact information?  Which region are you located 
 in?

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


Re: [web2py] Re: IMPORTANT - WEB2PY CONSULTING

2015-03-28 Thread DJ
Hey Kiran,

Thanks for pointing that out! Just added a link to Web2Py on my site.

-Sebastian

On Tuesday, March 17, 2015 at 1:44:06 PM UTC-4, Kiran Subbaraman wrote:

  This seems to be the site: http://10biosystems.com

 Also, *Sebastian*, it would be helpful if you can refer to web2py on your 
 site too; especially since you mention the open source stack that is 
 powering this site (http://10biosystems.com/init/default/mobile)

 
 Kiran Subbaramanhttp://subbaraman.wordpress.com/about/

 On Tue, 17-03-2015 11:09 PM, Dave S wrote:
  


 On Monday, March 16, 2015 at 6:57:54 PM UTC-7, DJ wrote: 

 Hi Massimo, 

  10Biosystems.com has been doing web2Py consulting  bioinformatics 
 product development for lifesciences  healthcare for a few years now. 
 Kindly add us!

  Thanks,
 Sebastian
  
  


 Is there a website or contact information?  Which region are you located 
 in?

 /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+un...@googlegroups.com javascript:.
 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: saving and dumping variables

2015-03-28 Thread Anthony
You are simply saving the dump to a variable, which does not persist across 
separate Python processes. If you want to be able to re-load the object, 
you need some form of persistence, such as writing to a file or saving to a 
database.

Anthony

On Saturday, March 28, 2015 at 9:21:18 AM UTC-4, Ron Chatterjee wrote:

 Wondering how to save and dump variables from web2py to a static python 
 ide. In other words, 

  import cPickle
   b = cPickle.dumps(a)
   c = cPickle.loads(b)

 That seems to work only inside a web2py session. Once I close the web2py 
 application and if I want to load up the saved variable using an external 
 IDE. c=cPickle.loads(b) doesn't work. 

 Any thoughts?:-)




-- 
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: fields strings to variable for fields=fields

2015-03-28 Thread Anthony
On Friday, March 27, 2015 at 3:39:38 PM UTC-4, LoveWeb2py wrote:

 Hi JorgeH,

 I didn't want to use eval due to code injection, but here is what I ended 
 up using and it worked.

 field_list = ['db.mytable.field1', 'db.mytable.field2'] 

 fields = [getattr(db.mytable, i.split(.)[-1] for i in field_list]


Note, you don't need to use getattr() -- just do:

[db.mytable[i.split('.')[-1]] for i in field_list]

A better option might be to change the function that returns the list so it 
returns just the field names (why does it need to return fields in 
'db.mytable.field1' format?).

Anthony

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


[web2py] Web2py: Create a CSV file to download for an executesql result

2015-03-28 Thread Adam Scarlat
Hi, 

I use an external mysql database in my application and use the 
executesql(str(query), as_dict=True)) to run queries on it.
I want to have a download link for a csv files of different queries in my 
application. If I were to work locally I would have used the following 
mysql command:

'SELECT * FROM SOME_TABLE INTO OUTFILE '/tmp/test1.csv' FIELDS TERMINATED 
BY ',' ENCLOSED BY '' LINES TERMINATED BY '\n''

In my application a user can select certain criteria, a query is built in 
the controller according to the criteria and is executed with the 
executesql() method
which returns a dictionary like object. 

My question is: is there a way to make a download link in the view to 
download a csv file of results returned by the executesql() method?

Thank you!
Adam

-- 
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] Routes.py confusion

2015-03-28 Thread Grzegorz Dzień
I have web2py deployed behind Apache, and I am using routes:

routers = dict(

# base router
BASE=dict(
default_application='support',
),
)

but it always lands me in support app's controller default I just can't 
use other controllers - what am I doing wrong?


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


[web2py] Re: Table Migration on GAE

2015-03-28 Thread Sébastien Loix
Hello Massimo,
Where can I find the version for tester?
Also I am using SQL with MySQL with GAE through Cloud SQL, so the 
check_reserved keywords is necessary right?

Once I have the new version I will test it and report here.
Thanks


El martes, 24 de marzo de 2015, 17:32:09 (UTC+1), Massimo Di Pierro 
escribió:

 I spoke too soon. Please wait I post a new version for testers. I will 
 email this list.
 Then try:

 db = DAL('google:sql://[app-name]:[db-name]/[table-name]')
 ...
 auth.settings.extra_fields['auth_user'] = [Field('username_fb', 
 length=128, default=, unique=True, writable=False, readable=False)]
 auth.define_tables(username=False, signature=False)

 consider that migrate_enabled is true by default so no need to set it. 
 Also the check_reserved keywords is designed for SQL and not GAE. It does 
 not hurt but it is not necessary. I do not swear by lazy_table because they 
 have some caveats. Let's try without that.

 Can you help us check if this work? If, not what behaviour do you see? Do 
 you get a traceback?


 On Tuesday, 24 March 2015 11:18:06 UTC-5, Sébastien Loix wrote:

 Thank you for the answer.
 Could you explain a bit more the there are no migrations on GAE, is it 
 only for the actual version and the fixed version will solve it?
 I realised that I am using the 2.10.0-beta version of web2py. The one 
 downloaded from the main download page.
 Thanks for the help

 El martes, 24 de marzo de 2015, 8:31:51 (UTC+1), Massimo Di Pierro 
 escribió:

 1) there are no migrations on GAE, web2py will still create .table files 
 but they serve no purpose.
 2) GAE support is broken in 2.9.12. It works in trunk pydal and we will 
 released a fixed version this week

 On Monday, 23 March 2015 21:53:04 UTC-5, Sébastien Loix wrote:

 Hi,

 I am having difficulties with table migration on GAE.

 I deployed perfectly in the Google App Engine and everything is working 
 fine.

 I then needed to make some change in the auth_user adding some extra 
 field but when I deploy again the new version, the migration doesn't occur 
 and the new column is not created.

 Here is the code used:

 db = DAL('google:sql://[app-name]:[db-name]/[table-name]', 
 migrate_enabled=True, check_reserved=['all'], lazy_tables=True)

 then below:

 auth.settings.extra_fields['auth_user'] = [Field('username_fb', 
 length=128, default=, unique=True, writable=False, readable=False)]
 auth.define_tables(username=False, signature=False, migrate=True)

 Any idea why the migration doesn't occur?

 Is there a way to force web2py to do migration somehow?

 Thanks for the help!
 Best,
 Sebastian



-- 
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: Web2py security questions

2015-03-28 Thread Gray Kanarek
This might help with the second 
question: 
http://stackoverflow.com/questions/32369/disable-browser-save-password-functionality

This (and included links) might help with the first.

On Friday, March 27, 2015 at 7:12:02 PM UTC-4, Scott Hunter wrote:

 1. Does web2py employ, allow or support any anti-framing measures, to 
 prevent an attack that can trick the user into clicking on the link by 
 framing the original page and showing a layer on top of it with dummy 
 buttons.  If so, any pointers to either documentation describing how these 
 are present, or how one would enable them, would be appreciated. 
  Supposedly not employing such measures can allow clickjacking and/or CSRF.

 2. Does, or can, web2py prevent the browser from prompting the user to 
 save populated values for later reuse?

 - Scott


-- 
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] Cannot check boolean field

2015-03-28 Thread Ruud Schroen
Hi,

I have the following model:

#Abstract category model, has references from multiple translations
db.define_table('pitch_category')  #No fields except for ID

#The category translations
db.define_table('pitch_category_translation',
Field('pitch_category', db.pitch_category, 
requires=IS_IN_DB(db,db.pitch_category.id,lambda r: 
get_default_translation(r.id)), label=T('Category')),
Field('lang', 'string', requires=IS_IN_SET(settings.languages), 
label=T('Language')),
Field('val', 'string', label=T('The translation')),
Field('is_default', 'boolean', label=T('This is the default translation. 
NOTE: there should be only one per category!'))
)


When i try to check if is_default is True, i get the following error:

class 'gluon.contrib.pg8000.ProgrammingError'(('ERROR', '42804', 
'argument of IS TRUE must be type boolean, not type character'))

This is my SQL statement:

sql = 
SELECT
p.ID,
tr.val,
def.val
  FROM pitch_category p
  LEFT OUTER JOIN pitch_category_translation tr
ON p.ID = tr.pitch_category AND tr.lang = '%s'
  LEFT OUTER JOIN pitch_category_translation def
ON p.ID = def.pitch_category AND def.is_default IS TRUE;
 % language


Everything works, except for the boolean check...

-- 
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] How to approach presenting API data in web2py ?

2015-03-28 Thread Gary Cowell
Hello

Looking at writing a front end to an AWS orchestration tool in web2py, I 
already have the functionality required coded in python defs, so just 
looking at presenting things nicely.

One thing I'll have to do a lot of, is present grids and dropdowns of data 
that have come from lists and dictionaries returned by boto module, for 
example in my controller, I tested this:

@auth.requires_login()
def stacklist():
xadb = DAL('sqlite:memory:')
xadb.define_table('stacks', Field('stack_name', label='Stack Name'),
Field('stack_status', label='Status'))
xadb.stacks.truncate()
awskey=auth.user['AWSKey']
awssec=auth.user['AWSSecret']
e2conn = boto.ec2.connect_to_region('eu-west-1',
 aws_access_key_id=awskey,
 aws_secret_access_key=awssec)
cfconn = boto.cloudformation.connect_to_region('eu-west-1',
 aws_access_key_id=awskey,
 aws_secret_access_key=awssec)
regions = boto.ec2.regions(aws_access_key_id=awskey, 
aws_secret_access_key=awssec)  #
# get and populate cloudformer stacks
#
stackList = cfconn.list_stacks()

for stackSummary in stackList:
xadb.stacks.insert(stack_name=stackSummary.stack_name, stack_status=
stackSummary.stack_status)

form = SQLFORM.grid(xadb.stacks,orderby=[xadb.stacks.stack_status,])
return dict(form=form)

This works, but if I wanted to create a dropdown for regions instead of 
hard coding eu-west-1, I'd be doing this sort of thing again with a 
different temporary db. And then there's lists for RDS snapshots, ec2 
images, ec2 snapshots etc. Lots of lists of AWS resources to be presented.

Am I going about this the best way ? What other options exist for me to 
present lists and dropdowns of data returned from third party API calls?

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: Team of admin/devellopers with different permissions

2015-03-28 Thread Tom Clerckx
You can always create multiple instances of web2py (each with their own 
applications directory).
But for developers, wouldn't it be easier if they just have there local 
version of web2py and the application they're working on and use 
subversion/git/or any other version control system to check in updates?

Best regards,
Tom.

On Thursday, March 26, 2015 at 12:04:24 AM UTC+1, Ramos wrote:

 First web2py admin/developer are the same.
 Should it be?

 Also 
 my server can get crowded in the future with one or more developers. As i 
 have some apps i dont to share with then, how can i limit their access.

 Thank u


-- 
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] Help with two python operators

2015-03-28 Thread Paul McDonald
 


 In the web2py Application Development Cookbook:


 
 page 69 the | operator


 alphabetical = User.first_name|User.last_name *← | what is this doing??*


 
 
 page 82 the = operator


 if not form:

# search flatpage according to the current request

query = db.flatpage.c==request.controller

query = db.flatpage.f==request.function *← = what is this doing??*

if request.args:

query = db.flatpage.args==request.args(0)

else:

query = (db.flatpage.args==None)|(db.flatpage.args=='')

query = db.flatpage.lang==lang


 

-- 
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-03-28 Thread Carlos Costa
And what is the future of experts4solutions ?

2015-03-25 0:19 GMT-03:00 Massimo Di Pierro massimo.dipie...@gmail.com:

 Looks like you did. :-O

 Anyway, the point of a university is that we do not usually teach courses
 about specific technologies. We use specific technologies to serve more
 abstract purposes. For example I teach CSC438 which is about the internal
 design of web frameworks and I use web2py as one of the (main) examples.

 We use Python in many classes but the goal is not teach python. The goal
 is to teach programming (for, if, def, return).

 Anyway, it would be nice to have more material about teaching web2py
 and/or teaching with web2py. Perhaps we could crowdsource the effort. If I
 have a list of 10 topics that people would want me to cover in detail I can
 make some short videos. I am sure other people here would be willing to
 help.

 Massimo



 On Tuesday, 24 March 2015 12:39:02 UTC-5, Ron Chatterjee wrote:

 We should clone you saying!? lol. jk:-). Would be nice to have an advance
 course like that. Someone should write to the dean and sign me up.



 On Tuesday, March 24, 2015 at 12:19:23 PM UTC-4, Massimo Di Pierro wrote:

 No. Perhaps there should be. But not yet.

 On Tuesday, 24 March 2015 08:40:40 UTC-5, Ron Chatterjee wrote:

 Massimo,

 On that note. I have seen some of that lecture and it seems very
 undergrad level. Is there a grad level course that you can offer where we
 can go through each API (or the most important one). Lets create few stand
 alone code and go line by line to understand how the framework is made? Get
 into more depth and complexity. Lets say someone is already a web2py
 developer but he wants to push the envelop and become an expert or even
 better (since no one can't clone you. lol). Is there a course like that?

 Ron


 On Tuesday, March 24, 2015 at 3:34:26 AM UTC-4, 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 


Carlos J. Costa
Cientista da Computação  | BS Computer Science
Esp. Gestão em Telecom   | PgC Telecom Mangement
º))

-- 
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: Git Clone : Seems bad first page

2015-03-28 Thread Vikash Sharma
Thanks, looks good now.
I tried in IE, it was working, so then reset chrome cookies and it worked.


Regards,
Vikash Sharma
vikash0...@gmail.com

On Wed, Mar 25, 2015 at 10:01 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 it should not look like that. Either a css is missing or your browser is
 caching some old style file (most likely). Try force a reload and check the
 JS console for errors.


 On Tuesday, 24 March 2015 22:14:49 UTC-5, Vikash Sharma wrote:

 Hi ,

 I have cloned src today from git and found this page. Is this new design
 or commit by mistake?


 https://lh6.googleusercontent.com/-tQJEK-ma7I8/VRGuc3pRIFI/SYY/5-CUnfMS4S8/s1600/web2py%2Badmin%2Bpage.PNG




  --
 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] Is web2py is good for below requirements?

2015-03-28 Thread Anandhakumar Radhakrishnan
Hi,


I have planned to create a website with certain requirement please tell 
whether this will support in web2py.

1. Dynamic Page
2. Multi Vendors like olx.com
3. Email Services 
4. Comparison charts

And please tell why the web2py is best compare to other frame works in 
python.

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


[web2py] Multiple checkboxes representation

2015-03-28 Thread gliporace
Hi, I have a model like this:

db.registro_donazioni(
   Field('cognome', 'string', length=100),
   Field('nome', 'string', length=100),
   Field('gruppo_sanguigno', 'integer'),
   Field('fattore_rh', 'integer'),
   Field('sierologia', 'list:integer', label='Sierologia')
)

gruppo_sanguigno_set = {0: 'A', 1: 'B', 2: 'AB', 3: '0'}
db.registro_donazioni.gruppo_sanguigno.requires = IS_IN_SET(
gruppo_sanguigno_set)
db.registro_donazioni.gruppo_sanguigno.represent = lambda value, row: 
gruppo_sanguigno_set.get(value, None)
fattore_rh_set = {0: 'Positivo', 1: 'Negativo'}
db.registro_donazioni.fattore_rh.requires = IS_IN_SET(fattore_rh_set)
db.registro_donazioni.fattore_rh.represent = lambda value, row: 
fattore_rh_set.get(value, None)
db.registro_donazioni.sierologia.requires = IS_IN_SET({0: 'HIV', 1: 'HCV', 2
: 'HBV'}, multiple=True)
db.registro_donazioni.sierologia.widget = lambda field, value: SQLFORM.
widgets.checkboxes.widget(field, value, cols=3, style='table')

When viewing a record in read-only (SQLFORM(db.registro_donazioni, record, 
readonly=True)) the 'sierologia' is displayed as a list of values instead 
of multiple checkboxes. I think I need to set the .represent attribute of 
the field, but I don't know how to do it. Some help please?

-- 
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] Write dynamic query in DAL without extra nested parentheses

2015-03-28 Thread gb
What is the DAL Code to generate a query like this:
SELECT * FROM product WHERE product.id=1 OR product.id=2 OR product.id=3 OR 
product.id product.id=4 OR product.id=5;
or even:
SELECT * FROM product WHERE (product.id=1) OR (product.id=2) OR 
(product.id=3) OR (product.id=4) OR (product.id=5);

I've tried both the DAL code approaches below and I always end up with 
crazy parentheses nesting which will eventually crash the DB driver e.g. in 
sqlite: class 'sqlite3.OperationalError' parser stack overflow

Is there another way to use the DAL, or is my only option to write the SQL 
manually?

db.define_table(product)

selected_ids = [1,2,3,4,5]
query = []
for pid in selected_ids:
query.append(db.product.id == pid)

query = reduce(lambda a,b:a|b,query)
#Ouputs this : (product.id = 1) OR (product.id = 2)) OR (product.id 
= 3)) OR (product.id = 4)) OR (product.id = 5))



selected_ids = [1,2,3,4,5]
query = []
for pid in selected_ids:
query |= db.product.id == pid

#I get a bonus parenthesis with this method ((product.id = 1) OR ) 
OR (product.id = 2)) OR (product.id = 3)) OR (product.id = 4)) OR 
(product.id = 5))

-- 
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] jQuery on button click

2015-03-28 Thread Diego R
Hello,

I'm following instructions on video 16 Final Reddit clone improvements by 
Massimo and I'm having problems calling jquery on button click:

Here is my code:

{{for post in row:}}
div class=alert alert-info
table

tr data-id={{=post.id}}

tdbutton data-direction=up+/button/td

tdspan class=votes{{=post.votes}}/span/td

tdbutton data-direction=down-/button/td

tdstrongnbsp;{{=A(post.title, _href=post.url) if 
post.url else post.title}}/strongbr//td

  /tr
  trtd colspan = 3/td

  td{{=A('comments', _href=URL('view_post', args = 
post.id))}}/td

  /tr
  /table
/div
{{pass}}


script

function do_ajax_vote(t,direction) {
alert('clicked');
}


jQuery(function(){
jQuery('[data-direction=plus]').click(function() 
{do_ajax_vote(this, 'up');});
jQuery('[data-direction=minus]').click(function() 
{do_ajax_vote(this, 'down');});
});
/script

When I click the buttons, nothing happens, no popup. My pop-ups are not 
blocked. I'm not sure what I'm doing wrong... 

Thanks in advance!

-- 
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: fields strings to variable for fields=fields

2015-03-28 Thread Gray Kanarek
With the information here 
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Run-time-field-and-table-modification

you can do db['mytable']['field1']. So you'd want something like: 

field_list_split = [i.split(.) for i in field_list]
fields = [db[table][field] for dummy, table, field in field_list_split]


On Friday, March 27, 2015 at 3:39:38 PM UTC-4, LoveWeb2py wrote:

 Hi JorgeH,

 I didn't want to use eval due to code injection, but here is what I ended 
 up using and it worked.

 field_list = ['db.mytable.field1', 'db.mytable.field2'] 

 fields = [getattr(db.mytable, i.split(.)[-1] for i in field_list]



 and in SQLFORM fields=fields

 Thanks everyone!1

 On Friday, March 27, 2015 at 3:35:57 PM UTC-4, JorgeH wrote:


 have you tried  eval  ??

 fields = [eval ('db.mytable.field1') , eval ('db.mytable.field2') ] 





 (just a suggestion. I didn't tried myself)

 On Friday, March 27, 2015 at 2:24:06 PM UTC-5, LoveWeb2py wrote:

 having trouble with the SQLFORM.smartgrid fields section

 Fields only takes 

 fields = [db.mytable.field1, db.mytable.field2]

 I have a function that returns all the fields to be returned, but 
 they're in strings format.

 fields = ['db.mytable.field1', 'db.mytable.field2'] #this returns an 
 error with SQLFORM

 How can I convert the strings to variables like in the first fields 
 example.



-- 
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] Help with two Python operators

2015-03-28 Thread Paul McDonald
In the Web2py Application Development Cookbook:
 
 p82the  =  operators


 if not form:

# search flatpage according to the current request

query = db.flatpage.c==request.controller

query = db.flatpage.f==request.function *-  what is going on 
here?*

if request.args:

query = db.flatpage.args==request.args(0)

else:

query = (db.flatpage.args==None)|(db.flatpage.args=='')

query = db.flatpage.lang==lang


 Alos, p69the   |   bianary or operator

alphabetical = User.first_name|User.last_name   * --  what is 
going on here?   *
  

  Can anyone explain what these are doing?
Thank you in advance


Paul
  

-- 
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: WEB2PY Certificate ?

2015-03-28 Thread KPlusPlus
What do you think of lunching an independent  repository for 
tutorials/guides/tricks of web2py ,, web2py School ? 

On Wednesday, March 25, 2015 at 11:08:57 PM UTC+3, Ron Chatterjee wrote:

 Regarding what you mentioned, 10 topics people want to cover in 
 details...short videos. I would like (may be as part of shot videos or 
 CSC438), if we can create bunch of stand alone code for whats inside 
 gluons and script. And create an architectural details about how each 
 module is used to make the web framework to work. That will be great! In 
 other words, sure, we have the documentation and now we can use web2py to 
 create sites. But if someone needs to create a brand new framework using 
 different language or create a hybrid, how that person can go about doing 
 it? Whats will be required at to level and at the lower level? Needs a 
 rocket (or apache) server for example to start. But how that is interfaced 
 into the code...I believe, the stand alone version with input and output of 
 each modules in gluon/scipt can help (without running web2py), in 
 understanding how each modules talk to each other and what are the 
 underlying relationship that ties the server side to the client side.

 That will be very interesting to me. Again, since I am a rookie, this may 
 be already answered and everyone on this site may already know all these. 
 But I think, it will help me to learn the framework better to know whats 
 inside and out. Just some thoughts...

 -Ron




 On Tuesday, March 24, 2015 at 11:19:31 PM UTC-4, Massimo Di Pierro wrote:

 Looks like you did. :-O

 Anyway, the point of a university is that we do not usually teach courses 
 about specific technologies. We use specific technologies to serve more 
 abstract purposes. For example I teach CSC438 which is about the internal 
 design of web frameworks and I use web2py as one of the (main) examples.

 We use Python in many classes but the goal is not teach python. The goal 
 is to teach programming (for, if, def, return).

 Anyway, it would be nice to have more material about teaching web2py 
 and/or teaching with web2py. Perhaps we could crowdsource the effort. If I 
 have a list of 10 topics that people would want me to cover in detail I can 
 make some short videos. I am sure other people here would be willing to 
 help.

 Massimo



 On Tuesday, 24 March 2015 12:39:02 UTC-5, Ron Chatterjee wrote:

 We should clone you saying!? lol. jk:-). Would be nice to have an 
 advance course like that. Someone should write to the dean and sign me up.



 On Tuesday, March 24, 2015 at 12:19:23 PM UTC-4, Massimo Di Pierro wrote:

 No. Perhaps there should be. But not yet. 

 On Tuesday, 24 March 2015 08:40:40 UTC-5, Ron Chatterjee wrote:

 Massimo,

 On that note. I have seen some of that lecture and it seems very 
 undergrad level. Is there a grad level course that you can offer where we 
 can go through each API (or the most important one). Lets create few 
 stand 
 alone code and go line by line to understand how the framework is made? 
 Get 
 into more depth and complexity. Lets say someone is already a web2py 
 developer but he wants to push the envelop and become an expert or even 
 better (since no one can't clone you. lol). Is there a course like that?

 Ron


 On Tuesday, March 24, 2015 at 3:34:26 AM UTC-4, 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Minor issue when trying to download plugins from admin application

2015-03-28 Thread Michel Krav
Hi,

I'm facing a minor issue when trying to install ckeditor plugin , so I 
report it :

When using Download plugins from repository button in the admin application 
interface as I cannot access the url web2slices.com the exception is caught 
and the following happen :

Version
web2py™ Version 2.9.12-stable+timestamp.2015.01.17.06.11.03
Python Python 2.7.8: C:\Python27\python.exe (prefix: C:\Python27)

Traceback (most recent call last):
  File D:\Python\web2py_src\web2py\gluon\restricted.py, line 224, in 
restricted
exec ccode in environment
  File 
D:/Python/web2py_src/web2py/applications/admin/controllers/default.py, 
line 1945, in module
  File D:\Python\web2py_src\web2py\gluon\globals.py, line 393, in lambda
self._caller = lambda f: f()
  File 
D:/Python/web2py_src/web2py/applications/admin/controllers/default.py, 
line 1919, in plugins
return dict(plugins=session.plugins[results], app=request.args(0))
TypeError: list indices must be integers, not str


type 'exceptions.TypeError'(list indices must be integers, not str)

This is the original code :
def plugins():
app = request.args(0)
from serializers import loads_json
if not session.plugins:
try:
rawlist = urllib.urlopen(http://www.web2pyslices.com/; +
 
public/api.json/action/list/content/Package?package +
 _type=pluginsearch_index=false).read
()
session.plugins = loads_json(rawlist)
except:
response.flash = T('Unable to download the list of plugins')
session.plugins = []
return dict(plugins=session.plugins[results], app=request.args(0))




So I propose to replace line 1918 :
session.plugins = []


by :
session.plugins = {results : None}



Thanks for web2py !

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


[web2py] Re: Ractive example

2015-03-28 Thread Massimo Di Pierro
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] Belongs not working

2015-03-28 Thread Leonardo Pires Felix
Hi,
I think on last update the belongs stoped working.
I've a table that is defined like this:
db.define_table(regra_entrada,
Field(descricao, notnull=True, represent=nome, requires=[
IS_NOT_EMPTY(), IS_UPPER()]),
Field(data_inicial, date, widget=SQLFORM.widgets.string.
widget, represent=campo_date_dia_semana,
  default=request.now.date() + datetime.timedelta(days=1
), notnull=True),
Field(data_final, date, notnull=True, widget=SQLFORM.
widgets.string.widget,
  represent=campo_date_dia_semana),
# Definido as delimitações abaixo
Field(modo, integer, widget=SQLFORM.widgets.radio.widget
, notnull=True,
  represent=lambda v, l: _dic_modo[v] if v is not None 
else None, requires=IS_IN_SET(_dic_modo)),
Field(notificacao_sms, boolean, notnull=True, default=
True),
Field(notificacao_email, boolean, notnull=True, default=
True),
Field(turnos, list:integer, represent=lambda l, v: , .
join([db.turno(i).sigla for i in l]),
  requires=IS_IN_DB(db, db.turno, multiple=True, label=
db.turno._format)))

Then, it's populated like this:
 print db(db.regra_entrada.id  0).select()
regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
regra_entrada.notificacao_email,regra_entrada.turnos
19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

The problem is, i'm pretty sure that belongs should be working on this 
case, as i have already tested it on early versions. But now belongs not 
work, this is the outpout for belongs of field turnos with 3(that is on 
the table, on the previous output):
 print db(db.regra_entrada.turnos.belongs([3])).select()
regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms,
regra_entrada.notificacao_email,regra_entrada.turnos



Maybe something was changed on the version i'm using? Or some specific 
change to the postgres DAL?


Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
Rocket 1.2.6, Python 2.7.9
OS: Debian 8(wheezy)
Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit


-- 
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: saving and dumping variables

2015-03-28 Thread Ron Chatterjee

Actually,
I figured it out. All I needed to do is CD to the directory where web2py 
source code is located and do:

from gluon import *

Thats it. Then if I do 
c = cPickle.load(open('C:\Users\Ron\Desktop\web2py_src\myfile.pickle', 
'rb'))

DAL object shows up as stand alone. Now I can do anything with it.


On Saturday, March 28, 2015 at 11:24:33 AM UTC-4, Anthony wrote:

 You are simply saving the dump to a variable, which does not persist 
 across separate Python processes. If you want to be able to re-load the 
 object, you need some form of persistence, such as writing to a file or 
 saving to a database.

 Anthony

 On Saturday, March 28, 2015 at 9:21:18 AM UTC-4, Ron Chatterjee wrote:

 Wondering how to save and dump variables from web2py to a static python 
 ide. In other words, 

  import cPickle
   b = cPickle.dumps(a)
   c = cPickle.loads(b)

 That seems to work only inside a web2py session. Once I close the web2py 
 application and if I want to load up the saved variable using an external 
 IDE. c=cPickle.loads(b) doesn't work. 

 Any thoughts?:-)




-- 
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-03-28 Thread Massimo Di Pierro
Since experts4solutions is now a registered company, I use it for 
consulting. I am planning to offer web2py certifications (I know I have 
said before but I am actually almost ready) and I plan to list certified 
developers and host the developers web pages.

Massimo

On Saturday, 28 March 2015 11:14:44 UTC-5, Carlos Costa wrote:

 And what is the future of experts4solutions ?

 2015-03-25 0:19 GMT-03:00 Massimo Di Pierro massimo.dipie...@gmail.com:

 Looks like you did. :-O

 Anyway, the point of a university is that we do not usually teach courses 
 about specific technologies. We use specific technologies to serve more 
 abstract purposes. For example I teach CSC438 which is about the internal 
 design of web frameworks and I use web2py as one of the (main) examples.

 We use Python in many classes but the goal is not teach python. The goal 
 is to teach programming (for, if, def, return).

 Anyway, it would be nice to have more material about teaching web2py 
 and/or teaching with web2py. Perhaps we could crowdsource the effort. If I 
 have a list of 10 topics that people would want me to cover in detail I can 
 make some short videos. I am sure other people here would be willing to 
 help.

 Massimo



 On Tuesday, 24 March 2015 12:39:02 UTC-5, Ron Chatterjee wrote:

 We should clone you saying!? lol. jk:-). Would be nice to have an 
 advance course like that. Someone should write to the dean and sign me up.



 On Tuesday, March 24, 2015 at 12:19:23 PM UTC-4, Massimo Di Pierro wrote:

 No. Perhaps there should be. But not yet. 

 On Tuesday, 24 March 2015 08:40:40 UTC-5, Ron Chatterjee wrote:

 Massimo,

 On that note. I have seen some of that lecture and it seems very 
 undergrad level. Is there a grad level course that you can offer where we 
 can go through each API (or the most important one). Lets create few 
 stand 
 alone code and go line by line to understand how the framework is made? 
 Get 
 into more depth and complexity. Lets say someone is already a web2py 
 developer but he wants to push the envelop and become an expert or even 
 better (since no one can't clone you. lol). Is there a course like that?

 Ron


 On Tuesday, March 24, 2015 at 3:34:26 AM UTC-4, 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 -- 


 Carlos J. Costa
 Cientista da Computação  | BS Computer Science 
 Esp. Gestão em Telecom   | PgC Telecom Mangement
 º))
  

-- 
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: Write dynamic query in DAL without extra nested parentheses

2015-03-28 Thread Anthony
In this particular case, you should instead use .belongs():

query = db.product.id.belongs([list of ids])

It's an interesting problem, though. A somewhat hackish solution would be:

query = ' OR '.join(str(db.product.id == i) for i in [list of ids])

The problem is that OR and AND operators always wrap the operands in 
parentheses, even when not necessary. The result is the nesting you observe 
when using reduce() or appending in a loop. Perhaps there should be a way 
to suppress the parentheses when not needed.

Anthony

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


Re: [web2py] Re: Django models into web2py

2015-03-28 Thread Phyo Arkar
Thanks a lot massimo , i will try with latest nightly then.

On Sat, Mar 28, 2015 at 10:53 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 This is a backward compatibility problem in the latest web2py. Should be
 fixed in the nightly build (for testers)


 On Friday, 27 March 2015 15:56:05 UTC-5, Ron Chatterjee wrote:

 This is an old web2py blog.

 http://www.web2py.com/AlterEgo/default/show/189

 Did anyone went through the steps and was able to generate the tables? I
 tried but it failed. It didn't work. Is it only valid for polls example
 only or any django models can be used in web2py this way? Not sure.

 I know its not a recommended and I will never deploy an application using
 this method. But wanted to try few django projects and code them up in
 web2py to learn more but I am and kind of feeling lazy to write the table
 from scratch. thought copy and paste will be nice if I can get this method
 to work. Any web2pier wants to try and see what I am doing wrong?

 *I get an error saying:*

 models/db.py 
 http://127.0.0.1:8000/admin/default/edit/try_django_polls/models/db.py, 
 line 62, in module
 class Poll(Model):
   File applications\try_django_polls\modules\django.py, line 145, in 
 __new__
 fields=[db.Field(key,**value.serial(name,db)) for key,value in 
 attrs.items() if hasattr(value,'serial') and not 
 isinstance(value,ManyToManyField)]
   File ...\Desktop\web2py_src\web2py\gluon\dal\base.py, line 893, in 
 __getattr__
 return ogetattr(self, key)

 AttributeError: 'DAL' object has no attribute 'Field'

  --
 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: Web2py security questions

2015-03-28 Thread Anthony
On Saturday, March 28, 2015 at 12:26:24 PM UTC-4, Massimo Di Pierro wrote:

 perhaps we should but being able to frame pages is something that people 
 always want as a feature.


The two header examples below allow framing if the ancestor page is from 
the same domain as the framed page. I wouldn't necessarily set the 
X-Frame-Options header by default in the framework, as that header is 
non-standard and being deprecated in favor of Content-Security-Policy, 
which itself is more flexible and allows specification of a whitelist of 
allowed ancestors. I was suggesting maybe setting Content-Security-Policy, 
with framing from the same domain allowed by default, and with an easy to 
set setting to specify a whitelist (e.g., 
response.allowed_frame_ancestors). I'm not sold on the idea -- just 
something to consider.

Another option might be to include a commented line in the scaffolding app 
that would make it easier/more obvious for developers to provide this 
protection.

Anthony
 


 On Saturday, 28 March 2015 09:52:58 UTC-5, Anthony wrote:

 On Friday, March 27, 2015 at 7:12:02 PM UTC-4, Scott Hunter wrote:

 1. Does web2py employ, allow or support any anti-framing measures, to 
 prevent an attack that can trick the user into clicking on the link by 
 framing the original page and showing a layer on top of it with dummy 
 buttons.  If so, any pointers to either documentation describing how these 
 are present, or how one would enable them, would be appreciated. 
  Supposedly not employing such measures can allow clickjacking and/or CSRF.


 I don't think web2py does anything by default, but you can add protection 
 yourself by setting the X-Frame-Options and/or Content-Security-Policy 
 headers in a model file:

 response.headers['X-Frame-Options'] = SAMEORIGIN
 response.headers['Content-Security-Policy'] = frame-ancestors 'self'

 Perhaps web2py should set the Content-Security-Policy header by default, 
 maybe with an optional configurable whitelist of allowed ancestors.

 Note, you can also configure your server (e.g., nginx, Apache) to 
 automatically set the above headers.

 You can also implement a Javascript defense, such as this one 
 https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script
 .
  


 2. Does, or can, web2py prevent the browser from prompting the user to 
 save populated values for later reuse?


 It doesn't by default (as that is a user preference configurable in the 
 browser), but nothing stops you from using the various available solutions, 
 such as setting the autocomplete attribute of form and input elements to 
 off (which can be done on the server or via Javascript) or using 
 Javascript to reset the form after rendering.

 Anthony



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


[web2py] Re: Belongs not working

2015-03-28 Thread Leonardo Pires Felix
Not working too on the version for testers, in this case using sqlite. 
Example:

db.define_table(business_day,
   Field(description, notnull=True),
   Field(week_days, list:integer, notnull=True))

db.business_day.insert(description='first week january 2015', week_days=[3,4
])
1L
 print db(db.business_day.id0).select()
business_day.id,business_day.description,business_day.week_days
1,first week january 2015,|3|4|

 db(db.business_day.week_days.belongs([3])).select()
Rows (0)

 db(db.business_day.week_days.belongs([3]))._select()
SELECT  business_day.id, business_day.description, business_day.week_days 
FROM business_day WHERE (business_day.week_days IN ('|3|'));


Em sábado, 28 de março de 2015 13:27:28 UTC-3, Massimo Di Pierro escreveu:

 Can you please try the for testers version on the web site? Can you 
 provide a simpler example to reproduce the problem?

 On Saturday, 28 March 2015 10:43:56 UTC-5, Leonardo Pires Felix wrote:

 Hi,
 I think on last update the belongs stoped working.
 I've a table that is defined like this:
 db.define_table(regra_entrada,
 Field(descricao, notnull=True, represent=nome, requires
 =[IS_NOT_EMPTY(), IS_UPPER()]),
 Field(data_inicial, date, widget=SQLFORM.widgets.
 string.widget, represent=campo_date_dia_semana,
   default=request.now.date() + datetime.timedelta(
 days=1), notnull=True),
 Field(data_final, date, notnull=True, widget=SQLFORM.
 widgets.string.widget,
   represent=campo_date_dia_semana),
 # Definido as delimitações abaixo
 Field(modo, integer, widget=SQLFORM.widgets.radio.
 widget, notnull=True,
   represent=lambda v, l: _dic_modo[v] if v is not 
 None else None, requires=IS_IN_SET(_dic_modo)),
 Field(notificacao_sms, boolean, notnull=True, default
 =True),
 Field(notificacao_email, boolean, notnull=True, 
 default=True),
 Field(turnos, list:integer, represent=lambda l, v: , 
 .join([db.turno(i).sigla for i in l]),
   requires=IS_IN_DB(db, db.turno, multiple=True, 
 label=db.turno._format)))

 Then, it's populated like this:
  print db(db.regra_entrada.id  0).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms
 ,regra_entrada.notificacao_email,regra_entrada.turnos
 19,OUTRO TESTE,2015-03-25,2015-05-01,0,True,True,|2|3|1|

 The problem is, i'm pretty sure that belongs should be working on this 
 case, as i have already tested it on early versions. But now belongs not 
 work, this is the outpout for belongs of field turnos with 3(that is on 
 the table, on the previous output):
  print db(db.regra_entrada.turnos.belongs([3])).select()
 regra_entrada.id,regra_entrada.descricao,regra_entrada.data_inicial,
 regra_entrada.data_final,regra_entrada.modo,regra_entrada.notificacao_sms
 ,regra_entrada.notificacao_email,regra_entrada.turnos



 Maybe something was changed on the version i'm using? Or some specific 
 change to the postgres DAL?


 Web2py version: 2.9.12-stable+timestamp.2015.01.17.06.11.03
 Rocket 1.2.6, Python 2.7.9
 OS: Debian 8(wheezy)
 Postgres: PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by 
 gcc-4.9.real (Debian 4.9.2-10) 4.9.2, 64-bit




-- 
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: Cannot check boolean field

2015-03-28 Thread Anthony
In many of the adapters, web2py converts booleans to and from strings with 
values T and F. So, depending on the adapter, if you are writing SQL 
manually, you may need to use those values instead of True and False.

Anthony

On Saturday, March 28, 2015 at 12:14:44 PM UTC-4, Ruud Schroen wrote:

 Hi,

 I have the following model:

 #Abstract category model, has references from multiple translations
 db.define_table('pitch_category')  #No fields except for ID

 #The category translations
 db.define_table('pitch_category_translation',
 Field('pitch_category', db.pitch_category, 
 requires=IS_IN_DB(db,db.pitch_category.id,lambda r: 
 get_default_translation(r.id)), label=T('Category')),
 Field('lang', 'string', requires=IS_IN_SET(settings.languages), 
 label=T('Language')),
 Field('val', 'string', label=T('The translation')),
 Field('is_default', 'boolean', label=T('This is the default translation. 
 NOTE: there should be only one per category!'))
 )


 When i try to check if is_default is True, i get the following error:

 class 'gluon.contrib.pg8000.ProgrammingError'(('ERROR', '42804', 
 'argument of IS TRUE must be type boolean, not type character'))

 This is my SQL statement:

 sql = 
 SELECT
 p.ID,
 tr.val,
 def.val
   FROM pitch_category p
   LEFT OUTER JOIN pitch_category_translation tr
 ON p.ID = tr.pitch_category AND tr.lang = '%s'
   LEFT OUTER JOIN pitch_category_translation def
 ON p.ID = def.pitch_category AND def.is_default IS TRUE;
  % language


 Everything works, except for the boolean check...



-- 
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: Web2py security questions

2015-03-28 Thread Scott Hunter
I did; it says nothing about the specific things I asked about (or if it 
does, I cannot tell); that is why I asked.

If that section of the book *does* address my questions, could someone 
point me to where in that section it does so?  For example, there is a 
reference to preventing CSRF, but not about anti-framing.

- Scott

P.S. Thanks for not LOL-ing me and saying this is an inappropriate forum 
for such a question, like my first reply (which has been deleted) -- 
progress!

On Saturday, March 28, 2015 at 2:03:53 AM UTC-4, 黄祥 wrote:

 i think you can check it on the book about web2py security
 ref :
 http://web2py.com/books/default/chapter/29/01/introduction#Security

 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.


[web2py] Re: Web2py security questions

2015-03-28 Thread 黄祥
i think you can check it on the book about web2py security
ref :
http://web2py.com/books/default/chapter/29/01/introduction#Security

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.