[web2py] insert multiple records to a new db.table from an existing table

2016-03-10 Thread Yibing Liu
Hello everyone, I have an existing table named db.news. I want to insert 
multiple rows which are selected from the existing db.news to another 
table. My code is like following:
news=db(db.news.id>=0).select(orderby=~db.news.release_time)[0:15]
db.news_temp.truncate()
db.news_temp.insert(news)
This raise an error and I can't find any other solution but looping the 
db.news.insert(somefileds=news.field). Could someone give some help?

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


[web2py] Re: how to call LOAD from one controller to access other with pagination as an example

2016-03-10 Thread Anthony
On Wednesday, March 9, 2016 at 11:32:46 PM UTC-5, Ron Chatterjee wrote:
>
> Later, I see. So, if I have to call a function within a function I need to 
> define the other one in the model.
>

No, that's not the case. You said you need to use the function in multiple 
controllers, so you cannot therefore define it in just a single controller, 
or otherwise no other controllers will be able to access it. Instead, you 
can define it in a model file or in a module (and import it where needed).

You certainly can define a function within a controller and have other 
functions in that controller call it. However, note that any function in a 
controller can also be reached via URL unless its name begins with a double 
underscore or it takes at least one argument).

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: insert multiple records to a new db.table from an existing table

2016-03-10 Thread Anthony
for row in news:
db.news_temp.insert(**db.news_temp._filter_fields(row))

Anthony

On Thursday, March 10, 2016 at 5:37:36 AM UTC-5, Yibing Liu wrote:
>
> Hello everyone, I have an existing table named db.news. I want to insert 
> multiple rows which are selected from the existing db.news to another 
> table. My code is like following:
> news=db(db.news.id>=0).select(orderby=~db.news.release_time)[0:15]
> db.news_temp.truncate()
> db.news_temp.insert(news)
> This raise an error and I can't find any other solution but looping the 
> db.news.insert(somefileds=news.field). Could someone give some help?
>
>

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


[web2py] Re: Scheduler mysql error

2016-03-10 Thread Alfonso Serra
Ive tried on a paid account and it works even with that error.

It might be the amount of processes limitation on free accounts.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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 call LOAD from one controller to access other with pagination as an example

2016-03-10 Thread Ron Chatterjee
I was going to call the pagination from multiple controller. I have about 
10 of them use pagination and tired of keep typing up the same over and 
over again and clutter the page. Okay...so, these what I understood so far:

(1) I can make a call to pagination from multiple controller inside 
default.py if I have pagination function defined in model. 
(2) I can make a call to pagination from multiple controller inside 
default.py if I have pagination function defined in module but in that case 
I have to import it. from  import 
(3) I can make a call to pagination from multiple controller inside 
default.py if I have pagination function defined in controller (default.py) 
but in that case I have to use URL redirect. And in URL redirect I can pass 
arguments. 

Have I got 1, 2 and 3 right?

Questions. If I use URL redirect, I can pass an input argument (I call 
input parameter) to pagination function, but how I get the output (or the 
return values). An example will be great. I thought LOAD is same like URL 
redirect. So, in that case I can also use LOAD as well. Right?

Thank you in advance.


On Thursday, March 10, 2016 at 8:19:27 AM UTC-5, Anthony wrote:
>
> On Wednesday, March 9, 2016 at 11:32:46 PM UTC-5, Ron Chatterjee wrote:
>>
>> Later, I see. So, if I have to call a function within a function I need 
>> to define the other one in the model.
>>
>
> No, that's not the case. You said you need to use the function in multiple 
> controllers, so you cannot therefore define it in just a single controller, 
> or otherwise no other controllers will be able to access it. Instead, you 
> can define it in a model file or in a module (and import it where needed).
>
> You certainly can define a function within a controller and have other 
> functions in that controller call it. However, note that any function in a 
> controller can also be reached via URL unless its name begins with a double 
> underscore or it takes at least one argument).
>
> 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] set difference using db

2016-03-10 Thread Paul Green
Does anyone know if there is a way to perform set difference (ie the
elements in set A that are not in set B) using database queries / DAL?

for example if you had some tables defined like this:

db.define_table('thing',
   Field('name'))

db.define_table('owns',
   Field('person', 'reference auth_user'),
   Field('thing', 'reference thing'))


and you want to find a list of all the things that person X doesn't yet own.

The "easy" way would be to query for a set of all the "thing"s and then do
a separate query for all the "thing"s owned by person X, create python set
objects and use the set difference operator.


I'm wondering if there is a way to do this as a single db query?

Thanks!

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.


Re: Mensaje privado sobre: [web2py] Bunch/Batch/Bulk insert Re-use db.define_table field definition in SQLFORM.factory() ?

2016-03-10 Thread Richard Vézina
The basic concept of what you need is presented here :
https://groups.google.com/d/msg/web2py/oiyOIC0IH04/6-NvVOJECU8J

You just have to adapt it... Add more field and change field/table names,
etc.

But it does basically what you need...

Richard

On Wed, Mar 9, 2016 at 5:04 PM, Yoel Baez  wrote:

> Thanks dude,
> Yoel
>
> 2016-03-09 18:01 GMT-04:00 Richard Vézina :
>
>> I think I had publish something in the past that address your
>> requirement...
>>
>> search for inline form or something... I don't have time to search now...
>>
>> Can have a look tomorrow what can I share...
>>
>> On Wed, Mar 9, 2016 at 11:22 AM, Yoel Baez  wrote:
>>
>>> Hey Richard,
>>>
>>> I need to do something like this...
>>> can you help me with a sample code, please?
>>>
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Regards,
>>> Yoel
>>>
>>>
>>>
>>> El viernes, 15 de marzo de 2013, 21:58:36 (UTC-4), Richard escribió:

 Yop!

 I am almost finish, I will publish the code I come up with when it good
 enough...

 :)

 Richard


 On Fri, Mar 15, 2013 at 8:24 PM, 黄祥  wrote:

