[web2py] Re: cannot access web2py.com today

2014-06-26 Thread Simon Ashley
Finding it flaky as well.  Probably AWS playing up again.

-- 
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] Can't seem to verify password field...

2014-06-26 Thread Jason (spot) Brower
I can't seem to get my key to verify:

This is how I verify it:

success = db.melodigram.deletion_key.validate(request.args(1)) ==
(db(db.melodigram.unique_id == request.args(0)).select().first(), None)

And this is how it is made:
form = SQLFORM(db.melodigram)
form.process(session = None, formname = None)

Any ideas as to why this would be an issue?
I just can't get success to be true.
:( .. . .
BR,
Jason Brower

-- 
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] Error while inserting in table with custom id

2014-06-26 Thread at
Hello,

I am getting getting this:

(lastval is not yet defined in this 
session ) 
while running:
if db(db.user_role).isempty():
db.user_role.insert(id=1, title='Application Administrator')
db.user_role.insert(id=2, title='Account Administrator')
db.user_role.insert(id=3, title='Account Member')

whereas my table defination is simply as follows:
db.define_table('user_role',
Field('title', type='string', length=50, label=T('User Role Title'))
)

and in postgres:
CREATE TABLE user_role
(
  id serial NOT NULL,
  title character varying(50),
  CONSTRAINT user_role_pkey PRIMARY KEY (id )
)
WITH (
  OIDS=FALSE
);

Any help please ...

Thanks & Regards
AT

-- 
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 scheduler period and repeats result not expected

2014-06-26 Thread 黄祥
a, i c, so that's why scheduler_task table is have a lot of record. thank 
you so much simone. btw, what i want to learn in here is to have a 
scheduler to create a new record in database every day, how can i achieve 
it using testing example above?

what i have tried is :
*models/db.py*
db.define_table('asdf',
Field('asdf'),
auth.signature )

*controllers/scheduler.py*
from gluon.scheduler import Scheduler

def demo1():
db.asdf.insert(asdf = 'asdf')
db.commit()

scheduler = Scheduler(db, tasks = dict(demo1 = demo1) )

scheduler.queue_task('demo1', prevent_drift = True, 
 repeats = 0, period = 5)

it seems the scheduler is execute everytime i access 
http://127.0.0.1:8000/test/scheduler/demo1, and i think it's not a 
scheduler, it's manually execute.

any idea how to achieve it using web2py way?

thanks and 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 scheduler period and repeats result not expected

2014-06-26 Thread Niphlod
you're missing a BG point. 

Either you need to queue a task as a result of some user action (i.e. send 
a reminder, calculate/aggregate/refresh some data, etc) --> usually it's a 
one-time-only activity, in which case, the following "pattern" applies
#models\scheduler.py
from gluon.scheduler import Scheduler

def demo1():
db.asdf.insert(asdf = 'asdf')
db.commit()

mysched = Scheduler(db, tasks = dict(demo1 = demo1) )

#controllers\a_controller.py
def an_action():
   ..
   #we need to schedule a background task
   mysched.queue_task('demo1')


Or you need a single task that repeats itself every once in a while 
(usually repeating tasks are "cron-like" and "maintenance-related"). 
In that case, you define the scheduler in models\scheduler.py, and you (as 
the admin-developer-god of the web application) queue a task in appadmin. 
Or you prepare a controller just for the occasion, that can only be 
accessed by you and run once (so you get only a SINGLE record in the 
scheduler_task table).

Now, back to your goal. If you want a single record to be added to the asdf 
table every day, you need a SINGLE task that has
repeats --> 0
period --> 60*60*24
prevent_drift --> True (if you care for "at the same time every day")

-- 
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: Error while inserting in table with custom id

2014-06-26 Thread Niphlod
was the table created by web2py  ?

On Thursday, June 26, 2014 9:53:31 AM UTC+2, at wrote:
>
> Hello,
>
> I am getting getting this:
>
> (lastval is not yet defined in this 
> session ) 
> while running:
> if db(db.user_role).isempty():
> db.user_role.insert(id=1, title='Application Administrator')
> db.user_role.insert(id=2, title='Account Administrator')
> db.user_role.insert(id=3, title='Account Member')
>
> whereas my table defination is simply as follows:
> db.define_table('user_role',
> Field('title', type='string', length=50, label=T('User Role Title'))
> )
>
> and in postgres:
> CREATE TABLE user_role
> (
>   id serial NOT NULL,
>   title character varying(50),
>   CONSTRAINT user_role_pkey PRIMARY KEY (id )
> )
> WITH (
>   OIDS=FALSE
> );
>
> Any help please ...
>
> Thanks & Regards
> AT
>
>

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

2014-06-26 Thread Tim Richardson

>
>
>
> Is this expected behaviour?
>
 
It is even documented  :)  

Look around here:
http://www.web2py.com/books/default/chapter/29/04/the-core?search=conditional

-- 
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: Error while inserting in table with custom id

2014-06-26 Thread at

Yes

On Thursday, 26 June 2014 14:55:35 UTC+5, Niphlod wrote:
>
> was the table created by web2py  ?
>
> On Thursday, June 26, 2014 9:53:31 AM UTC+2, at wrote:
>>
>> Hello,
>>
>> I am getting getting this:
>>
>> (lastval is not yet defined in this 
>> session ) 
>> while running:
>> if db(db.user_role).isempty():
>> db.user_role.insert(id=1, title='Application Administrator')
>> db.user_role.insert(id=2, title='Account Administrator')
>> db.user_role.insert(id=3, title='Account Member')
>>
>> whereas my table defination is simply as follows:
>> db.define_table('user_role',
>> Field('title', type='string', length=50, label=T('User Role Title'))
>> )
>>
>> and in postgres:
>> CREATE TABLE user_role
>> (
>>   id serial NOT NULL,
>>   title character varying(50),
>>   CONSTRAINT user_role_pkey PRIMARY KEY (id )
>> )
>> WITH (
>>   OIDS=FALSE
>> );
>>
>> Any help please ...
>>
>> Thanks & Regards
>> AT
>>
>>

-- 
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: Error while inserting in table with custom id

2014-06-26 Thread Simon Ashley
Believe it will be failing with the id=1 etc. Interfering with the primary 
key/ auto increment. Try it without.

-- 
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: my super heroic idea of the next scheduler

2014-06-26 Thread António Ramos
web2py.py -a yourpassword -K appname -X
does not work on windows
  i have web2py 2.9.5 and does not start scheduler at the same time as
web2py


2014-06-06 9:07 GMT+01:00 Niphlod :

> the scheduler doesn't need a decorator... for your own organization you
> can,e.g., put all the functions in one model file, or use comments ^_^
>
> with
> web2py.py -a yourpassword -K appname -X
> you can start in one command the webserver and the scheduler processes.
>
> On Thursday, June 5, 2014 12:24:23 PM UTC+2, Ramos wrote:
>>
>> Just kiding 
>>
>> is this simpler ?
>>
>> @task(* * * * *)
>> def myfunc():
>> bla bla bla
>> .
>>
>> It would be easier to detect a function under a schedule
>>
>> also can i stark the -K for the scheduler in the same command line as the
>> initial load of the web2py ?
>>
>> Regards
>> António
>>
>  --
> 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: Error while inserting in table with custom id

