[web2py] Re: Select filled with years

2017-04-18 Thread Juan Carlos Quesada
def getyears(anyo): from datetime import datetime, date option = [] option.append(OPTION(T('Año'), _value='')) year = datetime.today().year ryear = range(2015, int(year+1)) for r in ryear: if anyo == r: selected = True else: selecte

[web2py] Removing item from list:Reference

2017-04-18 Thread Sharjeel Ali Shaukat
I have company table in which projects information is stored in list:reference , now i want to remove the project id from company table reference field without using loop , simple by DAL update query *Company Table* | *id* | *name* | *projects* | | 1 | Com1 | |1|2| | So after up

[web2py] Re: Python 2.7 mock library and web2py

2017-04-18 Thread Marlysson Silva
Do you have a file called db in your modules folder in your application? Em domingo, 16 de abril de 2017 11:37:11 UTC-3, Robin Bryce escreveu: > > Hi, > > I'm attempting to use the python mock library with some unittest based > tests for a web2py application. It feels like I'm going against the g

[web2py] update_or_insert only returns id if created not updated

2017-04-18 Thread António Ramos
why? https://github.com/web2py/pydal/blob/4b30558e7d75da152ac6a003991e9add1b68c235/pydal/objects.py#L795 I could and need to use the id in case of update... Sem vírus. www.avast.com

[web2py] Re: Removing item from list:Reference

2017-04-18 Thread Alfonso Serra
Will this work for you? company = db(db.companies.id==1).select().first() company.projects.remove(1) use db.commit() afterwards if this is ran in a console instead a controller. Ideally you could use foreign keys to delete related projects data or dependencies. Have in mind that list fields are

[web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Alfonso Serra
Hi Chris, why do you use requires IS_NOT_EMPTY in a computed field?, if you do, you have to supply a value before is computed, isnt it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/is

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Christopher L
Hi Alfonso, I think the original reason was that sometimes I would end up with a computed field without a value. Inserts should automatically compute rows, but for some reason that wasn't happening here. On Apr 18, 2017 8:04 AM, "Alfonso Serra" wrote: Hi Chris, why do you use requires IS_NOT_EM

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Alfonso Serra
As per the docs, they say they are stored in db but not computed on retrieval. i guess this applies to updates. Does this calculate_field function does not return a value in some case? for example total = unit * price may be None if the operation fails because either unit or price is None or th

[web2py] requires option on field does't work

2017-04-18 Thread Andrea Fae'
I have this table db.define_table('materia', Field('nome', requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'materia.nome')]), Field('docente','reference auth_user'), auth.signature,singular="Materia",plural="Materie",migrate='materia.table',

[web2py] delete record confirmation dialog

2017-04-18 Thread Andrea Fae'
How to change customized message in the confirmation dialog about delete a record using grid or smartgrid? (depending on the situation) Any examples? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Anthony
You should not set "requires" on a computed field -- when you use validate_and_insert, the validation will be run before the computed value is generated. However, you can instead set required=True. In that case, any time you do an insert or update, if the fields needed by the computed field are

[web2py] Re: requires option on field does't work

2017-04-18 Thread Anthony
> > > db.materia.nome.requires=IS_NOT_IN_DB(db(db.materia.docente==request.vars.docente),db.materia.nome) > There is no request.vars.docente. Based on your controller code, it appears you are passing the "docente" value via request.args(0), so the above should probably be db.materia.docente==re

[web2py] Re: Removing item from list:Reference

2017-04-18 Thread Anthony
On Tuesday, April 18, 2017 at 7:54:21 AM UTC-4, Alfonso Serra wrote: > > Will this work for you? > > company = db(db.companies.id==1).select().first() > company.projects.remove(1) > The above will remove the value from the Row object but will not update the database. To do the latter, you must th

[web2py] list of dates into database

2017-04-18 Thread R U
I am trying to insert many dates into a field. Currently I am only getting 1 date inserted. my overall goal is to insert many (semi random) dates into the database; each user will have his/her own unique list. Then later iterate over the list having the date trigger some event if it equals today'

[web2py] Re: Select filled with years

2017-04-18 Thread Dave S
On Tuesday, April 18, 2017 at 2:23:14 AM UTC-7, Juan Carlos Quesada wrote: > > def getyears(anyo): > from datetime import datetime, date > option = [] > option.append(OPTION(T('Año'), _value='')) > year = datetime.today().year > ryear = range(2015, int(year+1)) > for r in

[web2py] Re: list of dates into database

2017-04-18 Thread Dave S
On Tuesday, April 18, 2017 at 12:02:28 PM UTC-7, R U wrote: > > I am trying to insert many dates into a field. Currently I am only > getting 1 date inserted. > my overall goal is to insert many (semi random) dates into the database; > each user will have his/her own unique list. Then later it

[web2py] Re: delete record confirmation dialog