> nice solution, with this can solve the problem to add the multiple
> data simultanously within one form.
>
>
> On Friday, March 15, 2013 2:07:11 AM UTC+7, Anthony wrote:
>>
>> How about:
>>
>> for i in range(0,10):
>> inputs.append(db.table1.field1.clone(name='%s_%s' % (db.table1.
>> field1.name, i)))
>>
>> The .clone() method copies the field, but you can pass in arguments
>> to replace some of the existing attributes (such as the name). I don't
>> think this is documented, though.
>>
>> Anthony
>>
>> On Thursday, March 14, 2013 8:42:21 AM UTC-4, Richard wrote:
>>>
>>> Hello Anthony,
>>>
>>> I know that, I just forget to take it in consideration in my example
>>> I guess...
>>>
>>> What I want to do is to create a batch insert form for a table a
>>> kind of inline edition but for insert data into database... So I would 
>>> have
>>> many rows in a html table that will contains the fields a given table 
>>> and
>>> only one submit button.
>>>
>>> I can build my form like this :
>>>
>>> inputs = []
>>> for i in range(0,10):
>>>inputs.append(Field('field1'+'_%s' %str(i), 'type...', ...))
>>>inputs.append(Field('field2'+'_%s' %str(i), 'type...', ...))
>>>
>>> form = SQLFORM.factory(*inputs)
>>>
>>> That way I get unique distinct inputs fields.
>>>
>>> Then with custom form I can esealy build html table in view...
>>>
>>> But what I would like to avoid is to have 2 instances for field
>>> definition : one in model and one in the batch insert function because 
>>> it
>>> seems to me that I can't get the field definition propertieds from 
>>> model...
>>>
>>> I would like to know if I could get field properties from model
>>> something like that :
>>>
>>> inputs = []
>>> for i in range(0,10):
>>> inputs.append(Field(db.table1.field1.name+'_%s' %str(i),
>>> db.table1.field1.type, ...)
>>> ...
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>>
>>> On Wed, Mar 13, 2013 at 6:28 PM, Anthony  wrote:
>>>
 SQLFORM.factory creates a dummy DAL Table object with the fields
 submitted, so you cannot use duplicate field names, as they are 
 illegal in
 DAL tables. Note, technically your form can have input elements with 
 the
 same name, but once the values are submitted to the server, the values 
 will
 be joined together in a single list. For example, if you have three 
 fields
 with the name "field1", request.vars.post_vars will be a list like 
 [value1,
 value2, value3].

 What are you really trying to do?

 Anthony


 On Wednesday, March 13, 2013 3:31:19 PM UTC-4, Richard wrote:

> Hello,
>
> I would like to build a bunch insert form and I wouldn't have to
> duplicate fields definition for SQLFORM.factory
>
> I try naively
>
> inputs = []
> for i in range(0,10):
>inputs.append(db.table1.field1)
>inputs.append(db.table1.field2)
>
> form = SQLFORM.factory(*inputs)
>
> But even if I get 10 inputs of each in "inputs" they all refer to
> the same instance so when I render the form with SQLFORM.factory, I 
> only
> get my 2 fields, but I would have 10 of each...
>
> Is there a way to avoid doing this :
>
> inputs = []
> for i in range(0,10):
>inputs.append(Field('fiel

[web2py] Re: Scheduler mysql error

2016-03-10 Thread Niphlod
given that scheduler auto imports definition, it doesn't know that you are 
using a custom adapter.

On Thursday, March 10, 2016 at 3:02:54 PM UTC+1, Alfonso Serra wrote:
>
> Ive tried on a paid account and it works even with that error.
>
> It might be the amount of processes limitation on free accounts.
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: set difference using db

2016-03-10 Thread Jim S
Maybe something like this?  (not tested)

already_owns = db(db.owns.person == person_id)._select(db.owns.thing)

things_not_owned = db(~db.thing.id.belongs(already_owns)).select()


-Jim

On Thursday, March 10, 2016 at 8:49:32 AM UTC-6, Paul wrote:
>
> Does anyone know if there is a way to perform set difference (ie the 
> elements in set A that are not in set B) using database queries / DAL?
>
> for example if you had some tables defined like this:
>
> db.define_table('thing',
>Field('name'))
>
> db.define_table('owns',
>Field('person', 'reference auth_user'),
>Field('thing', 'reference thing'))
>
>
> and you want to find a list of all the things that person X doesn't yet 
> own.
>
> The "easy" way would be to query for a set of all the "thing"s and then do 
> a separate query for all the "thing"s owned by person X, create python set 
> objects and use the set difference operator. 
>
>
> I'm wondering if there is a way to do this as a single db query? 
>
> Thanks!
>
> 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: unable to see sqlite tables created through console using python console using gluon

2016-03-10 Thread Niphlod
IMHO you should read the manual. no rabbit holes included.

On Thursday, March 10, 2016 at 1:11:12 AM UTC+1, Shayn Raney wrote:
>
> This is some rabbit hole,  looks like I need to do the following for some 
> odd reason.  
>
> db = DAL('sqlite://TestDB.sqlite', migrate_enabled=False)
>
>
>
> On Wednesday, March 9, 2016 at 3:06:45 PM UTC-8, Shayn Raney wrote:
>>
>> So I take it I need to redescribe the DB again using define_table()?  Ok, 
>> it works!  So strange.  I'm use to web.py SQL actions. 
>>
>> db.tables
>> []
>> db.define_table('person',
>>
>>  Field('fname', 'string'),
>>  Field('lname', 'string'),
>>  Field('building', 'string')
>>  )
>> 
>> rows = db(db.person.lname == 'Thorns').select()
>> rows
>> 
>> for e in rows:
>>   print e
>>
>>
>>  
>> 
>> 
>>
>>
>>
>> Thanks for the help. 
>>
>> On Wednesday, March 9, 2016 at 2:59:11 PM UTC-8, Niphlod wrote:
>>>
>>> DAL is a database abstraction layer. you need to define tables EVERY 
>>> time you need to access them. 
>>> define_table() accidentally creates table if migrations are turned on, 
>>> but define_table() doesn't map to "create a table"  it stands for 
>>> "define an entity that is mapped to a table".
>>>
>>> tl;dr: if you kill the process and reinitiate the DAL connection, DAL 
>>> doesn't do introspection on the tables present on the database. it'll 
>>> interact only with tables which have been previously defined.
>>>
>>> see 
>>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer
>>>  
>>> for all the gory details
>>>
>>>


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: set difference using db

2016-03-10 Thread Paul
works!

Thanks Jim!

On Thursday, March 10, 2016 at 9:55:33 AM UTC-5, Jim S wrote:
>
> Maybe something like this?  (not tested)
>
> already_owns = db(db.owns.person == person_id)._select(db.owns.thing)
>
> things_not_owned = db(~db.thing.id.belongs(already_owns)).select()
>
>
> -Jim
>
> On Thursday, March 10, 2016 at 8:49:32 AM UTC-6, Paul wrote:
>>
>> Does anyone know if there is a way to perform set difference (ie the 
>> elements in set A that are not in set B) using database queries / DAL?
>>
>> for example if you had some tables defined like this:
>>
>> db.define_table('thing',
>>Field('name'))
>>
>> db.define_table('owns',
>>Field('person', 'reference auth_user'),
>>Field('thing', 'reference thing'))
>>
>>
>> and you want to find a list of all the things that person X doesn't yet 
>> own.
>>
>> The "easy" way would be to query for a set of all the "thing"s and then 
>> do a separate query for all the "thing"s owned by person X, create python 
>> set objects and use the set difference operator. 
>>
>>
>> I'm wondering if there is a way to do this as a single db query? 
>>
>> Thanks!
>>
>> 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.


Re: [web2py] bug in IS_NOT_EMPTY() ?

2016-03-10 Thread Richard Vézina
It turns out that the issue wasn't even related to IS_NOT_EMPTY()... Since
the field wasn't include it couldn't block the form to submit... Though I
may have the issue in other form where it is included..

What was the root cause of my issue was in fact (as far as I can
understand) that the id field of the record wasn't include in custom form
which prevent form.process() to process correctly the form...

Could it be cause of _enable_record_versioning() that I active over
auth_user table somewhat recently... Issue run out without me noticing it...

I am glad that I finally resolve this one...

Richard

On Wed, Mar 9, 2016 at 1:58 PM, Richard Vézina 
wrote:

> Damn it, there is surely something else wrong also... Even with the
> removal I seems to have difficulty with other fields not included in the
> custom form which are removed with readable and writable False...
>
> I start to be clue less about the root cause of this issue... This form
> has worked properly for year now and it seems now completly broken...
>
> Richard
>
> On Wed, Mar 9, 2016 at 12:19 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Hello Anthony,
>>
>> Last suggestion seems the way to go... I do understand and I realise by
>> trying to hack IS_NOT_EMPTY() that it makes no sens to refactoring it in
>> anyway to make it support bool null since it never going to allow null
>> value to be input in the DB. Though it certainly shouldn't prevent a form
>> to submit properly when used with a bool type field. I may have use it by
>> mistake with bool field... But I think, base on this post which is not mine
>> in the first place, that I am not alone thinking that it usage in
>> conjonction of a bool type field will prevent the form to allow null bool
>> type field input (which is wrong thought since html checkbox can't return
>> null value)...
>>
>> So, you idea if apply, is a really good way to fix the situation...
>>
>>
>> *How I come here:*
>> I have hunted so much the reason for a bug that I had with a custom form
>> which only appears recently which I am still not sure why... Stange enough
>> even if the form wasn't submit and the system was throwing ticket, computed
>> _thumbnail_ files from compute upload fields related to an main upload
>> field of user profile picture were deleted. The form was returning error,
>> but the field wasn't include in the form so error can't be seen on form
>> submission. I guess what was really happen was that the insert process was
>> falling kind of too late and the _before_update callback was already
>> triggered... False positive ticket related to the actual issue :
>> https://github.com/web2py/pydal/issues/330
>>
>> So thumbnails get delete and then the insert fails...
>>
>> For now I think that as a workaround I can just remove the IS_NOT_EMPTY()
>> from field definition that was causing the issue.
>>
>> Thanks for your help Anthony
>>
>> Richard
>>
>> On Tue, Mar 8, 2016 at 4:41 PM, Anthony  wrote:
>>
>>> On Tuesday, March 8, 2016 at 3:01:48 PM UTC-5, Richard wrote:

 For instance how someone can acheive the same than NullBooleanField of
 Django :


 https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.NullBooleanField
 

>>>
>>> In web2py, a regular boolean field allows NULLs, so I don't think we
>>> need a special field type. In Django, the NullBooleanField is intended to
>>> be used with the NullBooleanSelect widget, which actually includes three
>>> options (with "uknown" being equivalent to a NULL). I suppose in web2py,
>>> you could achieve this with a standard select widget (with a None option),
>>> and then use an IS_IN_SET or IS_NOT_EMPTY validator.
>>>
>>>
 One part of the problem with IS_NOT_EMPTY() is that it seems to be
 intent to work only with string field type, from the book :

>>>
>>> It does work with other types of values, but there isn't much point to
>>> it when working with boolean form fields, as they cannot be empty by
>>> definition (though I suppose the distinction could be made when using the
>>> .validate_and_insert method).
>>>
>>>
 Or we can just fix IS_NOT_EMPTY() so it works with boolean type field
 so that it returns false when the checkbox is leave blank as it should...

>>>
>>> There's nothing to fix with IS_NOT_EMPTY() -- it doesn't know what type
>>> of field produces the value it is passed, so it cannot behave differently
>>> depending on the type of field. We could instead change the behavior of
>>> SQLFORM so it automatically converts empty checkboxes to False values,
>>> which would then pass validation with IS_NOT_EMPTY.
>>>
>>> Anthony
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)

[web2py] web2py pygal graph

2016-03-10 Thread kecajkecaj123
Hi Guys, 

Trying to draw some graphs using pygal and below link:
http://www.web2pyslices.com/slice/show/1634/beauty-graphics-and-charts-with-pygal

It works fine, but my view display only graph, without anything else 
included in the view e.g. headers, styling etc.

Controller:

def graph():
response.view = 'default/graph.html'
response.headers['Content-Type']='image/svg+xml'
dateline = pygal.DateLine(x_label_rotation=25)
dateline.x_labels = [
datetime.date(2013, 1, 1),
datetime.date(2013, 7, 1),
datetime.date(2014, 1, 1),
datetime.date(2014, 7, 1),
datetime.date(2015, 1, 1),
datetime.date(2015, 7, 1)
]


dateline.add("Serie", [
(datetime.date(2013, 1, 2), 213),
(datetime.date(2013, 8, 2), 281),
(datetime.date(2014, 12, 7), 198),
(datetime.date(2015, 3, 21), 120)
])

return dateline.render()


view:

{{extend 'layout.html'}}


MY FIRST GRAPH


http://localhost/project/default/graph.svg"; type="image/svg+xml" 
/>


How can i disply my original view containing styles from layout.html, 
header "MY FIRST GRAPH" and the graph itself? 

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: unable to see sqlite tables created through console using python console using gluon

2016-03-10 Thread Anthony
On Wednesday, March 9, 2016 at 6:06:45 PM UTC-5, Shayn Raney wrote:
>
> So I take it I need to redescribe the DB again using define_table()?  Ok, 
> it works!  So strange.  I'm use to web.py SQL actions. 
>

The DAL models let you do a lot more via Python than you can do with 
web.py, which is not far removed from just writing raw SQL. If you want, in 
web2py you can simply use db.executesql(...) to execute any SQL you want 
without defining any models. Also, you can do:

db = DAL('sqlite://TestDB.sqlite', auto_import=True)

and it will automatically create model definitions based on the migration 
metadata (the definitions will be missing some web2py-only attributes that 
don't relate to the database itself, such as validators, labels, etc.).

Finally, if you need to work in a shell with the database/models of a 
particular web2py app, rather than starting a standard Python shell, you 
should instead do:

python web2py.py -S myapp -M

You'll then get a shell with the entire web2py environment, including any 
objects defined in your models -- so you would have access to the db object 
with all of its models defined.

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: unable to see sqlite tables created through console using python console using gluon

2016-03-10 Thread Anthony
On Wednesday, March 9, 2016 at 7:11:12 PM UTC-5, Shayn Raney wrote:
>
> This is some rabbit hole,  looks like I need to do the following for some 
> odd reason.  
>
> db = DAL('sqlite://TestDB.sqlite', migrate_enabled=False)
>
>
No, you shouldn't need to do that (unless you want to protect against 
accidental changes).

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: Fields from multiple tables in a single form

2016-03-10 Thread David Orme
Thanks for the help. I'm still working on this - I will come back with some 
code to show what worked for me - but just wanted to correct another typo 
in my code.

The correct syntax for referencing other tables is not:

Field('project_id', 'references projects')

but:

Field('project_id', 'reference projects')

That extra 's' causes all sorts of confusion. I got error messages next to 
my SQLFORM.grid saying "Query Not Supported: 'references'" and it took a 
while to spot what was going 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] Using writable=False fields in an onupdate function

2016-03-10 Thread David Orme
Hello,

I'm trying to use a variable from a form in an onupdate function, but 
because I've set it to writeable=False in the controller, it doesn't get 
passed in form.vars. In more depth:

I've got a table for volunteers to post offers of help on a project. Those 
have to be approved by an admin before becoming visible, but I don't want 
the admin to be able to change the original data. So, I have this as my 
table:

db.define_table('help_offered',
Field('volunteer_id', 'reference auth_user'),
Field('volunteer_type', requires=IS_IN_SET(volunteer_type), notnull=True
),
Field('available_from','date', notnull=True),
Field('admin_status','string', requires=IS_IN_SET(['Pending', 'Approved'
,'Rejected']),
Field('approval_notes','text'),

For users, I just have a SQLFORM, which just doesn't show the two admin 
fields (admin_status and approval_notes):

def volunteer():

form = SQLFORM(db.help_offered,
   fields =['volunteer_type', 'research_statement', 
'available_from'])

Now for admin users, I want a table of pending offer, where they can view 
records but only edit those two admin fields. So, SQLFORM.grid fits 
perfectly:

def administer_volunteers():

# lock down which fields can be changed
db.help_offered.volunteer_id.writable = False
db.help_offered.volunteer_type.writable = False
db.help_offered.available_from.writable = False

# get a query of pending requests with user_id
form = SQLFORM.grid(query=(db.help_offered.admin_status == 'Pending'), 
csv=False,
fields=[db.help_offered.volunteer_id,
db.help_offered.volunteer_type,
db.help_offered.available_from],
 deletable=False, editable=True, create=False, 
details=False,
 onupdate = update_administer_volunteers)

However, now I want to email the volunteers the decision, so onupdate does 
this:

def update_administer_volunteers(form):

# Email the decision to the proposer
row = db(db.auth_user.id == form.vars.volunteer_id).select().first()
volunteer_email = row.email
volunteer_fn = row.first_name

# alternatives
if form.vars.admin_status == 'Approved':
mail.send(to=volunteer_email,
  subject='Decision',
  message='Approved'
elif form.vars.admin_status == 'Rejected':
mail.send(to=volunteer_email,
  subject='Decision',
  message='Rejected')
else:
pass

But, form.vars only contains the writable fields and the row id:

admin_status : Approved
approval_decision_date : 2016-03-10
approval_notes : Sounds good
approver_id : 1L
id : 3L

I've seen solutions using hidden but I don't want to hide the field, just 
make it read only, and I can't work out how to insert volunteer_id back 
into my form. I could look up id in help_offered and then get the 
volunteer_id that way but that seems like an unnecessary extra step!

A long post for a simple question!


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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 call LOAD from one controller to access other with pagination as an example

2016-03-10 Thread Anthony
On Thursday, March 10, 2016 at 9:35:08 AM UTC-5, Ron Chatterjee wrote:
>
> I was going to call the pagination from multiple controller. I have about 
> 10 of them use pagination and tired of keep typing up the same over and 
> over again and clutter the page. Okay...so, these what I understood so far:
>
> (1) I can make a call to pagination from multiple controller inside 
> default.py if I have pagination function defined in model. 
>

To be clear, in web2py a "controller" is a .py file in the /controllers 
folder, and it may contain multiple *actions* (actions are functions in the 
controller). When you say "multiple controller inside default.py," 
presumably you mean multiple actions in the default.py controller.

In any case, if you only need the pagination function for actions within 
the default.py controller, then you may define the function there, as it is 
only needed in that one controller. However, as noted, if you define a 
helper function in a controller that is not intended to be an action 
accessible via URL, you must precede its name with a double underscore or 
otherwise make sure it accepts at least one argument.
 

> (3) I can make a call to pagination from multiple controller inside 
> default.py if I have pagination function defined in controller (default.py) 
> but in that case I have to use URL redirect. And in URL redirect I can pass 
> arguments.
>

No. First, as noted above, you can define pagination inside default.py and 
call it from within there. Also, you are confusing the calling a Python 
function with making an HTTP request to a URL (which ultimately results in 
a function being executed). In this case, you do not want to do a redirect 
(which tells the browser to make an HTTP request to an alternative URL) nor 
use LOAD (which generates an Ajax component that makes an Ajax request to a 
particular URL). Rather, you simply want to create and call a standard 
Python function that accepts some inputs and generates some outputs that 
you can then use for pagination purposes.
 
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: how to call LOAD from one controller to access other with pagination as an example

2016-03-10 Thread Ron Chatterjee
Thanks. 

On Thursday, March 10, 2016 at 2:13:21 PM UTC-5, Anthony wrote:
>
> On Thursday, March 10, 2016 at 9:35:08 AM UTC-5, Ron Chatterjee wrote:
>>
>> I was going to call the pagination from multiple controller. I have about 
>> 10 of them use pagination and tired of keep typing up the same over and 
>> over again and clutter the page. Okay...so, these what I understood so far:
>>
>> (1) I can make a call to pagination from multiple controller inside 
>> default.py if I have pagination function defined in model. 
>>
>
> To be clear, in web2py a "controller" is a .py file in the /controllers 
> folder, and it may contain multiple *actions* (actions are functions in 
> the controller). When you say "multiple controller inside default.py," 
> presumably you mean multiple actions in the default.py controller.
>
> In any case, if you only need the pagination function for actions within 
> the default.py controller, then you may define the function there, as it is 
> only needed in that one controller. However, as noted, if you define a 
> helper function in a controller that is not intended to be an action 
> accessible via URL, you must precede its name with a double underscore or 
> otherwise make sure it accepts at least one argument.
>  
>
>> (3) I can make a call to pagination from multiple controller inside 
>> default.py if I have pagination function defined in controller (default.py) 
>> but in that case I have to use URL redirect. And in URL redirect I can pass 
>> arguments.
>>
>
> No. First, as noted above, you can define pagination inside default.py and 
> call it from within there. Also, you are confusing calling a Python 
> function with making an HTTP request to a URL (which ultimately results in 
> a function being executed). In this case, you do not want to do a redirect 
> (which tells the browser to make an HTTP request to an alternative URL) nor 
> use LOAD (which generates an Ajax component that makes an Ajax request to a 
> particular URL). Rather, you simply want to create and call a standard 
> Python function that accepts some inputs and generates some outputs that 
> you can then use for pagination purposes.
>  
> 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] Using writable=False fields in an onupdate function

2016-03-10 Thread Richard Vézina
You can't get it in you onupdate function?

You already retrieve auth_user row, so I guess instead of use form.vars
instance for this piece of information...

Though I am not sure what is exactly you problem...

Richard

On Thu, Mar 10, 2016 at 1:34 PM, David Orme  wrote:

> Hello,
>
> I'm trying to use a variable from a form in an onupdate function, but
> because I've set it to writeable=False in the controller, it doesn't get
> passed in form.vars. In more depth:
>
> I've got a table for volunteers to post offers of help on a project. Those
> have to be approved by an admin before becoming visible, but I don't want
> the admin to be able to change the original data. So, I have this as my
> table:
>
> db.define_table('help_offered',
> Field('volunteer_id', 'reference auth_user'),
> Field('volunteer_type', requires=IS_IN_SET(volunteer_type), notnull=
> True),
> Field('available_from','date', notnull=True),
> Field('admin_status','string', requires=IS_IN_SET(['Pending',
> 'Approved','Rejected']),
> Field('approval_notes','text'),
>
> For users, I just have a SQLFORM, which just doesn't show the two admin
> fields (admin_status and approval_notes):
>
> def volunteer():
>
> form = SQLFORM(db.help_offered,
>fields =['volunteer_type', 'research_statement',
> 'available_from'])
>
> Now for admin users, I want a table of pending offer, where they can view
> records but only edit those two admin fields. So, SQLFORM.grid fits
> perfectly:
>
> def administer_volunteers():
>
> # lock down which fields can be changed
> db.help_offered.volunteer_id.writable = False
> db.help_offered.volunteer_type.writable = False
> db.help_offered.available_from.writable = False
>
> # get a query of pending requests with user_id
> form = SQLFORM.grid(query=(db.help_offered.admin_status == 'Pending'),
> csv=False,
> fields=[db.help_offered.volunteer_id,
> db.help_offered.volunteer_type,
> db.help_offered.available_from],
>  deletable=False, editable=True, create=False,
> details=False,
>  onupdate = update_administer_volunteers)
>
> However, now I want to email the volunteers the decision, so onupdate does
> this:
>
> def update_administer_volunteers(form):
>
> # Email the decision to the proposer
> row = db(db.auth_user.id == form.vars.volunteer_id).select().first()
> volunteer_email = row.email
> volunteer_fn = row.first_name
>
> # alternatives
> if form.vars.admin_status == 'Approved':
> mail.send(to=volunteer_email,
>   subject='Decision',
>   message='Approved'
> elif form.vars.admin_status == 'Rejected':
> mail.send(to=volunteer_email,
>   subject='Decision',
>   message='Rejected')
> else:
> pass
>
> But, form.vars only contains the writable fields and the row id:
>
> admin_status : Approved
> approval_decision_date : 2016-03-10
> approval_notes : Sounds good
> approver_id : 1L
> id : 3L
>
> I've seen solutions using hidden but I don't want to hide the field, just
> make it read only, and I can't work out how to insert volunteer_id back
> into my form. I could look up id in help_offered and then get the
> volunteer_id that way but that seems like an unnecessary extra step!
>
> A long post for a simple question!
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are 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] Using writable=False fields in an onupdate function

2016-03-10 Thread Richard Vézina
Not complete my sentence :

You already retrieve auth_user row, so I guess instead of use form.vars
instance for this piece of information you can get it from auth_user row...


On Thu, Mar 10, 2016 at 2:41 PM, Richard Vézina  wrote:

> You can't get it in you onupdate function?
>
> You already retrieve auth_user row, so I guess instead of use form.vars
> instance for this piece of information...
>
> Though I am not sure what is exactly you problem...
>
> Richard
>
> On Thu, Mar 10, 2016 at 1:34 PM, David Orme  wrote:
>
>> Hello,
>>
>> I'm trying to use a variable from a form in an onupdate function, but
>> because I've set it to writeable=False in the controller, it doesn't get
>> passed in form.vars. In more depth:
>>
>> I've got a table for volunteers to post offers of help on a project.
>> Those have to be approved by an admin before becoming visible, but I don't
>> want the admin to be able to change the original data. So, I have this as
>> my table:
>>
>> db.define_table('help_offered',
>> Field('volunteer_id', 'reference auth_user'),
>> Field('volunteer_type', requires=IS_IN_SET(volunteer_type), notnull=
>> True),
>> Field('available_from','date', notnull=True),
>> Field('admin_status','string', requires=IS_IN_SET(['Pending',
>> 'Approved','Rejected']),
>> Field('approval_notes','text'),
>>
>> For users, I just have a SQLFORM, which just doesn't show the two admin
>> fields (admin_status and approval_notes):
>>
>> def volunteer():
>>
>> form = SQLFORM(db.help_offered,
>>fields =['volunteer_type', 'research_statement',
>> 'available_from'])
>>
>> Now for admin users, I want a table of pending offer, where they can view
>> records but only edit those two admin fields. So, SQLFORM.grid fits
>> perfectly:
>>
>> def administer_volunteers():
>>
>> # lock down which fields can be changed
>> db.help_offered.volunteer_id.writable = False
>> db.help_offered.volunteer_type.writable = False
>> db.help_offered.available_from.writable = False
>>
>> # get a query of pending requests with user_id
>> form = SQLFORM.grid(query=(db.help_offered.admin_status == 'Pending'
>> ), csv=False,
>> fields=[db.help_offered.volunteer_id,
>> db.help_offered.volunteer_type,
>> db.help_offered.available_from],
>>  deletable=False, editable=True, create=False,
>> details=False,
>>  onupdate = update_administer_volunteers)
>>
>> However, now I want to email the volunteers the decision, so onupdate
>> does this:
>>
>> def update_administer_volunteers(form):
>>
>> # Email the decision to the proposer
>> row = db(db.auth_user.id == form.vars.volunteer_id).select().first()
>> volunteer_email = row.email
>> volunteer_fn = row.first_name
>>
>> # alternatives
>> if form.vars.admin_status == 'Approved':
>> mail.send(to=volunteer_email,
>>   subject='Decision',
>>   message='Approved'
>> elif form.vars.admin_status == 'Rejected':
>> mail.send(to=volunteer_email,
>>   subject='Decision',
>>   message='Rejected')
>> else:
>> pass
>>
>> But, form.vars only contains the writable fields and the row id:
>>
>> admin_status : Approved
>> approval_decision_date : 2016-03-10
>> approval_notes : Sounds good
>> approver_id : 1L
>> id : 3L
>>
>> I've seen solutions using hidden but I don't want to hide the field, just
>> make it read only, and I can't work out how to insert volunteer_id back
>> into my form. I could look up id in help_offered and then get the
>> volunteer_id that way but that seems like an unnecessary extra step!
>>
>> A long post for a simple question!
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are 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: for those of us who do not understand ...

2016-03-10 Thread Massimo Di Pierro
Here is another piece:

http://mdipierro.github.io/stupid.css/widgets/index.html

The work with web2py forms if you manually add the data-format and 
data-range. For example

for e in form.elements('.datetime'): 
e['_data-format'] = '{DD}/{MM}/{year} {hh}:{mm}:{ss}'

for e in form.elements('.double'):
e.add_class('number slider');
e['_data-range']] = '0,100'

It would be great if you could help me test these.


On Tuesday, 8 March 2016 15:04:50 UTC-6, Massimo Di Pierro wrote:
>
> I would like to buy a .ham.burger 
> http://mdipierro.github.io/stupid.css/themes/hamburger.html
>
> On Thursday, 3 March 2016 01:27:57 UTC-6, Massimo Di Pierro wrote:
>>
>> A damn simple and easy css framework ... stupid.css
>>
>> https://t.co/9vB48IjYJK
>>
>> No promise of backward compatibility is made, but comments and 
>> suggestions for improvement are welcome.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: Using writable=False fields in an onupdate function

2016-03-10 Thread David Orme
That's the problem - the auth_user row _can't_ be retrieved because 
form.vars.volunteer_id is None.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: Using writable=False fields in an onupdate function

2016-03-10 Thread Dave S


On Thursday, March 10, 2016 at 12:01:47 PM UTC-8, David Orme wrote:
>
> That's the problem - the auth_user row _can't_ be retrieved because 
> form.vars.volunteer_id is None.
>

Is this one of the places you should set it in your controller before 
calling form.process()?

In regular SQLFORM, that's how (AIUI) you set a default value, and it works 
for writable=False and hidden fields (again, AIUI).

Is this post helpful?
https://groups.google.com/d/msg/web2py/HF95xbM8Hs4/MR8cM9G3FgAJ>

/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: Using writable=False fields in an onupdate function

2016-03-10 Thread Richard Vézina
Ok, your form is not over auth_user... Sorry fast reading does that...

You can use session then...

session.volunteer_id = db.table(row_id).volunteer_id

Or

You can passe it as request vars :

URL(..., vars=dict(volunteer_id=db.table(row_id).volunteer_id))

Though, I am not sure you will be able to access it in the latter case
since request.vars.volunteer_id... But I remember had retrieve request.vars
passed into form vars when the name of the vars was exactly the same which
was causing issue in some circonstances, so I avoid passing the value with
the same name.

There is also post_vars that could be use...

Richard


On Thu, Mar 10, 2016 at 3:01 PM, David Orme  wrote:

> That's the problem - the auth_user row _can't_ be retrieved because
> form.vars.volunteer_id is None.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are 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: Using writable=False fields in an onupdate function

2016-03-10 Thread Richard Vézina
If you use session be aware that the value you put in session will remain
there for the duration of the session, so you need to carefully reset them
or init them in order to not create bug...

As Dave S mention SQLFORM() wouldn't maybe suffer from this issue as you
can do that :

form = SQLFORM(...)
form.vars.volunteer_id = ...
if form.process().accept:
...

Richard

On Thu, Mar 10, 2016 at 3:35 PM, Dave S  wrote:

>
>
> On Thursday, March 10, 2016 at 12:01:47 PM UTC-8, David Orme wrote:
>>
>> That's the problem - the auth_user row _can't_ be retrieved because
>> form.vars.volunteer_id is None.
>>
>
> Is this one of the places you should set it in your controller before
> calling form.process()?
>
> In regular SQLFORM, that's how (AIUI) you set a default value, and it
> works for writable=False and hidden fields (again, AIUI).
>
> Is this post helpful?
> https://groups.google.com/d/msg/web2py/HF95xbM8Hs4/MR8cM9G3FgAJ>
>
> /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.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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] Fetching date from database table into html form

2016-03-10 Thread Snehal Ashtekar
I had done this shown below

Field('dob','date',requires = IS_DATE_IN_RANGE(format=T('%Y-%m-%d'),

 minimum=datetime.date(1980,1,1),

 maximum=datetime.date(2030,12,31),

i am getting an error as-
  ( (name 'datetime' is not 
defined) )
so where should I define the datetime in db.py file or in html 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] internet access issues

2016-03-10 Thread shoaib jan Jan
 I am once again in trouble. I have installed Sahana in dell poweredge R410 
Rake server . with public IP. Sahana EDEN  as server installation framework 
is (Web2py webserver, PostgreSQL as the database, Cherokee. I have done 
some customizations as well. Now I need to know that after 3 or 4 days it 
increase the bytes (in mbps up 50 mbps) and hang (i-e slow down) the entire 
network which file in sahana eden need to be configured so that it can be 
accessed from anywhere.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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] Advice for small database on GAE

2016-03-10 Thread Brendan
Hi

I have a web2py app on GAE at the moment that takes some of its data by 
parsing a hard coded string constant (at the moment, it has a half a dozen 
rows each with half a dozen or so columns). 
I plan to expand this to have dozens of rows and updated every couple of 
months with 3 or 4 more. I was planning on doing this with a local sqlite 
database but GAE doesn't seem to support it. 
My question is:

* if I import the db into the GAE datastore how do I update it? 

- If I have a local sqlite db then I can simply upload a new copy of the 
db. 
- Do I need to write a GAE interface to add entries (I'd rather do it 
locally). 
- Do I run a db restore from a local copy?
- if I add columns later does this cause GAE any heartache?

I am thinking that using the datastore will be overkill and I should just 
serialise the db (JSON? Configparser? yaml?) then deserialise/treat it as a 
dictionary in memory at run time.
Advice?

Thanks


Brendan

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: Fetching date from database table into html form

2016-03-10 Thread Dave S


On Thursday, March 10, 2016 at 1:07:01 PM UTC-8, Snehal Ashtekar wrote:
>
> I had done this shown below
>
> Field('dob','date',requires = IS_DATE_IN_RANGE(format=T('%Y-%m-%d'),
> 
>  minimum=datetime.date(1980,1,1),
> 
>  maximum=datetime.date(2030,12,31),
>
> i am getting an error as-
>   ( (name 'datetime' is not 
> defined) )
> so where should I define the datetime in db.py file or in html file 
>
>
You would need to have "import datetime" in your model file where the Field 
is defined.
 (That might be db.py, depending on how you set your models up.)

/dps

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


[web2py] Re: internet access issues

2016-03-10 Thread Dave S
On Thursday, March 10, 2016 at 1:07:18 PM UTC-8, shoaib jan Jan wrote:
>
>  I am once again in trouble. I have installed Sahana in dell poweredge 
> R410 Rake server . with public IP. Sahana EDEN  as server installation 
> framework 
> is (Web2py webserver, PostgreSQL as the database, Cherokee. I have done 
> some customizations as well. Now I need to know that after 3 or 4 days it 
> increase the bytes (in mbps up 50 mbps) and hang (i-e slow down) the entire 
> network which file in sahana eden need to be configured so that it can be 
> accessed from anywhere.
>

It looks like Sahana EDEN is an application suite.  To answer your 
question, we need to know more about your configuration:

1)  What operating system are is running on the Dell server?
2)  On that OS, are you setting up HTTP access with Apache, NginX, Rocket 
(such as comes with Web2Py), IIS, or something else?
3)  Are you trying to access Sahana through a Web2Py application?

As to the traffic on your local network, I'm not sure we can answer that. 
 Perhaps you need to be watching with Wireshark, tcpdump, or (for Windows) 
netsh trace and use Network Monitor 3 to read the files.

Good luck!

Dave
/dps

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


[web2py] Re: How i can do a form factory 2 tables with bulkdata

2016-03-10 Thread Val K
Hi!

   1. it is not quite clear for me, what  is the goal of client/property 
   fields? Are they search fields? 
   2. If you want user to fill/edit/del all these fields (without server 
   interaction) and submit result at once - it's impossible without having 
   some JS-coding 
   3. Your Bulkdata looks like grid, so you can use SQLFORM.grid, but it 
   requires real DB-table  and performs submission per record add/edit/del, 
   i.e. all user actions will be submitted immediately, so, special submit 
   button is useless.

But still it's possible to be realized by web2py power only! (w/o JS-coding)
What you have to do: 

   1. Create dummy table to process bulkdata add/edit/del, it should have 
   extra field "user_id" -   reference to auth_user.id (we don't want user to 
   see what another one  is doing )
   2. Create 2 controllers  - one to process main page and final 
   user submission ( now, submit-button is useful;) ), another  - to process 
   bulkdata only (returning something 
   like SQLFORM.grid(dummy_table.user_id==auth.user_id)  ).
   3. Embed bulkdata_controller to main_page_controller using smth like 
   =LOAD('bulkdata_controller', ajax=True) - see the  book
   4. When user performs final submission  - do what you want to do  using 
   dummy-table data filtering by auth.user_id, then delete bulckdata records 
   (using filtering by auth.user_id of course)


There is an issue  - is it possible  dummy-table id overflow? 
To avoid this you can use 'big-id' type for  id-field and perform 
periodical (Sunday night or 31 October ) truncation all dummy-table records 
 with restart id-counter (or just recreate table)





On Wednesday, March 9, 2016 at 7:12:14 PM UTC+3, Yoel Baez wrote:
>
>
> I need to do something like this in web2py... please help me..
>
> Regards,
> Yoel
>
>
>
> 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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] Not welcome app

2016-03-10 Thread Dave S
If I want to remove the welcome app from my server, and have a bare 
hostname URLto somewhere appropriate (rather than "invalid function"), I 
should set up routes.py?

And in 2.13.4-stable, main.py L388 +/- is where the welcome app is made the 
default?

/dps

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


[web2py] Re: for those of us who do not understand ...

2016-03-10 Thread eric cuver
it's nice I am impressed

Le jeudi 10 mars 2016 20:43:03 UTC+1, Massimo Di Pierro a écrit :
>
> Here is another piece:
>
> http://mdipierro.github.io/stupid.css/widgets/index.html
>
> The work with web2py forms if you manually add the data-format and 
> data-range. For example
>
> for e in form.elements('.datetime'): 
> e['_data-format'] = '{DD}/{MM}/{year} {hh}:{mm}:{ss}'
>
> for e in form.elements('.double'):
> e.add_class('number slider');
> e['_data-range']] = '0,100'
>
> It would be great if you could help me test these.
>
>
> On Tuesday, 8 March 2016 15:04:50 UTC-6, Massimo Di Pierro wrote:
>>
>> I would like to buy a .ham.burger 
>> http://mdipierro.github.io/stupid.css/themes/hamburger.html
>>
>> On Thursday, 3 March 2016 01:27:57 UTC-6, Massimo Di Pierro wrote:
>>>
>>> A damn simple and easy css framework ... stupid.css
>>>
>>> https://t.co/9vB48IjYJK
>>>
>>> No promise of backward compatibility is made, but comments and 
>>> suggestions for improvement are welcome.
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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] Smartgrid search bar without dropdown search

2016-03-10 Thread rajjmatthur

Is there a way to show the smartgrid search bar without showing the 
dropdown search box? I find the dropdown search can be confusing. Like the 
 grid with search and clear button but want to exclude the drop down menu 
that comes in below with  =,<,>, +And, Or...etc.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: for those of us who do not understand ...

2016-03-10 Thread Leonel Câmara
Massimo you need to detect mouseleave in the number slider widget. 
Otherwise I can click with the mouse drag a little bit, then keeping the 
left mouse button pressed leave the element and, finally, let the mouse 
button go. Now if my mouse (which has no buttons pressed at this time) even 
hovers the slider it changes its value. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: for those of us who do not understand ...

2016-03-10 Thread Massimo Di Pierro
another piece: http://mdipierro.github.io/stupid.css/themes/dashboard.html


On Thursday, 10 March 2016 18:53:54 UTC-6, eric cuver wrote:
>
> it's nice I am impressed
>
> Le jeudi 10 mars 2016 20:43:03 UTC+1, Massimo Di Pierro a écrit :
>>
>> Here is another piece:
>>
>> http://mdipierro.github.io/stupid.css/widgets/index.html
>>
>> The work with web2py forms if you manually add the data-format and 
>> data-range. For example
>>
>> for e in form.elements('.datetime'): 
>> e['_data-format'] = '{DD}/{MM}/{year} {hh}:{mm}:{ss}'
>>
>> for e in form.elements('.double'):
>> e.add_class('number slider');
>> e['_data-range']] = '0,100'
>>
>> It would be great if you could help me test these.
>>
>>
>> On Tuesday, 8 March 2016 15:04:50 UTC-6, Massimo Di Pierro wrote:
>>>
>>> I would like to buy a .ham.burger 
>>> http://mdipierro.github.io/stupid.css/themes/hamburger.html
>>>
>>> On Thursday, 3 March 2016 01:27:57 UTC-6, Massimo Di Pierro wrote:

 A damn simple and easy css framework ... stupid.css

 https://t.co/9vB48IjYJK

 No promise of backward compatibility is made, but comments and 
 suggestions for improvement are welcome.

>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: Not welcome app

2016-03-10 Thread Leonel Câmara
Yes, set routes.py in your web2py folder.

A very simple routes.py for you can just be:

routers = dict(
BASE=dict(
default_application='YourApplicationName',
),
)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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: for those of us who do not understand ...

2016-03-10 Thread Dave S


On Tuesday, March 8, 2016 at 4:01:00 PM UTC-8, Dave S wrote:
>
>
>
> On Tuesday, March 8, 2016 at 1:04:50 PM UTC-8, Massimo Di Pierro wrote:
>>
>> I would like to buy a .ham.burger 
>> http://mdipierro.github.io/stupid.css/themes/hamburger.html
>>
>
> Oh, my!
>

I like the card divs you added (as seen in the stupid.css-welcome-app 
sample), but a btn-block doesn't wrap in those. That may not be a big deal, 
but I did have a chance to observe it before moving part of the text into 
the enclosing H3.

/dps

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


[web2py] Re: Not welcome app

2016-03-10 Thread Dave S


On Thursday, March 10, 2016 at 6:42:19 PM UTC-8, Leonel Câmara wrote:
>
> Yes, set routes.py in your web2py folder.
>
> A very simple routes.py for you can just be:
>
> routers = dict(
> BASE=dict(
> default_application='YourApplicationName',
> ),
> )
>
>

Thanks!

/dps
 

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


[web2py] Re: Smartgrid search bar without dropdown search

2016-03-10 Thread Leonel Câmara
Yes give it advanced_search=False as a kwarg.  
  
You can then actually make the one input text box search pretty smart if 
the default isn't good enough for you. You can set searchable to a function 
where you build a nice query from the text with your knowledge of the 
domain.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are 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] storing the values into database from html form

2016-03-10 Thread Snehal Ashtekar
how to store the data from html form into database?

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