2014-06-26 Thread at

Yes you are right. Without id=1 it's working.
But if I insert data using postgres/psql with id=1, it doesn't give any 
error.

Regards,
AT

On Thursday, 26 June 2014 15:39:20 UTC+5, Simon Ashley wrote:
>
> Believe it will be failing with the id=1 etc. Interfering with the primary 
> key/ auto increment. Try it without.
>
>

-- 
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: Can't seem to verify password field...

2014-06-26 Thread Cliff Kachinske
Check the data types of element 0 in the tuples.

On Thursday, June 26, 2014 3:37:22 AM UTC-4, Encompass solutions wrote:
>
> I can't seem to get my key to verify:
>
> This is how I verify it:
>
> success = db.melodigram.deletion_key.validate(request.args(1)) == 
> (db(db.melodigram.unique_id == request.args(0)).select().first(), None)
>
> And this is how it is made:
> form = SQLFORM(db.melodigram)
> form.process(session = None, formname = None)
>
> Any ideas as to why this would be an issue?
> I just can't get success to be true.
> :( .. . .
> BR,
> Jason Brower
>

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


Re: [web2py] how to turn off the record counter on Sqlform.grid

2014-06-26 Thread Javier Pepe
I'm use this code:

form = SQLFORM.grid()
form.element('.web2py_counter',replace=None)


On Thu, Jun 26, 2014 at 2:04 AM, JorgeH  wrote:

> hello
> Is it possible to turn off the record counter , on the top right of the
> table generated by sqlform.frid ??
>
> --
> 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: multiple functions in one view

2014-06-26 Thread Richard
Hi,

I try to do exactly the same and have the following in my app:

controller:

def index():

response.js = '$.web2py.component("%s", target="graph1");' % 
URL('default', 'graph1.load')

index.html:

 
 


graph1.load contains a graph in pure JS

What am I overlooking?

KInd regards


On Tuesday, January 21, 2014 5:15:17 PM UTC+1, Anthony wrote:
>
> You could put both the form and the grid in ajax components. When the form 
> is submitted, it could send back a JS command to load the grid:
>
> In index.html:
>
> {{=LOAD('default', 'tracker_form.load', ajax=True)}}
> 
>
> Change your two existing views to a .load extension (not required, but 
> done by convention for component views), and remove the {{extend 
> 'layout.html'}} from each.
>
> In tracker_form, do:
>
> if form.process().accepted:
> response.js = '$.web2py.component("%s", target="content_grid");' % 
> URL('default', 'show_form.load')
> response.flash = 'Submitted Successfully!'
>
> Whenever the form is submitted and accepted, it will reload the grid in 
> the "content_grid" div.
>
> Anthony
>
> On Tuesday, January 21, 2014 10:37:04 AM UTC-5, En Ware wrote:
>>
>> Hello, 
>>
>>   I am trying to figure out how to call more then function per view.
>> I would like to be to have users fill out a form and and then as soon as 
>> they submit 
>> show the results sort of like SQLFORM. I also want to make the "grid" 
>> editable so
>> that users can hide rows and columns. 
>>
>> Thanks in Advance.
>>
>>
>>
>> #controller default.py
>>
>> def index():
>> return dict()
>>
>>
>> def tracker_form():
>> record = db.content(request.args(0))
>> show_record = request.args(0)
>> form = SQLFORM(db.content, record, show_record)
>> if form.process().accepted:
>> response.flash = 'Submitted Successfully!'
>> #response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
>> #return dict(show_record=show_record)
>> elif form.errors: 
>> response.flash = 'Form is not correct; please correct and submit 
>> again'
>> else:
>> response.flash = 'Please fill out the damn form'
>> return dict(form=form)
>>  
>>
>>
>> def show_form():
>> #rows = db().select(db.content.ALL)
>> return dict(grid=SQLFORM.grid(db.content))
>>
>>
>>
>>
>>
>> #views 
>>
>> #tracker_form.html
>>
>> {{extend 'layout.html'}}
>> Tracking
>> {{=form}}
>> {{=BEAUTIFY(request.vars)}}
>>
>>
>> #show_form.html
>>
>> {{extend 'layout.html'}}
>> Records processed
>>
>> {{=grid}}
>>
>> http://127.0.0.1:8000/WnD/default/tracker_form";>Back
>>
>>
>> #index.html
>>
>> {{extend 'layout.html'}}
>> Watch and Defend
>> 
>> Current customers:
>> 
>> 
>>
>>
>> http://127.0.0.1:8000/WnD/default/tracker_form>Tracker 
>> Monitoring click on the link
>> 
>> 
>>
>>
>>
>>

-- 
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: Error while inserting in table with custom id

2014-06-26 Thread at

So it's incorrect or impermissible to add records with custom ids?

Thanks


On Thursday, 26 June 2014 16:33:02 UTC+5, at wrote:
>
>
> Yes you are right. Without id=1 it's working.
> But if I insert data using postgres/psql with id=1, it doesn't give any 
> error as well.
>
> Regards,
> AT
>
> On Thursday, 26 June 2014 15:39:20 UTC+5, Simon Ashley wrote:
>>
>> Believe it will be failing with the id=1 etc. Interfering with the 
>> primary key/ auto increment. Try it without.
>>
>>

-- 
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 scheduler period and repeats result not expected

2014-06-26 Thread 黄祥
yeah, i realize that something i'm lacked off, unfortunately, i don't know 
where is it. tried again using your code but still no luck 
started from scratch

*models\db_wizard_0.py*
db.define_table('asdf',
Field('asdf'),
auth.signature )

*models\scheduler.py*
from gluon.scheduler import Scheduler

def demo1():
db.asdf.insert(asdf = 'asdf')
db.commit()

mysched = Scheduler(db, tasks = dict(demo1 = demo1) )

*controlelrs\test.py*
def queue_task():
mysched.queue_task('demo1')
"""
mysched.queue_task('demo1', prevent_drift = True, 
   repeats = 0, period = 5)
"""

*command prompt*
cd C:\web2py
python web2py.py -K test -X

checked the scheduler_task, scheduler_worker and asdf tables via appadmin.

count to 5 or 10 and then refresh the scheduler_task, scheduler_worker and 
asdf tables on appadmin.

nothing happen

i even created the scheduler_task manually from appadmin 
(http://127.0.0.1:8000/test/appadmin/insert/db/scheduler_task), but still 
no luck (no error occured, but the scheduler didn't run). 
execute the test controller (http://127.0.0.1:8000/test/test/queue_task) 
got the same result.
for testing purpose, i set the period = 5, so that, i don't have to long 
waiting for the task execute by the scheduler.

i'm running on windows 7 64 bit, with web2py latest source code version, 
python 2.7.

any idea, where is my mistake on code above or step i took to run the 
scheduler?

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


Re: [web2py] how to turn off the record counter on Sqlform.grid

2014-06-26 Thread JorgeH
Thanks!

On Thursday, June 26, 2014 7:31:28 AM UTC-5, Javier Pepe wrote:
>
> I'm use this code:
>
> form = SQLFORM.grid()
> form.element('.web2py_counter',replace=None)
>
>
> On Thu, Jun 26, 2014 at 2:04 AM, JorgeH > 
> wrote:
>
>> hello
>> Is it possible to turn off the record counter , on the top right of the 
>> table generated by sqlform.frid ??
>>  
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] How to manage repeated fields/attributes using form.custom.widget.fieldname?

2014-06-26 Thread Omar Meat Boy Gutiérrez
I have three tables (country, state, and town) each one has a field called 
name:

db.define_table('country'
Field('name', 'string'),
... more fields ...
)

db.define_table('state'
Field('name', 'string'),
Field('country_id', 'reference country'),
... more fields ...
)

db.define_table('town'
Field('name', 'string'),
Field('state_id', 'reference state'),
... more fields ...
)

In the controller I join these tables with SQLFORM.factory(db.country, 
db.state, db.town) in order to generate a form:

 form = SQLFORM.factory(db.country, db.state, db.town)

I am using form.custom in my view. However I don't know how to 
differentiate between these fields (country.name, state.name, and 
town.name), when I call form.custom.widget.name I get the first one defined 
in SQLFORM.factory(). 

It is not in my hand to change the name of the fieldnames in the model (the 
solution I thought). It is not possible. I need to use form.custom because 
I am splitting my form in tabs.

Any suggestion?

-- 
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 scheduler period and repeats result not expected

2014-06-26 Thread Niphlod
ok. steps.

web2py.py -a yourpassword

go to /appname/test/queue_task

go to /appname/appadmin/select/db?query=db.scheduler_task.id>0

if nothing is there, then in controller test.py the function queue_task is 
not queuing the task.

if a single row is there, then, open a terminal and start the scheduler 
process with

web2py.py -K appname

wait 5 seconds, go to 
/appname/appadmin/select/db?query=db.scheduler_worker.id>0

if nothing is there, your worker process isn't actually working, or is 
unable to talk to the db.

if a single row is there, then it's working.

wait a few seconds, go 
to  /appname/appadmin/select/db?query=db.scheduler_task.id>0

check that the status turns to COMPLETED.

You can now go to  /appname/appadmin/select/db?query=db.asfd.id>0

to check for the record inserted by the task.

On Thursday, June 26, 2014 4:18:39 PM UTC+2, 黄祥 wrote:
>
> yeah, i realize that something i'm lacked off, unfortunately, i don't know 
> where is it. tried again using your code but still no luck 
> started from scratch
>
> *models\db_wizard_0.py*
> db.define_table('asdf',
> Field('asdf'),
> auth.signature )
>
> *models\scheduler.py*
> from gluon.scheduler import Scheduler
>
> def demo1():
> db.asdf.insert(asdf = 'asdf')
> db.commit()
>
> mysched = Scheduler(db, tasks = dict(demo1 = demo1) )
>
> *controlelrs\test.py*
> def queue_task():
> mysched.queue_task('demo1')
> """
> mysched.queue_task('demo1', prevent_drift = True, 
>repeats = 0, period = 5)
> """
>
> *command prompt*
> cd C:\web2py
> python web2py.py -K test -X
>
> checked the scheduler_task, scheduler_worker and asdf tables via appadmin.
>
> count to 5 or 10 and then refresh the scheduler_task, scheduler_worker and 
> asdf tables on appadmin.
>
> nothing happen
>
> i even created the scheduler_task manually from appadmin (
> http://127.0.0.1:8000/test/appadmin/insert/db/scheduler_task), but still 
> no luck (no error occured, but the scheduler didn't run). 
> execute the test controller (http://127.0.0.1:8000/test/test/queue_task) 
> got the same result.
> for testing purpose, i set the period = 5, so that, i don't have to long 
> waiting for the task execute by the scheduler.
>
> i'm running on windows 7 64 bit, with web2py latest source code version, 
> python 2.7.
>
> any idea, where is my mistake on code above or step i took to run the 
> scheduler?
>
> thanks and 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: Does SQLFORM.grid editable=True require an explicit db.commit()?

2014-06-26 Thread JoeCodeswell
Thanks, Niphlod. I got it working with a custom search widget.

BTW, the original post got a bit garbled when i edited it. Sorry about that.

Thanks again, Niphlod.

Love and peace,

Joe

On Saturday, June 21, 2014 11:46:04 AM UTC-7, Niphlod wrote:
>
> try simplifying the controller stripping the useless parts and start from 
> there. the grid doesn't need a commit as every db operation is committed at 
> the end of a successfull request automatically.
>

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


[web2py] Re: how to use gluon Expose

2014-06-26 Thread Jim Karsten
I was experimenting with Expose this week and I came across similar 
problems. For example, if I click on a subfolder link, the page refreshes 
but still displays the contents of the base folder.

After some digging, I think I found the problem. The code in Expose uses 
request.raw_args to determine the subfolder or link clicked. If routers is 
set in routes.py, request.raw_args is never set, so the args is always an 
empty list. If Expose used request.args, it would work.

I created a bug report here: 
http://code.google.com/p/web2py/issues/detail?id=1947


On Monday, April 21, 2014 10:14:57 AM UTC-4, Louis Amon wrote:
>
> It gets me the same result : broken links & images
>
> On Monday, April 21, 2014 3:28:00 PM UTC+2, Massimo Di Pierro wrote:
>>
>> Can you try:
>>
>> Expose(os.path.join(request.folder,'static','presse'))
>>
>> On Monday, 21 April 2014 06:01:42 UTC-5, Louis Amon wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to expose a folder in my application, so I tried to use the 
>>> Expose function as described here 
>>> 
>>>
>>> My controller looks like :
>>>
>>> from gluon.tools import Expose
 def presse():
 files=Expose(request.folder+'static/presse')
 return dict(files=files)
>>>
>>>
>>> When I reach the correct URL, I see links for every file in that folder, 
>>> but they point to nothing.
>>>
>>> Same goes for image previews : they are broken.
>>>
>>>
>>> I checked one of the broken previews, and it points to : 
>>> "/presse/logo.png", when it should point to "/static/presse/logo.png".
>>>
>>>
>>> What did I do 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: web2py scheduler period and repeats result not expected

2014-06-26 Thread 黄祥
yes, followed your step, i understood the logic flow of the web2py 
scheduler and made it work, thank you so much, simone for the pointers. 
just wondering, the precision for second is not exact on created_on, tested 
using period = 5 and period = 60
here is the steps i took :
*cmd*
cd C:\web2py\applications
xcopy welcome test /s /e /h
D

*cmd*
notepad C:\web2py\applications\test\models\db_wizard_0.py

db.define_table('asdf',
Field('asdf'),
auth.signature )

*cmd*
notepad C:\web2py\applications\test\models\scheduler.py
from gluon.scheduler import Scheduler

def demo1():
db.asdf.insert(asdf = 'asdf')
db.commit()

mysched = Scheduler(db, tasks = dict(demo1 = demo1) )

*cmd*
notepad C:\web2py\applications\test\controlelrs\test.py
def queue_task():
#mysched.queue_task('demo1')
mysched.queue_task('demo1', prevent_drift = True, repeats = 0, period = 
5)

*cmd*
cd C:\web2py
python web2py.py -a a

*web browser*
http://127.0.0.1:8000/test/test/queue_task

http://127.0.0.1:8000/test/appadmin/select/db?query=db.scheduler_task.id%3E0

*cmd*
cd C:\web2py
python web2py.py -K test

*web browser*
http://127.0.0.1:8000/test/appadmin/select/db?query=db.scheduler_worker.id%3E0

http://127.0.0.1:8000/test/appadmin/select/db?query=db.scheduler_task.id%3E0

http://127.0.0.1:8000/test/appadmin/select/db?query=db.asdf.id%3E0

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


Re: [web2py] Re: Error while inserting in table with custom id

2014-06-26 Thread Greg Sier
Seems to be a postgresql specific issue. Fails in the DAL at when executing
'select lastval()'. SQlite and MySQL are fine. The command also fails at
the pg command line level. This was changed back in December but uncertain
if the issue existed prior to this
https://groups.google.com/forum/?fromgroups#!searchin/web2py/select$20lastval().
Only came across it 3 hours before you when attempting bulk_insert from a
select.as_list() dict to move between databases. Cant see a quick or easy
work around, and the issue probably needs a PR.


On Thu, Jun 26, 2014 at 11:42 PM, at  wrote:

>
> So it's incorrect or impermissible to add records with custom ids?
>
> Thanks
>
>
>
> On Thursday, 26 June 2014 16:33:02 UTC+5, at wrote:
>
>>
>> Yes you are right. Without id=1 it's working.
>> But if I insert data using postgres/psql with id=1, it doesn't give any
>> error as well.
>>
>> Regards,
>> AT
>>
>> On Thursday, 26 June 2014 15:39:20 UTC+5, Simon Ashley wrote:
>>>
>>> Believe it will be failing with the id=1 etc. Interfering with the
>>> primary key/ auto increment. Try it without.
>>>
>>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/z-docU0cUN4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Greg Sier
Sier Associates AU
+61 7 55736422

-- 
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: Error while inserting in table with custom id

2014-06-26 Thread Michele Comitini
id is implicit and defined as serial, implying that there is a sequence
that is used to fill proper values.
id is intended to be unique and primary key: an integer generator that
guarantee uniqueness or at least has a very low probability of conflict is
the standard way to go.  This is very important in a multiuser environment
such as web2py.

Of course you can do inserts with explicit values for the id column, but
you should resort to the executesql() method of DAL. And remember to update
the related sequence properly to avoid conflicts.

mic


2014-06-26 23:36 GMT+02:00 Greg Sier :

> Seems to be a postgresql specific issue. Fails in the DAL at when
> executing 'select lastval()'. SQlite and MySQL are fine. The command also
> fails at the pg command line level. This was changed back in December but
> uncertain if the issue existed prior to this
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/select$20lastval().
> Only came across it 3 hours before you when attempting bulk_insert from a
> select.as_list() dict to move between databases. Cant see a quick or easy
> work around, and the issue probably needs a PR.
>
>
> On Thu, Jun 26, 2014 at 11:42 PM, at  wrote:
>
>>
>> So it's incorrect or impermissible to add records with custom ids?
>>
>> Thanks
>>
>>
>>
>> On Thursday, 26 June 2014 16:33:02 UTC+5, at wrote:
>>
>>>
>>> Yes you are right. Without id=1 it's working.
>>> But if I insert data using postgres/psql with id=1, it doesn't give any
>>> error as well.
>>>
>>> Regards,
>>> AT
>>>
>>> On Thursday, 26 June 2014 15:39:20 UTC+5, Simon Ashley wrote:

 Believe it will be failing with the id=1 etc. Interfering with the
 primary key/ auto increment. Try it without.

  --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/z-docU0cUN4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Greg Sier
> Sier Associates AU
> +61 7 55736422
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Error while inserting in table with custom id

2014-06-26 Thread Simon Ashley

>
> I tend to agree with this. We ended up dropping the id field from 
> bulk_insert routines and if we need integrity (for references) in the 
> target databases, we would/ should base it on other fields.
>

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


[web2py] Re: Group or/and Field

2014-06-26 Thread Massimo Di Pierro
The group information is loaded on login and cached in the session. 
If you check 

auth.user_groups you find a dictionary of {group_id:group_role}.

On Wednesday, 25 June 2014 13:08:17 UTC-5, Carlos Zenteno wrote:
>
> I am classifying my users within groups (ie, carpenters group) but I am 
> wondering
> if it would be useful or more efficient to also add a field in auth_user 
> (ie, is_carpenter).
>
> Would it be faster to check the is_carpenter flag in the db or to do it 
> from the auth
> system checking the membership of the user to the group?
>
> Would it be better to do both?  use the group to restricting functions and 
> check
> the field for other logic?
>
> 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: combining two queries on different table (one reference the other) - newbie db

2014-06-26 Thread Massimo Di Pierro
This is  very wrong:

 q1 = eval('db. userLanguage.'+ language )== True

what is it supposed to be?


 q1 = db.userLanguage[language] == True

I am not sure. Once q1 is correct, this works:

 results = db(q1 & q2).select()

On Wednesday, 25 June 2014 17:04:28 UTC-5, Riccardo C wrote:
>
> Dear all,
>
> I am trying to formulate a query to get ALL the people that know a 
> language AND leave in a specific city.
> As I am not an expert I thought that was a good idea to have two tables as 
> following:
> auth.settings.extra_fields['auth_user']= [ 
> Field('city',requires=IS_IN_SET(('UK - London','IT - Milano','USA - New 
> York')) )]
>
>
> db.define_table('userLanguage',
> Field('idUser','reference auth_user', unique=True),
> Field('French','boolean',default = False),
> Field('Italian','boolean',default = False),
> Field('Chinese','boolean',default = False),
> Field('Indian','boolean',default = False))
>
> in term of controller search function I decided to get the information 
> from the URL (that in my idea will be generate from a javascript function 
> depending of what the user select on the page):
> def search():
> 
> lstLanguages = ['French',   'Italian','Chinese','Indian']
>
> lstCity = ['UK - London','IT - Milano','USA - New York']
> 
> language = lstLanguages[int(request.vars.n)]
> userCity = lstCity[int(request.vars.c)]
> 
> q1 = eval('db. userLanguage.'+ language )== True
> q2 = db.auth_user.city  == userCity
> 
> """ QUERY: give me the list of users that know that language and live 
> in that city"""
>
> 
> return dict(form = chefResults)
>
> As written above I tried different way to do that (without succed):
>
> results = db(q1 & q2).select() """ gives me, as expected the sum of the 
> two query results"""
> ---
> results2 = db(q1).select() '''this return those who speak the selected 
> language'''
> searchresults = [row for row in results2 if results2.idUser_city == 
> userCity] '''this make web2py to crash! I have to kill the process...why?'''
>
> I hope to not have bother you too much, I would like to learn and 
> understand... in particular:
> 1) which is the best way of doing this kind of query?
> 2) is there a better way of structuring the data (db tables) 
> 3) why it crashes?!
> 4) what would be the best way to pass the search criteria to the function? 
>
> Thanks for any answer and I hope it might be useful for other people as 
> well.
>
> Regards, 
>
> Riccardo
>
>
>
>

-- 
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] SQLFORM cannot save to database

2014-06-26 Thread hajere

Pls can someone help here. Am new to web2py. I produce a form using SQLFORM 
with a submit button. After filling the form and clicking submit, i 
discoverd the values in the form are not saved into the database. I login 
using the appadmin, i could create and insert into the database. I will 
like to know what am doin wrong.

my code snippet:

@auth.requires_login()
def add_subject():
form = SQLFORM(db.subject_result, ignore_rw=True)

if FORM.accepts(form, request.vars):

#session.form_vars = request.vars
response.flash = 'Subject Saved'
#db.commit() if i comment this out the same thing happen.
  
 
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'fill the form'


records = db().select(db.subject_result.ALL)

return dict(form=form, records=records)

-- 
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] Database query using exclude or "Does not contain"

2014-06-26 Thread Douglas Campbell
Hello,

I am trying to filter out specific values in an SQLFORM.grid but I can not 
figure out how to do this in the Query. Right now I have something like:

 (cd.value.contains(filter_value_inc, all=False))


And this gets the values that I want to be included. filter_value_inc holds 
a list of strings that I want to include. Now I want to also have a 
filter_value_exc that holds a list of strings I want to EXCLUDE from the 
query, basically the exact opposite of what the .contains() does. 


Example:

database values:
Red-Green
Blue-yellow
Blue-Green
Blue-Red
Red-Orange
Green-Red

I want to include everything that has Red in it AND exclude everything with 
Blue. The values I would want it to return is Red-Green, Red-Orange, and 
Green-Red but exclude Blue-Red since it contains "Blue". 


I know how to do this using pure SQL but I am having a hard time figuring 
out how to do it in Web2Py. 


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] SQLFORM.grid woes

2014-06-26 Thread hvjunk
Hi there, 

 Yes I'm new to wep2py *and* to Python (other than having edited some 
Gentoo ebuilds many summers ago), but it was the advice for the simplest 
web framework to create simple input/edit functionality for a database to 
have customer details captured in a closed environment (ie. only trusted 
employees on the network and the office, and I mean trusted as in they all 
have all the access to all the paper and other files in the current 
environment)

 So, I have a SOLIDFORM for entry (though the table and row things doesn't 
work that great as I have 2/4/3/1/4/2/2/2/2 columns per row and spacing is 
off), and now I try to get a SQLFORM.grid going to list and edit the 
entries already inserted. I've also cleaned up the standard layout.html to 
only show what I need/want (like removing the auth links on the top right).

 Yesterday I had an hour to look at the buttons in SQLFORM.grid to edit 
their actions, but on first search only tried the links= which just add an 
extra link, not replaced/edit the buttons, which pointed me to the jquery 
etc. to be investigated, at which point I had to rush out for the rest of 
the day.

 This morning somethings broke... and yes, it *was* me, but I don't know 
where/what ;( (had too many customers telling me "I/we didn't do do 
nothing" and then I showed them what and then they remember something 
totally different):

1) The SQLFORM.grid nice and gray buttons disappeared, and they just show 
up as normal links, no javascript ;(
 Where do I start to find that problem/issue?

2) buttons_placement='yes' throws an error when included in the 
SQLFORM.grid parameter list:

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 220, in restricted
exec ccode in environment
  File "/home/www-data/web2py/applications/hvt/controllers/members.py" 
, line 
54, in 
  File "/home/www-data/web2py/gluon/globals.py", line 385, in 
self._caller = lambda f: f()
  File "/home/www-data/web2py/applications/hvt/controllers/members.py" 
, line 
50, in list
links=[lambda row: A('View',_href=URL('view',args=[grdb.clients,row.id]))]
TypeError: __call__() got an unexpected keyword argument 'buttons_placement'


def list():
grid = SQLFORM.grid(grdb.clients,
buttons_placement='left',

fields=[grdb.clients.id,grdb.clients.Surname,grdb.clients.Initials,grdb.clients.Email],
user_signature=False,
links=[lambda row: 
A('View',_href=URL('view',args=[grdb.clients,row.id]))]
)


What do I miss where?
Thanks for the help thus far

-- 
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] Error : unable to open database file

2014-06-26 Thread Sandeep Kumar
Hi,
 I am getting this strange error one in 10 times in my app. The error 
is " unable to open database file". I am 
getting this error after i replaced the *databases* folder with one from my 
backup app which is running on a different server. I think the plugin_wiki 
is has some problem. I want to uninstall this plugin_wiki and reinstall it 
but then i fear of losing all the pages that were created using 
plugin_wiki. Can someone help me out on this?

The error traceback is as follows : 

 Traceback (most recent call last):

  File "/backup1/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/backup1/web2py/applications/lims/models/plugin_wiki.py" 
, line 
715, in 
plugin_wiki=PluginWiki()
  File "/backup1/web2py/applications/lims/models/plugin_wiki.py" 
, line 
534, in __init__
code_page = db(db.plugin_wiki_page.slug=='meta-code').select().first()
  File "/backup1/web2py/gluon/dal.py", line 9958, in select
return adapter.select(self.query,fields,attributes)
  File "/backup1/web2py/gluon/dal.py", line 2245, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "/backup1/web2py/gluon/dal.py", line 1704, in select
return self._select_aux(sql,fields,attributes)
  File "/backup1/web2py/gluon/dal.py", line 1669, in _select_aux
self.execute(sql)
  File "/backup1/web2py/gluon/dal.py", line 1784, in execute
return self.log_execute(*a, **b)
  File "/backup1/web2py/gluon/dal.py", line 1778, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
OperationalError: unable to open database file

-- 
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] Debug Web2py with Wing IDE