2017-04-18 Thread Paolo Valleri
At the moment is not possible to change it directly in grid or smartgrid. This is because the javascript variable is fixed, assigned in https://github.com/web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html and then used in https://github.com/web2py/web2py/blob/master/applicat

[web2py] Re: Removing item from list:Reference

2017-04-18 Thread Anthony
list:-type fields are a DAL abstraction (they are simply stored as pipe-delimited strings in the database), so it would be complicated to get the database to directly manipulate the contents of such fields. If you have the entire contents of the field, you can update the field without a select:

[web2py] Re: update_or_insert only returns id if created not updated

2017-04-18 Thread Anthony
I think the reason is so you can determine whether an insert was done or not (otherwise there would be no way to distinguish). Anyway, it's a fairly simple function, so if you need the id of updated records, just write your own version. Anthony On Tuesday, April 18, 2017 at 6:58:22 AM UTC-4, R

[web2py] Re: update_or_insert only returns id if created not updated

2017-04-18 Thread Paolo Valleri
It should work. Try to open an issue on https://github.com/web2py/pydal or a pull request with the necessary change it could be something like, new_id = record[self._id.name] Paolo On Tuesday, April 18, 2017 at 12:58:22 PM UTC+2, Ramos wrote: > > why? > > https://github.com/web2py/pydal/blob/

[web2py] decode/encode password

2017-04-18 Thread lucas
hello one and all, what about this for https://groups.google.com/forum/#!topic/web2py/4eWj_BlGWjc and I started this new thread because I think it is different subject then the latter link. what if I sent the password as straight text in the form? meaning it is decoded from the database, sen

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Christopher L
Thanks for the info Anthony! I'll try one of those approaches. Why is validation run before compute? On Apr 18, 2017 2:50 PM, "Anthony" wrote: You should not set "requires" on a computed field -- when you use validate_and_insert, the validation will be run before the computed value is generated

Re: [web2py] Re: web2py and python3

2017-04-18 Thread JorgeH
Please consider adding support for GraphQL, if I may suggest On Sunday, April 16, 2017 at 9:51:11 AM UTC-5, Massimo Di Pierro wrote: > > The main goal is to make it as close as possible to web2py but faster, > allow more flexibility and move more logic client-size. It will be smaller > than web2

[web2py] Re: decode/encode password

2017-04-18 Thread Dave S
On Tuesday, April 18, 2017 at 2:19:30 PM UTC-7, lucas wrote: > > hello one and all, > > what about this for > https://groups.google.com/forum/#!topic/web2py/4eWj_BlGWjc and I started > this new thread because I think it is different subject then the latter > link. > > what if I sent the passwo

[web2py] Re: update_or_insert only returns id if created not updated

2017-04-18 Thread Anthony
On Tuesday, April 18, 2017 at 3:33:31 PM UTC-4, Paolo Valleri wrote: > > It should work. Try to open an issue on https://github.com/web2py/pydal > or a pull request with the necessary change > it could be something like, > > new_id = record[self._id.name] > We can't do that, as it would break b

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Anthony
On Tuesday, April 18, 2017 at 5:41:38 PM UTC-4, Chris wrote: > > Thanks for the info Anthony! I'll try one of those approaches. > > Why is validation run before compute? > In terms of implementation, compute is handled in the .insert() method, which must necessarily run after validation. I suppos

[web2py] Re: table already exists; 'Rows' object has no attribute 'fields'

2017-04-18 Thread pbreit
models were in the regular models.py file On Monday, April 17, 2017 at 4:18:26 PM UTC-7, Dave S wrote: > > > > On Monday, April 17, 2017 at 3:58:38 PM UTC-7, pbreit wrote: >> >> Sqlite. These are fresh installs with just a table defined and no other >> edits. >> >> I've noticed that I can get it

[web2py] list of dates into database

2017-04-18 Thread Marlysson Silva
You already tried populate method in built in contribuiu methods? The populate function do that to some table of system , it generate some fake data in some large dataset .. Example populate(db.mytable, 20) The lib use the bayesian classifier to generate data based in type of field.. -- Resou

[web2py] Re: table already exists; 'Rows' object has no attribute 'fields'

2017-04-18 Thread Wabbajack
Similar problem here i have downloaded the latest version. enable username = true add 1 user thru the webapp then go appadmin click db.auth_user [to view my newly created user] then the error occurs 'Rows' object has no attribute 'fields' Also i view the database and confirmed that it already

[web2py] Re: Removing item from list:Reference

2017-04-18 Thread Sharjeel Ali Shaukat
Thanks ! how it will response when i used it in put service of 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

[web2py] Re: table already exists; 'Rows' object has no attribute 'fields'

2017-04-18 Thread Dave S
On Tuesday, April 18, 2017 at 7:54:32 PM UTC-7, Wabbajack wrote: > > > Similar problem here i have downloaded the latest version. > Windows? Source? Packaged or GitHub? > enable username = true > add 1 user thru the webapp > > then go appadmin click db.auth_user [to view my newly created u