2014-06-26 Thread Omri Levy
Hi ,

I asked Wing support the following question:

 I am using Web2py framework. I saw a video that says the Wing can
> debug a running python code no matter if it launched it itself. When
> reading this: http://wingware.com/doc/howtos/web2py
> I see that I can only debug Web2py in a way that I need to rerun the
> server from Wing for each time I hit 'Debug'. Is there any better way to
> do it?
>

*They replied:*
*This is our recommended approach because of the difficulties reloading 
code in Python.  Does web2py have code reloading?  It's been some time 
since I worked with it.  Or does it have a master process that spawns a new 
sub process when things change?  django and some other frameworks work this 
way.*

Do someone know what is the answer to these two questions?

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: Undesired redirect to other page after submitting a form

2014-06-26 Thread Tom Clerckx
Sorry being persistent on this, but has somebody any idea why the observed 
behavior is in place?


Best regards,
Tom.

On Thursday, June 19, 2014 9:46:06 AM UTC+2, Tom Clerckx wrote:
>
> Hi,
>
> I have some undesired behavior in my app that I was able to resolve, but I 
> would like to understand what goes wrong.
> I could easily reproduce the problem with a simple test-application, 
> containing two pages and two forms (I'm skipping the boilerplate code that 
> is created when making a new application):
>
> menu.py
> response.menu = [
> (T('Home'), False, URL('default', 'index'), []),
> (T('Secondpage'), False, URL('default', 'secondpage'), []),
> ]
>
> controller
> def index():
> form = SQLFORM.grid(db.contact, create=True, user_signature=False, )
> return dict(form=form)
>
> def secondpage():
> form = SQLFORM.grid(db.activity, create=True, user_signature=False, )
> return dict(form=form)
>
> index.html
> {{extend 'layout.html'}}
> Index page
> {{=form}}
>
> secondpage.html
> {{extend 'layout.html'}}
> Welcome to the 2nd page
> {{=form}}
>
> db.py
> contact = db.define_table('contact',
>   Field('first_name', 'string'),
>   Field('last_name', 'string'),
>   )
> 
> activity = db.define_table('activity',
> Field('what_you_plan_to_do', 'string'),
> )
>
> The problem occurs as follows:
>
> * I go to the index page
> * I press the add button opening up the contacts form (which I don't fill 
> in at this point)
> * In the menu I now press the link to the secondpage
> * When the secondpage is loaded I press the browser's back-button
> * Now I see the contacts form again which I fill in
> * When I now press the Submit button, I am redirected to the secondpage as 
> opposed to staying on the index page, which is not the desired outcome.
>
> I could resolve this by giving the forms a formname, but I would like to 
> understand why this behavior occurs.
> In this specific example the undesired behavior is not critical, but it 
> was really a problem in my app as the redirect went to a .load page that 
> did not contain any css styling.
>
>
> Updated controller resolving the problem
> def index():
> form = SQLFORM.grid(db.contact, create=True, user_signature=False, 
> formname='contact')
> return dict(form=form)
>
> def secondpage():
> form = SQLFORM.grid(db.activity, create=True, user_signature=False, 
> formname='activity')
> return dict(form=form)
>
>
> web2py version info
> 2.8.2-stable+timestamp.2013.11.28.13.54.07
> (Running on Rocket 1.2.6, Python 2.7.5)
>
>
> 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] Access auth.signature from different database

2014-06-26 Thread Bilal Hasan
I have this code here in a different model file called db_nameofapp.py:

dmz.define_table('nds_ticketing_comments',
Field(blah),
Field(blah2),
Field(blah3),
auth.signature
)

DAL breaks when trying to access auth.signature.

in my db.py:
auth = Auth(db)
...
...
..
etc.

Sorry I can't copy and paste as I work on either a remote machine or VM.

Anyway, DAL breaks on auth.signature when defining a table on ANOTHER 
database (in my case: 'dmz').

-- 
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] Inserting to database after submit

2014-06-26 Thread hajere

Hello,

I am new to web2py. I am running this application , my form was produced 
using SQLFORM. I noticed after i click submit the data don't get inserted 
into the database. However if go through the admin and do new record my 
database get updated. I dont know if I will have to do commit or something 
to insert the record. Pls I will appreciate your help.

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: web2py password encryption/decryption

2014-06-26 Thread farmy zdrowia
Massimo,
Your code hash password,  but it is not recognized by Joomla. :)

Anyway I have got this class in py from phpass fremwork web page. It works! 
Now CUSTOMIZE CRYPT is the last effort. hash_password and check_password 
shell be used. 






import os
import time
import hashlib
import crypt

try:
import bcrypt
_bcrypt_hashpw = bcrypt.hashpw
except ImportError:
_bcrypt_hashpw = None


class PasswordHash:
def __init__(self, iteration_count_log2=8, portable_hashes=True,
 algorithm=''):
alg = algorithm.lower()
if (alg == 'blowfish' or alg == 'bcrypt') and _bcrypt_hashpw is 
None:
raise NotImplementedError('The bcrypt module is required')
self.itoa64 = 
'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
if iteration_count_log2 < 4 or iteration_count_log2 > 31:
iteration_count_log2 = 8
self.iteration_count_log2 = iteration_count_log2
self.portable_hashes = portable_hashes
self.algorithm = algorithm
self.random_state = '%r%r' % (time.time(), os.getpid())

def get_random_bytes(self, count):
outp = ''
try:
outp = os.urandom(count)
except:
pass
if len(outp) < count:
outp = ''
rem = count
while rem > 0:
self.random_state = hashlib.md5(str(time.time())
+ self.random_state).hexdigest()
outp += hashlib.md5(self.random_state).digest()
rem -= 1
outp = outp[:count]
return outp

def encode64(self, inp, count):
outp = ''
cur = 0
while cur < count:
value = ord(inp[cur])
cur += 1
outp += self.itoa64[value & 0x3f]
if cur < count:
value |= (ord(inp[cur]) << 8)
outp += self.itoa64[(value >> 6) & 0x3f]
if cur >= count:
break
cur += 1
if cur < count:
value |= (ord(inp[cur]) << 16)
outp += self.itoa64[(value >> 12) & 0x3f]
if cur >= count:
break
cur += 1
outp += self.itoa64[(value >> 18) & 0x3f]
return outp

def gensalt_private(self, inp):
outp = '$P$'
outp += self.itoa64[min([self.iteration_count_log2 + 5, 30])]
outp += self.encode64(inp, 6)
return outp

def crypt_private(self, pw, setting):
outp = '*0'
if setting.startswith(outp):
outp = '*1'
if not setting.startswith('$P$') and not setting.startswith('$H$'):
return outp
count_log2 = self.itoa64.find(setting[3])
if count_log2 < 7 or count_log2 > 30:
return outp
count = 1 << count_log2
salt = setting[4:12]
if len(salt) != 8:
return outp
if not isinstance(pw, str):
pw = pw.encode('utf-8')
hx = hashlib.md5(salt + pw).digest()
while count:
hx = hashlib.md5(hx + pw).digest()
count -= 1
return setting[:12] + self.encode64(hx, 16)

def gensalt_extended(self, inp):
count_log2 = min([self.iteration_count_log2 + 8, 24])
count = (1 << count_log2) - 1
outp = '_'
outp += self.itoa64[count & 0x3f]
outp += self.itoa64[(count >> 6) & 0x3f]
outp += self.itoa64[(count >> 12) & 0x3f]
outp += self.itoa64[(count >> 18) & 0x3f]
outp += self.encode64(inp, 3)
return outp

def gensalt_blowfish(self, inp):
itoa64 = 
'./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
outp = '$2a$'
outp += chr(ord('0') + self.iteration_count_log2 / 10)
outp += chr(ord('0') + self.iteration_count_log2 % 10)
outp += '$'
cur = 0
while True:
c1 = ord(inp[cur])
cur += 1
outp += itoa64[c1 >> 2]
c1 = (c1 & 0x03) << 4
if cur >= 16:
outp += itoa64[c1]
break
c2 = ord(inp[cur])
cur += 1
c1 |= c2 >> 4
outp += itoa64[c1]
c1 = (c2 & 0x0f) << 2
c2 = ord(inp[cur])
cur += 1
c1 |= c2 >> 6
outp += itoa64[c1]
outp += itoa64[c2 & 0x3f]
return outp

def hash_password(self, pw):
rnd = ''
alg = self.algorithm.lower()
if (not alg or alg == 'blowfish' or alg == 'bcrypt') \
 and not self.portable_hashes:
if _bcrypt_hashpw is None:
if (alg == 'blowfish' or alg == 'bcrypt'):
raise NotImplementedError('The bcrypt module is 
required')
else:
rnd = self.get_random_bytes(16)
salt = self.gensalt_blowfish(rnd)
hx = _bcrypt_hashpw(pw, salt)
if len(hx) == 60:
 

[web2py] Unclear how to create a unique multiple fields on web2py

2014-06-26 Thread Daniel Lafrance
Hi gang

I am quite new to web2py and i am confronted to the following lack of my 
own knowledge.

In other DB engine one can write :

create table sometable (
a_field varchar(10),
b_field timestamp default date(now()),
unique(a_field, b_field)
);

wich I have reproduce in web2py using the following syntax:

# coding: utf8
db.define_table('sometable',
Field('a_field', 'string', length=10),
Field('b_field','datetime', default=request.now),
Field('unique_fields','text',compute=lambda s: 
str(s.a_field) + str(s.b_field), unique=True)
)
db.sometable.requires = IS_NOT_IN_DB(db, 'sometable.unique_fields')

Written as is it works and I get a ticket when I try to create duplicate.

My question is : 

In some posts it is being said not to put the "unique=True" for the unique 
field.
I have tried it, (after deleting all databases files created by web2py) and 
the IS_NOT_IN_DB clause does not seem to work.

Any idea of what I am doing wrong ?

Regard's

Daniel L


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


[web2py] Re: A way to trigger method on update?

2014-06-26 Thread Omri Levy
Thank you! :)

On Thursday, June 26, 2014 12:25:00 AM UTC+3, 黄祥 wrote:
>
> afaik, compute didn't work on update. for onupdate, is execute on form 
> level not on dal, please take a look at book chapter about that.
>
> ref:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators
>
> 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: Hypermedia API and Collection+JSON in web2py

2014-06-26 Thread Massimo Di Pierro
No. At least not in the way web2py uses it.

On Wednesday, 25 June 2014 11:58:01 UTC-5, Cliff Kachinske wrote:
>
> Massimo,
>
> I like the way your thoughts are headed.
>
> doesn't the many2many issue goes away if one uses, for example, MongoDB?
>
> On Sunday, June 22, 2014 4:45:06 PM UTC-4, Massimo Di Pierro wrote:
>>
>> I added Hypermedia API support to web2py using Collection+JSON. 
>> Experimental.
>> Collection+JSON is a standard for self documenting RESTful API.
>> Read more: http://amundsen.com/media-types/collection/
>>
>> Example
>> =
>>
>> Let's say you have a model:
>>  
>> db.define_table('thing',Field('name'))
>>
>> and in controller default.py you add
>>
>> def api():
>>  from gluon.contrib.hypermedia import Collection
>>  rules = {
>> 'thing': {
>> 'GET':{'query':None,'fields':['id', 'name']},
>> 'POST':{'query':None,'fields':['name']},
>> 'PUT':{'query':None,'fields':['name']},
>> 'DELETE':{'query':None},
>>}}
>> return Collection(db).process(request,response,rules)
>>
>> And now by magic your table "thing" is fully exposed using the 
>> Collection+JSON API. The API is self documenting and supports GET, POST, 
>> PUT, DELETE, etc.
>>
>> For example you can do things like:
>>
>> curl http://127.0.0.1:8000/app/default/api/thing
>> curl http://127.0.0.1:8000/app/default/api/thing/1
>> curl http://127.0.0.1:8000/app/default/api/thing?id=1
>> curl 
>> http://127.0.0.1:8000/app/default/api/thing?name=Box&id.gt=10&_offest=10&_limit=30
>> curl -X POST -d name="Box" http://127.0.0.1:8000/app/default/api/thing
>> curl -X PUT -d name="Chair" http://127.0.0.1:8000/app/default/api/thing
>> ?name=Box
>> curl -X DELETE 
>> http://127.0.0.1:8000/super/collections/conform/thing?name=Chair
>>
>> The API are completely self documenting as explained here 
>> http://amundsen.com/media-types/collection/
>>
>> It is customizable
>> ==
>>
>>rules = {
>> 'thing': {
>> 'GET':{'query':None,'fields':['id', 'name']},
>> 'POST':{'query':None,'fields':['name']},
>> 'PUT':{'query':None,'fields':['name']},
>> 'DELETE':{'query':None},
>>}}
>>
>> Let you specify which tables are exposed, which methods are available and 
>> which fields are exposed for each method. The query property lets you 
>> specify optional filters for example  { 
>> 'query':db.thing.name.startswith('A'),} will only exposed things 
>> starting with letter A. Fields can be conditional and different for 
>> different users or for the same user in different stages of a workflow (the 
>> communication is stateless, but the server is not).
>>
>> Supports complex queries
>> =
>> http:/./{table}
>> http:/./{table}/{id}
>> http:/./{table}?{field}=value
>> http:/./{table}?{field}.gt=value # field>value
>> http:/./{table}?{field}.le=value # field<=value
>> ...
>> http:/./{table}?_orderby={field}
>> http:/./{table}?_limitby=value
>> http:/./{table}?_offset=value
>> ...
>> and combinations there of. They are mapped directly into DAL queries. 
>> More examples are in the API response itself.
>>
>> The bigger picture
>> ===
>>
>> This API provide enough information to generate forms and tables and grid 
>> completely client side. Recently we stumbled against the problem of moving 
>> from Bootstrap 2 to Bootstrap 3 because so much of the form and grid logic 
>> is server side. My plan is to move most of the logic in the JS library and 
>> allow users to customize them  for different CSS frameworks.
>>
>> Eventually (in dreams) I would like to have a very slim framework based 
>> on bottle+dal+validators+auth+collection and have client side only 
>> templates (based on jquery, sugar, and ractive.js) that can generate forms 
>> and grids based the collection API. This framework could ship with web2py 
>> and allow you to program using same web interface that we all love. There 
>> are many design decisions to make to get there. Your suggestions are 
>> welcome.
>>
>> How can you help?
>> ===
>> 1) test it.
>> 2) there are many existing client side tools for Collection+JSON. Try 
>> them with web2py.
>> 3) blog about it and suggest improvements.
>>
>>
>> I said, it is experimental
>> ===
>>
>> Collection+JSON has limits:
>> - it is very verbose JSON. This is my my implementation has  compact=True 
>> option that breaks the protocol but makes much smaller JSON messages.
>> - it does not convey field type information and constraints. This is why 
>> I extended to do so but more work is needed because DAL types do not map 
>> into HTML5 input types (this of list:string or list:reference).
>>
>> More extensions of the protocol are required. Extensions are allowed. Yet 
>> they may change the API in th

[web2py] Re: Debug Web2py with Wing IDE

2014-06-26 Thread Massimo Di Pierro
None of them web2py loads and exec's modes and controller codes at every 
request. Not sure that qualifies as "code realoding".
We do not do what Django does because that only works when you use the 
built-in web server and not in production with, for example, nginx.

Massimo

On Wednesday, 25 June 2014 13:16:40 UTC-5, Omri Levy wrote:
>
> Hi ,
>
> I asked Wing support the following question:
>
>  I am using Web2py framework. I saw a video that says the Wing can
>> debug a running python code no matter if it launched it itself. When
>> reading this: http://wingware.com/doc/howtos/web2py
>> I see that I can only debug Web2py in a way that I need to rerun the
>> server from Wing for each time I hit 'Debug'. Is there any better way to
>> do it?
>>
>
> *They replied:*
> *This is our recommended approach because of the difficulties reloading 
> code in Python.  Does web2py have code reloading?  It's been some time 
> since I worked with it.  Or does it have a master process that spawns a new 
> sub process when things change?  django and some other frameworks work this 
> way.*
>
> Do someone know what is the answer to these two questions?
>
> 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: Inserting to database after submit

2014-06-26 Thread Massimo Di Pierro
Did you do form = SQLFORM(...).process()?

On Thursday, 26 June 2014 11:12:29 UTC-5, haj...@byteplus.com.ng wrote:
>
>
> Hello,
>
> I am new to web2py. I am running this application , my form was produced 
> using SQLFORM. I noticed after i click submit the data don't get inserted 
> into the database. However if go through the admin and do new record my 
> database get updated. I dont know if I will have to do commit or something 
> to insert the record. Pls I will appreciate your help.
>
> 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: SQLFORM cannot save to database

2014-06-26 Thread Massimo Di Pierro
this:

   FORM.accepts(form, request.vars):

should be

   SQLFORM.accepts(form,request.post_vars, session)

or better

   form.accepts(request.post_vars, session)

or eve better

   form.process()


On Thursday, 26 June 2014 18:24:27 UTC-5, haj...@byteplus.com.ng wrote:
>
>
> Pls can someone help here. Am new to web2py. I produce a form using 
> SQLFORM with a submit button. After filling the form and clicking submit, i 
> discoverd the values in the form are not saved into the database. I login 
> using the appadmin, i could create and insert into the database. I will 
> like to know what am doin wrong.
>
> my code snippet:
>
> @auth.requires_login()
> def add_subject():
> form = SQLFORM(db.subject_result, ignore_rw=True)
> 
> if FORM.accepts(form, request.vars):
>
> #session.form_vars = request.vars
> response.flash = 'Subject Saved'
> #db.commit() if i comment this out the same thing happen.
>   
>  
> elif form.errors:
> response.flash = 'form has errors'
> else:
> response.flash = 'fill the form'
> 
> 
> records = db().select(db.subject_result.ALL)
> 
> return dict(form=form, records=records)
>

-- 
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: Unclear how to create a unique multiple fields on web2py

2014-06-26 Thread Massimo Di Pierro
I would not do it that way. There are two places to enforce uniqueness: at 
the database level and at the form level.

To enforce is at the database level you can manually do 

create table sometable (
a_field varchar(10),
b_field timestamp default date(now()),
unique(a_field, b_field)
);

and in web2py:

db.define_table('sometable',
Field('a_field', 'string', length=10),
Field('b_field','datetime', default=request.now),
migrate=False
)

so web2py will take the table as in database. This still will not enforce 
uniqueness in forms.

To enforce uniqueness in forms, the problem is, you need to specify how is 
the error to be reported. Let's say you want the b field to report the 
error. You can do this in the action, before SQLFORM...

def index():
 if request.post_vars.b_field:
 db.sometable.b_field.requires = 
IS_NOT_IN_DB(db(db.sometable.a_field==request.post_vars.a_field),'b_field')
 form = SQLFORM(db.sometable).process()
 





On Thursday, 26 June 2014 12:32:17 UTC-5, Daniel Lafrance wrote:
>
> Hi gang
>
> I am quite new to web2py and i am confronted to the following lack of my 
> own knowledge.
>
> In other DB engine one can write :
>
> create table sometable (
> a_field varchar(10),
> b_field timestamp default date(now()),
> unique(a_field, b_field)
> );
>
> wich I have reproduce in web2py using the following syntax:
>
> # coding: utf8
> db.define_table('sometable',
> Field('a_field', 'string', length=10),
> Field('b_field','datetime', default=request.now),
> Field('unique_fields','text',compute=lambda s: 
> str(s.a_field) + str(s.b_field), unique=True)
> )
> db.sometable.requires = IS_NOT_IN_DB(db, 'sometable.unique_fields')
>
> Written as is it works and I get a ticket when I try to create duplicate.
>
> My question is : 
>
> In some posts it is being said not to put the "unique=True" for the unique 
> field.
> I have tried it, (after deleting all databases files created by web2py) 
> and the IS_NOT_IN_DB clause does not seem to work.
>
> Any idea of what I am doing wrong ?
>
> Regard's
>
> Daniel L
> 
>
>

-- 
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 scheduler period and repeats result not expected

2014-06-26 Thread Niphlod


On Thursday, June 26, 2014 11:17:21 PM UTC+2, 黄祥 wrote:
>
> yes, followed your step, i understood the logic flow of the web2py 
> scheduler and made it work, thank you so much, simone for the pointers. 
> just wondering, the precision for second is not exact on created_on, tested 
> using period = 5 and period = 60
>
>
it'll never be. Scheduler is not precise to the second. When you queue a 
task, you specify a start_time that doesn't mean "launch the task at this 
time" but "from this time, you CAN launch this task".  

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