Re: [web2py] Re: detect a specific device

2014-01-14 Thread paolo.vall...@gmail.com
hi, thanks everyone for the answers
@Willoughby I don't think the mac address is sent/received in an http
request, isn't ?
@dave your suggestion is in the right direction but how can you
automatically tells the browser to send this token?
@niphlod authentication is not enough, an user can still use his/her
credentials to log in in a different tablet, ip address would work but it
is too intrusive for an already present intranet.

Following @dave suggestion, I thought about a cookie that never expire, the
first time the tablet start the 'a setup app' stores the cookie on both the
client browser and in the server, however I'm not convinced this solution
would work either; the 'setup app' is not foresee at all. I've to verify if
there're ways to pre-install the cookie in the tablet?



 Paolo


2014/1/14 Niphlod 

> this is an architectural problem: what does the device send to your app to
> be able to identify it ?
> If it's a webapp and it is accessed via the browser, and there are no
> running bits on the device itself speaking to your webapp, then the headers
> and the env are the only thing you can rely onto (fortunately, browsers are
> fully isolated).
>
> Hello, authentication (or fixed ip address)!
>
>
> On Tuesday, January 14, 2014 8:05:17 PM UTC+1, Paolo Valleri wrote:
>
>> Hi,
>> what you posted can be a starting point but it is not enough because it
>> doesn't guarantee that a different android tablet has been purchased.
>> The requirement is, only a well defined set of tablets can access the
>> webapp.
>>
>>  Paolo
>>
>>
>> 2014/1/14 Leonel Câmara 
>>
>>>  I guess you can use something like:
>>>
>>> request.user_agent().is_tablet and request.user_agent().dist.name== 
>>> 'Android'
>>>
>>>
>>>  --
>>> 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/3Q7izsidMXM/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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/3Q7izsidMXM/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/groups/opt_out.
>

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


Re: [web2py] Re: Cookbook - No indentation ??

2014-01-14 Thread Joe Barnhart
The problem still exists, here in 2014!

It is broader than just MOBI format -- it also makes EPUB book listings (at 
least Python ones) useless.  BUT -- it only affects one publisher I have 
found so far -- Packt Publishing.

Sadly I will be crossing them off my list of suitable purveyors of ebooks 
because (a) they have known about the problem for years, and (b) they do 
not care enough to fix it.  I'm tempted to request a refund for every 
Python book I have bought from them -- about 6 or 7 so far.

It is not ok to just download the listings as I often read these books on 
long flights and it's not possible to fire up the computer and get the 
listing, or even follow along.  It really is not a substitute, and I would 
add demerits to any book author who says its acceptable.

-- Joe B.

On Saturday, March 17, 2012 11:34:56 AM UTC-7, Jonathan Lundell wrote:
>
> On Mar 17, 2012, at 11:22 AM, Marcello wrote:
>
> I screwed with nobody.
> I just pointed a fact.
>
> I have many Python eBooks(ePub) and ALL of them have NO formatting 
> or indentation problem.
> Even Kindle has no indentation problem in all of my Python books.
>
>
> True; I've got plenty of tech books, both ePub and mobi, that handle 
> indentation just fine.
>
>
>
> Marcello
>
>
>
> On Saturday, March 17, 2012 3:04:58 PM UTC-3, AngeloC wrote:
>>
>> Kindle and other ebook readers that doesn't support pdf are useless for 
>> viewing technical documents because text is reflowable, always. So blanks 
>> are removed and text is full aligned.
>>
>> Please don't screw with packtpub, amazon or others, is a common problem 
>> with all reflowable mobile formats.
>>
>> I have an ebook reader that supports all mobile formats (BeBook One) and 
>> pdf (non digital editions) is the only readable format for tech documents. 
>> I read always on my bebook one!
>>
>> Publishers never says that, because they will not sell technical ebooks 
>> anymore!
>>
>
>
>

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


[web2py] Re: Web2py Integration with Sentry

2014-01-14 Thread James Q
Massimo: Would you consider taking a patch / pull request for a new script?

-- James

On Thursday, January 9, 2014 9:16:02 AM UTC-5, Massimo Di Pierro wrote:
>
> The problem is that it would not work. you can have exceptions at two 
> levels: web2py apps, web2py itself. In other frameworks these two levels 
> are mixed up so sentry will catch either exceptions. In web2py the two 
> levels are well separated and web2py catches app exceptions before they 
> propagate up and sentry would not catch them. sentry would only catch 
> exceptions in web2py itself and that is pretty much useless. 
>
> You can think about it in another way, web2py already has a mechanism to 
> catch exceptions and log them. and you cannot do:
>
> try:
> try:
>   do something
>exceptiion: 
>   web2py ticket system
> except:
>sentry logging system
>
> and expect the second except to catch anything. Look instead into 
> scritps/tickets2db.py and scripts/tickets2email.py and modify them to do 
> what you need to do.
>
>
> On Wednesday, 8 January 2014 23:27:46 UTC-6, James Q wrote:
>>
>> Interesting. I have never written wsgi middleware, any pointers on that? 
>> As middleware, I would still need to have an understanding of how to detect 
>> if an exception has been logged in the request, no?
>>
>> Thanks!
>>
>> -- J
>>
>> On Tuesday, January 7, 2014 8:24:14 PM UTC-5, Derek wrote:
>>>
>>> I haven't, but I've done something similar with a different piece of 
>>> software. You'd usually just use it as a wsgi middleware around your app. 
>>> So you'd need to run web2py as wsgi and wrap it with Sentry.
>>>
>>> On Monday, January 6, 2014 8:14:46 PM UTC-7, James Q wrote:

 Has anyone ever integrated web2py an Sentry (
 https://github.com/getsentry/sentry)? I would like it if all web2py 
 generated exceptions generate a ticket like usual, but also generates an 
 event to a sentry server. Has anyone ever done this? If not, could anyone 
 point to where I would need to patch web2py or how best this integration 
 would work?

 Thanks for any 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/groups/opt_out.


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Anthony
As noted in the book, the _before_ callbacks must return falsey values, or 
the operation will be aborted. So, you can either write a full function 
(that returns False) instead of using a lambda, or do something like:

lambda s: db(...).update(...) and False

which will return the value False.

Anthony

On Tuesday, January 14, 2014 9:27:44 PM UTC-5, Apple Mason wrote:
>
> Yeah, that thread says to use _before_delete, and it fits this use case.
>
> Can you verify if what I'm seeing about the delete is correct? The 
> _before_delete is causing the admin panel to not delete the record for some 
> reason. Is it a bug?
>
> I'm using web2py 2.7.4 stable
>
> On Tuesday, January 14, 2014 9:20:27 PM UTC-5, 黄祥 wrote:
>>
>> for after delete callback, please check this discussion
>> https://groups.google.com/forum/#!msg/web2py/M4_5THMHzH0/r9aXH-k8eJQJ
>>
>> 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/groups/opt_out.


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Anthony
Of course, that's only if you add or delete one record at a time.

On Wednesday, January 15, 2014 12:09:11 AM UTC-5, Anthony wrote:
>
> db.thing._after_insert.append(lambda f,id: db(db.person.id
>> ==f['owner_id']).update(total_items=len(db(db.thing.owner_id==f['owner_id']).select(
>> from pprint import pprint
>> db.thing._before_delete.append(lambda s: db(db.person.id
>> ==s.select().first()['owner_id']).update(total_items=db(db.thing.owner_id==s.select().first()['owner_id']).count()))
>>
>
> Note, to simplify, you can do .update(total_items=db.person.total_items + 
> 1) and .update(total_items=db.person.total_items - 1).
>
> 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/groups/opt_out.


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Anthony

>
> db.thing._after_insert.append(lambda f,id: db(db.person.id
> ==f['owner_id']).update(total_items=len(db(db.thing.owner_id==f['owner_id']).select(
> from pprint import pprint
> db.thing._before_delete.append(lambda s: db(db.person.id
> ==s.select().first()['owner_id']).update(total_items=db(db.thing.owner_id==s.select().first()['owner_id']).count()))
>

Note, to simplify, you can do .update(total_items=db.person.total_items + 1)and 
.update(total_items=db.person.total_items - 1).

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


[web2py] Re: Dynamic form generation using FORM()

2014-01-14 Thread Chris Hepworth
You know, I hate to say it but that never even occurred to me to try. I got 
so distracted with other things that I never took the time to really 
evaluate what could be happeing. Thank you, Anthony.

On Tuesday, January 14, 2014 5:23:23 PM UTC-7, Anthony wrote:
>
> If you want to submit a list of inputs to FORM(), then that's all you can 
> submit. So, append the submit input to the fields list and then just do 
> FORM(fields).
>
> Also, if db.a_table.image is an upload field, it will just store the 
> transformed filename, which won't be very informative to the users. You'll 
> probably want to show the original filename (it may be easiest to store 
> that in a separate field rather than extract it from the transformed 
> filename).
>
> Anthony
>
> On Tuesday, January 14, 2014 4:44:49 PM UTC-5, Chris Hepworth wrote:
>>
>> I am trying to make a custom form which allows the selection of a set of 
>> images that are in the database. So far I have the following code:
>>
>> rows = db().select(db.a_table.name,db.a_table.image)
>> fields = []
>> for row in rows:
>> fields += [
>> INPUT(_type="checkbox", _value=row.image) , row.f_name
>> ]
>> form=FORM(fields,INPUT(_type='submit'))
>>
>> I know for sure that the database query is correct and is not a problem 
>> at all now. However, when I insert the form into the view it appears as 
>> follows:
>>
>> [, 'Koi', > 0xaf12bb8c>, 'Goldfish'...
>>
>> The only thing that renders as intended is the submit button. Am I going 
>> about this problem the right way? And if not, is there a way to achieve the 
>> effect I want? 
>>
>

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


[web2py] Architecture & hosting considerations. Just 1 query/minute but "high" traffic app

2014-01-14 Thread Jaime Sempere

Hi everyone, 

I plan to do an app for webs that have about 10k-100k visits per day. This 
app would be an iframe of my own webpage/app. 

I don't need a lot of bandwith (say that I will send an STATIC page, size 
less than 30-20kb per request), but I need to update some data of this 
static page each minute, querying my database, and here is my first big 
question.

What would be the best approach? I don't need to query database in every 
request, just query everyminute, and update the static page that is being 
returned. Here is my first big question. 

My first thought would be access to the static file and modify/update it 
every minute. This doesn't look to me like the best approach, but I have no 
experience in a case like this. Could anyone give me some hints or any 
other approaches? Cache, store the query on server...? 



I ask this here too, because I think is related with the hosting that I 
will need to choose... GAE was my first thought but I am worried about 
price, and also that I couldn't use my approach as I cannot modify 
filesystem from GAE.


Thanks in advance



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


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
Yeah, that thread says to use _before_delete, and it fits this use case.

Can you verify if what I'm seeing about the delete is correct? The 
_before_delete is causing the admin panel to not delete the record for some 
reason. Is it a bug?

I'm using web2py 2.7.4 stable

On Tuesday, January 14, 2014 9:20:27 PM UTC-5, 黄祥 wrote:
>
> for after delete callback, please check this discussion
> https://groups.google.com/forum/#!msg/web2py/M4_5THMHzH0/r9aXH-k8eJQJ
>
> 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/groups/opt_out.


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread 黄祥
for after delete callback, please check this discussion
https://groups.google.com/forum/#!msg/web2py/M4_5THMHzH0/r9aXH-k8eJQJ

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


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
I read through the link you show me. I'm using _before_delete now, since 
doing s.select() returns 0 rows since it's already been deleted. I'm not 
sure how to deal with sets in _after_delete.

Here is my updated models:

db.define_table('person',
Field('name'),
Field('total_items', 'integer'),
format='%(name)s')
db.define_table('thing',
Field('name'),
Field('owner_id', 'reference person'),
format='%(name)s')
## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db)

db.thing._after_insert.append(lambda f,id: 
db(db.person.id==f['owner_id']).update(total_items=len(db(db.thing.owner_id==f['owner_id']).select(
from pprint import pprint
db.thing._before_delete.append(lambda s: 
db(db.person.id==s.select().first()['owner_id']).update(total_items=db(db.thing.owner_id==s.select().first()['owner_id']).count()))

With this, deleting doesn't throw errors in the admin panel, but now for 
some reason deleting rows from the things table doesn't work anymore. The 
admin interface flashes the 'done!' message, but I still see the record. 

On Tuesday, January 14, 2014 6:58:37 PM UTC-5, 黄祥 wrote:
>
> another way around i think you can do it in web form using oncreate, 
> onupdate and ondelete. and for delete callback, please check this 
> discussion :
> https://groups.google.com/forum/#!topic/web2py/didLpxEKT38
> reference for oncreate, onupdate and ondelete, please check this 
> discussion :
> https://groups.google.com/forum/#!topic/web2py/ShebcblC9pM
>
> 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/groups/opt_out.


[web2py] Re: Dynamic form generation using FORM()

2014-01-14 Thread Anthony
If you want to submit a list of inputs to FORM(), then that's all you can 
submit. So, append the submit input to the fields list and then just do 
FORM(fields).

Also, if db.a_table.image is an upload field, it will just store the 
transformed filename, which won't be very informative to the users. You'll 
probably want to show the original filename (it may be easiest to store 
that in a separate field rather than extract it from the transformed 
filename).

Anthony

On Tuesday, January 14, 2014 4:44:49 PM UTC-5, Chris Hepworth wrote:
>
> I am trying to make a custom form which allows the selection of a set of 
> images that are in the database. So far I have the following code:
>
> rows = db().select(db.a_table.name,db.a_table.image)
> fields = []
> for row in rows:
> fields += [
> INPUT(_type="checkbox", _value=row.image) , row.f_name
> ]
> form=FORM(fields,INPUT(_type='submit'))
>
> I know for sure that the database query is correct and is not a problem at 
> all now. However, when I insert the form into the view it appears as 
> follows:
>
> [, 'Koi',  0xaf12bb8c>, 'Goldfish'...
>
> The only thing that renders as intended is the submit button. Am I going 
> about this problem the right way? And if not, is there a way to achieve the 
> effect I want? 
>

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


[web2py] Re: Need a Web2py tutor/mentor.

2014-01-14 Thread samuel bonill
look :

https://groups.google.com/forum/#!topic/web2py/Ow-x1D4__q0


El lunes, 13 de enero de 2014 22:07:05 UTC-5, Brando escribió:
>
>  I don't know anyone who builds webapps with python.  I've watched A LOT 
> of videos and read A LOT of posts about web2py.  I've got the basics down 
> and have built a couple of basic apps using web2py.  I'd like to find a 
> tutor/mentor who could spend a couple of hours with me (skype/google 
> hangout) to point me in the right direction on a few items.  I'm willing to 
> pay for your time.
>
> Suggestions?
>
>
>

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


[web2py] Re: linux shell scripts and web2py

2014-01-14 Thread 黄祥

>
> import subprocesssubprocess.call(['./scriptshell.sh'])
>
>
is it can be used for windows batch files too?
just a suggestion, why not use configuration management like puppet, chef 
or cfengine? 

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


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread 黄祥
another way around i think you can do it in web form using oncreate, 
onupdate and ondelete. and for delete callback, please check this 
discussion :
https://groups.google.com/forum/#!topic/web2py/didLpxEKT38
reference for oncreate, onupdate and ondelete, please check this discussion 
:
https://groups.google.com/forum/#!topic/web2py/ShebcblC9pM

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


[web2py] Re: Storing lots of txt files: Database or Filesystem? Advantages/Disadvantages

2014-01-14 Thread Anthony
Keep in mind, in that post, the first method (i.e., with 1 ms responses) 
involved serving static files. The second method (65-75 ms) also involved 
storing the files on the filesystem, but they weren't served as static 
files (instead, they were served using web2py's built-in file 
upload/download mechanism). If you need to protect the files via access 
control, then you cannot serve them as static files.

Anthony

On Tuesday, January 14, 2014 12:18:43 PM UTC-5, Brando wrote:
>
> Stifan, that is great info.  pulling from the filesystem is much faster. 
>  I think i'm going to go this route.  Thanks!
>
>
>
> On Monday, January 13, 2014 7:15:22 PM UTC-8, 黄祥 wrote:
>>
>> please check this discussion.
>> https://groups.google.com/forum/#!topic/web2py/t83nQfT24gE
>>
>> 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/groups/opt_out.


Re: [web2py] LDAP Auth

2014-01-14 Thread Maggs
Hi Richard,

That is perfect and exactly what I need! Thanks so much :)

Maggs

On Tuesday, January 14, 2014 6:52:51 AM UTC-8, Richard wrote:
>
> Hello Maggs,
>
> What you can do is to have 2 differents authentication process the 
> internal web2py process that will allow you to have a password as before 
> and then LDAP process... But you will not have password from LDAP you will 
> have two differents password, except if the user set the same password in 
> both, but you will not know this. The only thing I am not sure of is if it 
> possible to still allow user tu update their password since I restrict this 
> option, but I think you can still have the option on.
> # Here my setup 
> auth.settings.actions_disabled.extend(['change_password', 
> 'request_reset_password', 'retrieve_username'])
>
> I guess remove change_password could allow users to change their internal 
> web2py password even if you use LDAP (not tested).
>
> And for activate both authentication you do :
>
> auth.settings.login_methods = [auth, ldap_auth(mode='ad', ...)]
>
> You see auth is web2py default authentication process... So if you user 
> enter their web2py password they will authenticate against web2py, if they 
> enter their AD password the auth method will failed ant LDAP 
> authentification will be used...
>
> Hope it help...
>
> Richard
>
>
> On Mon, Jan 13, 2014 at 8:30 PM, Maggs 
> > wrote:
>
>> Hi all,
>>
>> I am running web2py 2.5.1 and have my auth set up to use secure ldap. 
>> Since switching from regular to secure ldap, I've noticed that web2py no 
>> longer saves the passwords of any newly added accounts to the db. Though I 
>> understand the reason for this since it's secure and all, I do actually 
>> need the passwords to be saved here. Is there a way to turn this on 
>> manually? I have done a whole lot of googling and reading through 
>> documentation to no avail. Apparently I'm the only person to ever want to 
>> do such a thing.
>>
>> Thanks,
>> Maeghan
>>
>> -- 
>> 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/groups/opt_out.
>>
>
>

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


[web2py] Dynamic form generation using FORM()

2014-01-14 Thread Chris Hepworth
I am trying to make a custom form which allows the selection of a set of 
images that are in the database. So far I have the following code:

rows = db().select(db.a_table.name,db.a_table.image)
fields = []
for row in rows:
fields += [
INPUT(_type="checkbox", _value=row.image) , row.f_name
]
form=FORM(fields,INPUT(_type='submit'))

I know for sure that the database query is correct and is not a problem at 
all now. However, when I insert the form into the view it appears as 
follows:

[, 'Koi', , 'Goldfish'...

The only thing that renders as intended is the submit button. Am I going 
about this problem the right way? And if not, is there a way to achieve the 
effect I want? 

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


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
Thanks, I came up with this:

db.thing._after_insert.append(lambda f,id: 
db(db.person.id==f['owner_id']).update(total_items=len(db(db.thing.owner_id==f['owner_id']).select(

It works, but is there is a better way to do this? Also, can someone help 
me with _after_delete? _after_delete gives me a set of db.thing.id, and I'm 
not sure how to use this to update the db.persons.total_items field.

On Tuesday, January 14, 2014 8:50:38 AM UTC-5, Anthony wrote:
>
> If you want db.person to be updated upon changes to db.thing, instead of a 
> computed field in db.person, you probably want to create _after_insert and 
> _after_update callbacks for db.thing (see 
> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks
> ).
>
> Anthony
>
> On Tuesday, January 14, 2014 12:48:59 AM UTC-5, Apple Mason wrote:
>>
>> In the online doc on computed field, the computed fields uses a field in 
>> the current table, and not in another table.
>>
>> I modified the one-to-many example by adding a 'total_items' field on 
>> person. If I want 'total_items' to be the sum of all items the person 
>> currently has, and this field should be updated when an inserted/deleted 
>> 'thing' for this person happens, what should computed be?
>>
>>
>> >>> db.define_table('person',
>> Field('name'),
>> Field('total_items', 'integer', compute=#lamdba r: 
>> r.??),  # what should go here?
>> format='%(name)s')
>> >>> db.define_table('thing',
>> Field('name'),
>> Field('owner_id', 'reference person'),
>> format='%(name)s')
>>
>>

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


Re: [web2py] Re: detect a specific device

2014-01-14 Thread Niphlod
this is an architectural problem: what does the device send to your app to 
be able to identify it ? 
If it's a webapp and it is accessed via the browser, and there are no 
running bits on the device itself speaking to your webapp, then the headers 
and the env are the only thing you can rely onto (fortunately, browsers are 
fully isolated). 

Hello, authentication (or fixed ip address)!

On Tuesday, January 14, 2014 8:05:17 PM UTC+1, Paolo Valleri wrote:
>
> Hi, 
> what you posted can be a starting point but it is not enough because it 
> doesn't guarantee that a different android tablet has been purchased. 
> The requirement is, only a well defined set of tablets can access the 
> webapp.
>
>  Paolo
>
>
> 2014/1/14 Leonel Câmara >
>
>> I guess you can use something like:
>>
>> request.user_agent().is_tablet and request.user_agent().dist.name == 
>> 'Android'
>>
>>
>>  -- 
>> 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/3Q7izsidMXM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


[web2py] Re: detect a specific device

2014-01-14 Thread Willoughby
You need to specify what is a 'well defined device'...
Even a MAC address can be spoofed.

On Tuesday, January 14, 2014 4:23:19 AM UTC-5, Paolo Valleri wrote:
>
> Hi all,
> I'd develop a web2py responsible app instead of an android app; at a first 
> sight it seams to some extent feasible. The only issue is related to an 
> unusual requirement, the web2py app (running on an intranet) must be 
> accessible only from well defined devices (android tablet). If needed I 
> can, let say, 'customize' the android tablet. 
> What can I do in order to satisfy this requirement? Be aware that the 
> simplest trick you have in mind should be fine because the app runs in an 
> intranet; given that I don't foresee malicious attacks or any kind of hack.
>
> Regards
> Paolo
>
>

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


Re: [web2py] Re: detect a specific device

2014-01-14 Thread Dave S
On Tuesday, January 14, 2014 11:05:17 AM UTC-8, Paolo Valleri wrote:
>
> Hi, 
> what you posted can be a starting point but it is not enough because it 
> doesn't guarantee that a different android tablet has been purchased. 
> The requirement is, only a well defined set of tablets can access the 
> webapp.
>
>
Can you require a token on the tablet?  Perhaps the browser can pass that 
the way it does a cookie.  I'd look at making a token that's basically a 
wrapper of a cert or perhaps encrypt the device's serial number (SN) with 
the associated key?

/dps
 

> 2014/1/14 Leonel Câmara >
>
>> I guess you can use something like:
>>
>> request.user_agent().is_tablet and request.user_agent().dist.name == 
>> 'Android'
>>
>>
>> -- 
>> 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/3Q7izsidMXM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


Re: [web2py] Re: detect a specific device

2014-01-14 Thread paolo.vall...@gmail.com
Hi,
what you posted can be a starting point but it is not enough because it
doesn't guarantee that a different android tablet has been purchased.
The requirement is, only a well defined set of tablets can access the
webapp.

 Paolo


2014/1/14 Leonel Câmara 

> I guess you can use something like:
>
> request.user_agent().is_tablet and request.user_agent().dist.name ==
> 'Android'
>
>
>  --
> 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/3Q7izsidMXM/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/groups/opt_out.
>

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


Re: [web2py] Compile app from command line

2014-01-14 Thread Wonton
Thank you very much for your advise! I will keep this in mind.

On Tuesday, January 14, 2014 4:25:22 AM UTC+1, LightDot wrote:
>
> Looking at your python version, you're running a RHEL 5 (or a derivative, 
> such as CentOS). Just a word of caution if you decide to attempt updating 
> the OS python's version - search the net for previous experiences. It's not 
> straightforward, as other important parts of the OS depend on it (ie. yum, 
> etc.).
>
> You might want to look into other possibilities, such as using python 2.6 
> from EPEL repository. This solution also has virtualenv available.
>
> Regards
>
>
> On Tuesday, January 14, 2014 1:08:23 AM UTC+1, Wonton wrote:
>>
>> That must be the problem. Both versions are very different. My local 
>> version is 2.7.5 (default, Aug 25 2013, 00:04:04)  and the server version 
>> is 2.4.3 (#1, Jun 18 2012, 08:55:23). I will try to update the server 
>> versionand see what happens.
>>
>> Thank you very much Ricardo!
>>
>> On Tuesday, January 14, 2014 12:52:02 AM UTC+1, Ricardo Pedroso wrote:
>>>
>>> On Mon, Jan 13, 2014 at 11:08 PM, Wonton  wrote: 
>>> > Hello everyone, 
>>> > 
>>> > I'm compiling my local apps with this command: 
>>> > 
>>> > python -c "import gluon.compileapp; 
>>> > gluon.compileapp.compile_application('applications/')" 
>>> > 
>>> > And everything is working well. But when I try to do the same thing in 
>>> the 
>>> > server (as admin), in the production environment I get this error: 
>>> > 
>>> > Traceback (most recent call last): 
>>> >   File "", line 1, in ? 
>>> >   File "gluon/__init__.py", line 15, in ? 
>>> > from globals import current 
>>> >   File "gluon/globals.py", line 17, in ? 
>>> > from storage import Storage, List 
>>> >   File "gluon/storage.py", line 73 
>>> > return value if not value else \ 
>>> >   ^ 
>>> > SyntaxError: invalid syntax 
>>>
>>> Probably a python version mismatch. 
>>>
>>> What python version do you have when run it from the shell? 
>>> Can be checked with: 
>>>
>>> $ python -c "import sys;print sys.version" 
>>>
>>>
>>> Ricardo 
>>>
>>

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


[web2py] Re: detect a specific device

2014-01-14 Thread Leonel Câmara
I guess you can use something like:

request.user_agent().is_tablet and request.user_agent().dist.name == 
'Android'


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


Re: [web2py] Re: keepvalues - need help with this

2014-01-14 Thread Anthony
keepvalues is for retaining values when there are no errors (but you want 
to retain the values from the previous submission). If there are errors, 
the values will be retained regardless of keepvalues. In your case, you are 
not using form.custom.widget, so you're not getting the values retained. If 
you create custom widgets, though, the field and value will get passed to 
the widget, so your custom widget should be able to retain the value if 
desired (without using request.vars).

Anthony

On Tuesday, January 14, 2014 11:52:54 AM UTC-5, Kiran Subbaraman wrote:
>
>  Anthony,
> Thanks for the link; that is useful. Also, was looking at the 
> implementation of the default widgets in 
> https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py.
>
> I think I can conclude that keepvalues does not retain values, as detailed 
> in this email. 
> Considering that I have to check for request.vars and then the 
> form.custom.* to assign values to be displayed, it makes sense to 
> encapsulate this amount of code in a helper function, or even a widget. I 
> intend to do just that.
>
> Thanks,
> Kiran
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On 1/14/2014 8:46 PM, Anthony wrote:
>  
> Some instruction about creating custom widgets at the end of this section: 
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Widgets
> .
>
> On Tuesday, January 14, 2014 12:33:22 AM UTC-5, Kiran Subbaraman wrote: 
>>
>>  Yes, that works: use request.vars.*. That was the option which I had 
>> mentioned I may need to resort to, since *keepvalues *doesn't seem to 
>> work for me.
>> This basically comes down to me creating a bunch of widgets; mirroring 
>> the ones in web2py, where a widget would have logic, similar to the one 
>> below, in it. 
>> I need to figure out how to create a widget now. Am familiar with 
>> creating jsp tag libraries, and dojo widgets. 
>>
>>   > id="country" name="country" 
>> value="{{=request.vars.country or 
>> form.custom.inpval['country']}}"
>> placeholder="{{=form.custom.comment['country']}}"
>>  
>> Thanks for your inputs,
>> Kiran
>>
>> 
>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>
>> On 1/14/2014 1:23 AM, Massimo Di Pierro wrote:
>>  
>> Strange. How about 
>>
>>  {{=request.vars.country or form.custom.inpval['country']}}
>>
>> On Monday, 13 January 2014 11:13:33 UTC-6, subbaram...@gmail.com wrote: 
>>>
>>> Massimo,
>>> Yes, I did. Does not make a difference. 
>>>
>>> Thanks for the suggestion,
>>> Kiran
>>>
>>> On Monday, January 13, 2014 7:49:15 PM UTC+5:30, Massimo Di Pierro 
>>> wrote: 

 Have you tried replacing 

  value="{{=form.custom.inpval['country']}}"

  with

  value="{{=form.custom.dspval['country']}}"

 On Sunday, 12 January 2014 22:50:43 UTC-6, subbaram...@gmail.comwrote: 
>
> Really would like some help with this. Anyone have suggestions?
> Thank you,
> Kiran
>
> On Saturday, January 11, 2014 12:10:07 AM UTC+5:30, 
> subbaram...@gmail.com wrote: 
>>
>> Hello All,
>> The *design *is: I have a custom form with the a controller that 
>> inserts/updates a table. Tthe form accepts data, and on successful 
>> submission of this form, it stays on the same page (there are no 
>> redirects 
>> to another page or form)
>> *Issue*: The problem am seeing is, when I update values in the form, 
>> and submit it, the entered values are lost when the form returns because 
>> of 
>> successful submit, or due to errors. I have tried to use keepvalues=True 
>> in 
>> the form.accepts() and form.process() methods. No luck.
>> Details below.
>>
>> Since the page am building has specific design needs, I went with the 
>> option of a custom form, where I used the form.custom.* options quite a 
>> bit. Therefore input fields in the form look like this
>>   > id="country" name="country" 
>> value="{{=form.custom.inpval['country']}}"
>> placeholder="{{=form.custom.comment['country']}}"
>>  
>> Also the controller is coded as below
>>  x = db(db.x.x_id == auth.user.id).select().first()
>> if x:
>> form = SQLFORM(db.x, record=x)
>> else:
>> form = SQLFORM(db.x)
>> pass
>>
>>  
>> # process the form
>> if form.accepts(request.vars, formname='basicinfo_form',keepvalues
>> =True):
>> response.flash = 'Basic Information updated successfully.'
>> elif form.errors:
>> response.flash = 'The submitted form contains errors. The 
>> fields in error are highlighted below.'
>> else:
>> response.flash = 'Please fill the form.'
>> pass
>>
>> retur

[web2py] Re: Storing lots of txt files: Database or Filesystem? Advantages/Disadvantages

2014-01-14 Thread Brando
Stifan, that is great info.  pulling from the filesystem is much faster.  I 
think i'm going to go this route.  Thanks!



On Monday, January 13, 2014 7:15:22 PM UTC-8, 黄祥 wrote:
>
> please check this discussion.
> https://groups.google.com/forum/#!topic/web2py/t83nQfT24gE
>
> 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/groups/opt_out.


Re: [web2py] Re: keepvalues - need help with this

2014-01-14 Thread Kiran Subbaraman

Anthony,
Thanks for the link; that is useful. Also, was looking at the 
implementation of the default widgets in 
https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py.


I think I can conclude that keepvalues does not retain values, as 
detailed in this email.
Considering that I have to check for request.vars and then the 
form.custom.* to assign values to be displayed, it makes sense to 
encapsulate this amount of code in a helper function, or even a widget. 
I intend to do just that.


Thanks,
Kiran


Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On 1/14/2014 8:46 PM, Anthony wrote:
Some instruction about creating custom widgets at the end of this 
section: 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Widgets.


On Tuesday, January 14, 2014 12:33:22 AM UTC-5, Kiran Subbaraman wrote:

Yes, that works: use request.vars.*. That was the option which I
had mentioned I may need to resort to, since *keepvalues *doesn't
seem to work for me.
This basically comes down to me creating a bunch of widgets;
mirroring the ones in web2py, where a widget would have logic,
similar to the one below, in it.
I need to figure out how to create a widget now. Am familiar with
creating jsp tag libraries, and dojo widgets.

|
 http://subbaraman.wordpress.com/about/  


On 1/14/2014 1:23 AM, Massimo Di Pierro wrote:

Strange. How about

{{=request.vars.country or form.custom.inpval['country']}}

On Monday, 13 January 2014 11:13:33 UTC-6, subbaram...@gmail.com
wrote:

Massimo,
Yes, I did. Does not make a difference.

Thanks for the suggestion,
Kiran

On Monday, January 13, 2014 7:49:15 PM UTC+5:30, Massimo Di
Pierro wrote:

Have you tried replacing

value="{{=form.custom.inpval['country']}}"

with

value="{{=form.custom.dspval['country']}}"

On Sunday, 12 January 2014 22:50:43 UTC-6,
subbaram...@gmail.com wrote:

Really would like some help with this. Anyone have
suggestions?
Thank you,
Kiran

On Saturday, January 11, 2014 12:10:07 AM UTC+5:30,
subbaram...@gmail.com wrote:

Hello All,
The *design *is: I have a custom form with the a
controller that inserts/updates a table. Tthe
form accepts data, and on successful submission
of this form, it stays on the same page (there
are no redirects to another page or form)
*Issue*: The problem am seeing is, when I update
values in the form, and submit it, the entered
values are lost when the form returns because of
successful submit, or due to errors. I have tried
to use keepvalues=True in the form.accepts() and
form.process() methods. No luck.
Details below.

Since the page am building has specific design
needs, I went with the option of a custom form,
where I used the form.custom.* options quite a
bit. Therefore input fields in the form look like
this
|
 https://groups.google.com/forum/#!searchin/web2py/keepvalues$20on$20validate/web2py/MNEYo96Shzg/jjKZaMmfAgQJ



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


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


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web

[web2py] Re: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-14 Thread User
For completeness and future reference this can also be done directly in SQL 
for example in postgresql:

UPDATE your_table set some_field =  '|' || some_field || '|';

On Tuesday, January 14, 2014 8:52:40 AM UTC-5, Anthony wrote:

> For now, if you want to do a migration, all you have to do is loop through 
> the records and put a pipe character ("|") before and after each string. 
> Perhaps this can be automated -- you can submit an issue on Google Code.
>
> Anthony
>
> On Tuesday, January 14, 2014 1:21:52 AM UTC-5, User wrote:
>>
>> It appears it will leave the string data that exists in the string field 
>> alone in the database, however web2py will interpret it such that the first 
>> and last character are truncated.  For example:
>>
>> "hello" -> "ell"
>>
>> "something" -> "omethin"
>>
>> "world" -> "orl"
>> As soon as you add another list item to the string, then web2py 
>> will overwrite the original string's first and last characters with pipe 
>> characters in the database in addition to adding the new item.
>>
>> Migration back from list:string to string will preserve whatever 
>> list:string data is there (in the web2py representation format).
>>
>> "hello", "world" -> "|hello|world|"
>>
>> "one", "two" -> "|one|two|"
>>
>> Would it make sense for the migration process to handle this more 
>> gracefully?
>>
>>
>> On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:
>>
>>> Does a migration from a 'string' field to a 'list:string' field preserve 
>>> string data that is already in the database and convert it to the format 
>>> required by list:string?
>>>
>>

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


[web2py] Re: SQLFORM and IS_IN_SET problem

2014-01-14 Thread User
Thanks good point about just modifying the db field directly to add pipe 
characters if migrating from string to list:string.  I think in that case I 
will make my field a string field and migrate later if necessary.

On Tuesday, January 14, 2014 9:48:53 AM UTC-5, Anthony wrote:
>
> On Tuesday, January 14, 2014 1:18:11 AM UTC-5, User wrote:
>>
>> So I tested the migration feature and string to list:string doesn't 
>> work.  So we are left with the fact that a list:string field with IS_IN_SET 
>> multiple=False will not select the current value in an SQLFORM.
>>
>> Seems kind of like a bug to me, does anyone else think so?
>>
>
> I wouldn't call it a bug. It's somewhat of an odd use case.  Using 
> IS_IN_SET with multiple=False gives you a non-multiple SELECT widget. Such 
> a widget can have only a single option selected, so the web2py SELECT 
> helper checks to see if the current value of the field is the same as any 
> of the OPTION values. Because the current value of the list:string field is 
> a list (and not an individual string), it will not match the value of any 
> option values.
>
> Instead, you can just switch to a string field, and if you ever need to 
> migrate, just wrap each string in pipe characters (i.e., "|thestring|").
>
> Another option is to create a custom widget:
>
> Field('myfield', 'list:string', requires=IS_IN_SET(...), widget=mywidget)
>
> Finally, you can do:
>
> Field('myfield', 'list:string', requires=IS_IN_SET(..., multiple=(1, 1)),
>   comment='Please select only one.')
>
> The above will show a multiple select box instead of a single-select 
> drop-down, but it will require the user to select exactly one option (will 
> return an error message otherwise).
>
> 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/groups/opt_out.


Re: [web2py] Re: keepvalues - need help with this

2014-01-14 Thread Anthony
Some instruction about creating custom widgets at the end of this section: 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Widgets.

On Tuesday, January 14, 2014 12:33:22 AM UTC-5, Kiran Subbaraman wrote:
>
>  Yes, that works: use request.vars.*. That was the option which I had 
> mentioned I may need to resort to, since *keepvalues *doesn't seem to 
> work for me.
> This basically comes down to me creating a bunch of widgets; mirroring the 
> ones in web2py, where a widget would have logic, similar to the one below, 
> in it. 
> I need to figure out how to create a widget now. Am familiar with creating 
> jsp tag libraries, and dojo widgets. 
>
>id="country" name="country" 
> value="{{=request.vars.country or 
> form.custom.inpval['country']}}"
> placeholder="{{=form.custom.comment['country']}}"
>  
> Thanks for your inputs,
> Kiran
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On 1/14/2014 1:23 AM, Massimo Di Pierro wrote:
>  
> Strange. How about 
>
>  {{=request.vars.country or form.custom.inpval['country']}}
>
> On Monday, 13 January 2014 11:13:33 UTC-6, subbaram...@gmail.com wrote: 
>>
>> Massimo,
>> Yes, I did. Does not make a difference. 
>>
>> Thanks for the suggestion,
>> Kiran
>>
>> On Monday, January 13, 2014 7:49:15 PM UTC+5:30, Massimo Di Pierro wrote: 
>>>
>>> Have you tried replacing 
>>>
>>>  value="{{=form.custom.inpval['country']}}"
>>>
>>>  with
>>>
>>>  value="{{=form.custom.dspval['country']}}"
>>>
>>> On Sunday, 12 January 2014 22:50:43 UTC-6, subbaram...@gmail.com wrote: 

 Really would like some help with this. Anyone have suggestions?
 Thank you,
 Kiran

 On Saturday, January 11, 2014 12:10:07 AM UTC+5:30, 
 subbaram...@gmail.com wrote: 
>
> Hello All,
> The *design *is: I have a custom form with the a controller that 
> inserts/updates a table. Tthe form accepts data, and on successful 
> submission of this form, it stays on the same page (there are no 
> redirects 
> to another page or form)
> *Issue*: The problem am seeing is, when I update values in the form, 
> and submit it, the entered values are lost when the form returns because 
> of 
> successful submit, or due to errors. I have tried to use keepvalues=True 
> in 
> the form.accepts() and form.process() methods. No luck.
> Details below.
>
> Since the page am building has specific design needs, I went with the 
> option of a custom form, where I used the form.custom.* options quite a 
> bit. Therefore input fields in the form look like this
>    id="country" name="country" 
> value="{{=form.custom.inpval['country']}}"
> placeholder="{{=form.custom.comment['country']}}"
>  
> Also the controller is coded as below
>  x = db(db.x.x_id == auth.user.id).select().first()
> if x:
> form = SQLFORM(db.x, record=x)
> else:
> form = SQLFORM(db.x)
> pass
>
>  
> # process the form
> if form.accepts(request.vars, formname='basicinfo_form',keepvalues
> =True):
> response.flash = 'Basic Information updated successfully.'
> elif form.errors:
> response.flash = 'The submitted form contains errors. The 
> fields in error are highlighted below.'
> else:
> response.flash = 'Please fill the form.'
> pass
>
> return dict(form=form)
>  
> I was thinking that maybe I should capture the request.vars and send 
> it back to the view alongwith the form. 
> If the request.vars.country value exists, then I use that, instead of 
> the form.custom.inpval['country']. This only makes the view code a bit 
> more 
> verbose, but if it solves the problem, then nothing like it. 
>
> Can anyone suggest what I could do to sort this out?
> Thank you,
> Kiran
>
> P.S: I did take a look at all the conversations in the forum about 
> keepvalues. None of them seemed to help me. Though I did find this one to 
> be interesting and am curious if this is sorted out already: 
> https://groups.google.com/forum/#!searchin/web2py/keepvalues$20on$20validate/web2py/MNEYo96Shzg/jjKZaMmfAgQJ
>
>   -- 
> 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/groups/opt_out.
>
>
>  

-- 
Resources:
- http://web2py.co

Re: [web2py] Re: Quick question about custom message for verification and password reset email sent

2014-01-14 Thread Alex Bush
Thank you Anthony, that works beautifully!


On 14 January 2014 14:56, Anthony  wrote:

> As I mentioned, you can change auth.messages.email_sent dynamically:
>
> def user():
> flash = dict(register='Verification email sent',
>  request_reset_password='Reset password email sent')
> auth.messages.email_sent = flash.get(request.args(0), auth.messages.
> email_sent)
> return dict(form=auth())
>
> Anthony
>
> On Tuesday, January 14, 2014 9:35:09 AM UTC-5, Alex Bush wrote:
>>
>> Appologies if the initial email was confusing and thank you for the reply
>> Anthony, I understand and am using auth.messages.verify_email and
>> auth.messages.verify_email_subject however I wondered if there was any
>> way to set a specific flash message for each situation (verification email
>> sent and password reset email sent) instead of the
>> generic auth.messages.email_sent?
>>
>> At the moment the user is directed to the login page after registering
>> and the only hint of a verification email is the email sent flash.
>>
>> On Tuesday, 14 January 2014 13:46:48 UTC, Anthony wrote:
>>>
>>> On Tuesday, January 14, 2014 7:28:14 AM UTC-5, Alex Bush wrote:

 Hi all,

 I'm trying to set (custom) messages for both the verification email
 sent for new user registration

>>>
>>> Do auth.messages.verify_email and auth.messages.verify_email_subject
>>> not work for you? Note, auth.messages.email_sent is for the flash message
>>> that tells the user an email was sent (it is a generic message, not
>>> specific to the verification email, though you could change it dynamically
>>> to a custom message when the register function is called).
>>>
>>>
 and password reset email sent for existing users.

>>>
>>> auth.messages.reset_password_subject and auth.messages.reset_password
>>>
>>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/YL1CAdYavN8/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/groups/opt_out.
>

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


Re: [web2py] Re: linux shell scripts and web2py

2014-01-14 Thread Richard Vézina
Depending of the duration of your shell script you may face web server
timeout watchout!!

Richard


On Mon, Jan 13, 2014 at 4:33 PM, Adam Detektyw  wrote:

>
> I found that Python uses sth like that:
>
> import subprocesssubprocess.call(['./scriptshell.sh'])
>
> Looks fine. I must try it. Thanks a lot
>
>
> Regards
> Adam
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: [web2py] REF: Web2py database issue

2014-01-14 Thread Richard Vézina
Notice migrate_neabled=False as notting to do with read only, it only tell
to web2py to not migrate apply to the models in models.py. It is more of a
complement.

You may also consider to use auth permissions and set them to read and
select for every objects in your database for more sercure read only. So in
case you forgot a update or a create somewhere they will be disabled by the
permissions if you check for permission in your functions.

:)

Richard


On Mon, Jan 13, 2014 at 9:22 PM, Teddy Nyambe wrote:

> Brilliant, am using mural db...have found an inbuilt replication feature
> in mysql. So will try out the dam(..., migrate_enabled=False) feature for
> read only. And of course will use only select statements in the read only
> app.
>
> Thanx
> On 13 Jan 2014 21:42, "Anthony"  wrote:
>
>> Also, set DAL(..., migrate_enabled=False) to prevent migrations.
>>
>> Anthony
>>
>> On Monday, January 13, 2014 2:35:40 PM UTC-5, Richard wrote:
>>>
>>> web2py readonly :
>>> You implement select only in your app function everywhere :
>>>
>>> db().select()
>>>
>>> SQLFORM(..., readonly=True)
>>>
>>> SQLFORM.grid(..., deletable=False, editable=False, create=Flase,
>>> details=True, selectable=True)
>>>
>>> Replication :
>>> An audit trail on your table that received the new data should be what
>>> you want?
>>>
>>>
>>> :)#
>>>
>>> Richard
>>>
>>>
>>> On Mon, Jan 13, 2014 at 7:12 AM, Teddy Nyambe wrote:
>>>
 I have two web2py apps, one updates database the other app should just
 read. But i want the readonly app to have its own db to ready from with
 selected tables from the main db. Whats the best way to replicate selected
 tables and monitor changes to main db. Secondly what would be the
 configuration of web2py operate in readonly mode?

 --
 
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

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

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

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


[web2py] Re: Quick question about custom message for verification and password reset email sent

2014-01-14 Thread Anthony
As I mentioned, you can change auth.messages.email_sent dynamically:

def user():
flash = dict(register='Verification email sent',
 request_reset_password='Reset password email sent')
auth.messages.email_sent = flash.get(request.args(0), auth.messages.
email_sent)
return dict(form=auth())

Anthony

On Tuesday, January 14, 2014 9:35:09 AM UTC-5, Alex Bush wrote:
>
> Appologies if the initial email was confusing and thank you for the reply 
> Anthony, I understand and am using auth.messages.verify_email and 
> auth.messages.verify_email_subject however I wondered if there was any way 
> to set a specific flash message for each situation (verification email sent 
> and password reset email sent) instead of the 
> generic auth.messages.email_sent? 
>
> At the moment the user is directed to the login page after registering and 
> the only hint of a verification email is the email sent flash.
>
> On Tuesday, 14 January 2014 13:46:48 UTC, Anthony wrote:
>>
>> On Tuesday, January 14, 2014 7:28:14 AM UTC-5, Alex Bush wrote:
>>>
>>> Hi all,
>>>
>>> I'm trying to set (custom) messages for both the verification email sent 
>>> for new user registration
>>>
>>
>> Do auth.messages.verify_email and auth.messages.verify_email_subject not 
>> work for you? Note, auth.messages.email_sent is for the flash message that 
>> tells the user an email was sent (it is a generic message, not specific to 
>> the verification email, though you could change it dynamically to a custom 
>> message when the register function is called).
>>  
>>
>>> and password reset email sent for existing users.
>>>
>>
>> auth.messages.reset_password_subject and auth.messages.reset_password
>>
>> 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/groups/opt_out.


Re: [web2py] REF: Web2py database issue

2014-01-14 Thread Anthony
On Tuesday, January 14, 2014 9:56:25 AM UTC-5, Richard wrote:
>
> Notice migrate_neabled=False as notting to do with read only, it only tell 
> to web2py to not migrate apply to the models in models.py. It is more of a 
> complement.
>

The point is that if two applications are accessing the database, you want 
to make sure that only one of the apps is doing migrations.

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


Re: [web2py] LDAP Auth

2014-01-14 Thread Richard Vézina
Hello Maggs,

What you can do is to have 2 differents authentication process the internal
web2py process that will allow you to have a password as before and then
LDAP process... But you will not have password from LDAP you will have two
differents password, except if the user set the same password in both, but
you will not know this. The only thing I am not sure of is if it possible
to still allow user tu update their password since I restrict this option,
but I think you can still have the option on.
# Here my setup
auth.settings.actions_disabled.extend(['change_password',
'request_reset_password', 'retrieve_username'])

I guess remove change_password could allow users to change their internal
web2py password even if you use LDAP (not tested).

And for activate both authentication you do :

auth.settings.login_methods = [auth, ldap_auth(mode='ad', ...)]

You see auth is web2py default authentication process... So if you user
enter their web2py password they will authenticate against web2py, if they
enter their AD password the auth method will failed ant LDAP
authentification will be used...

Hope it help...

Richard


On Mon, Jan 13, 2014 at 8:30 PM, Maggs  wrote:

> Hi all,
>
> I am running web2py 2.5.1 and have my auth set up to use secure ldap.
> Since switching from regular to secure ldap, I've noticed that web2py no
> longer saves the passwords of any newly added accounts to the db. Though I
> understand the reason for this since it's secure and all, I do actually
> need the passwords to be saved here. Is there a way to turn this on
> manually? I have done a whole lot of googling and reading through
> documentation to no avail. Apparently I'm the only person to ever want to
> do such a thing.
>
> Thanks,
> Maeghan
>
> --
> 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/groups/opt_out.
>

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


[web2py] Re: SQLFORM and IS_IN_SET problem

2014-01-14 Thread Anthony
On Tuesday, January 14, 2014 1:18:11 AM UTC-5, User wrote:
>
> So I tested the migration feature and string to list:string doesn't work.  
> So we are left with the fact that a list:string field with IS_IN_SET 
> multiple=False will not select the current value in an SQLFORM.
>
> Seems kind of like a bug to me, does anyone else think so?
>

I wouldn't call it a bug. It's somewhat of an odd use case.  Using 
IS_IN_SET with multiple=False gives you a non-multiple SELECT widget. Such 
a widget can have only a single option selected, so the web2py SELECT 
helper checks to see if the current value of the field is the same as any 
of the OPTION values. Because the current value of the list:string field is 
a list (and not an individual string), it will not match the value of any 
option values.

Instead, you can just switch to a string field, and if you ever need to 
migrate, just wrap each string in pipe characters (i.e., "|thestring|").

Another option is to create a custom widget:

Field('myfield', 'list:string', requires=IS_IN_SET(...), widget=mywidget)

Finally, you can do:

Field('myfield', 'list:string', requires=IS_IN_SET(..., multiple=(1, 1)),
  comment='Please select only one.')

The above will show a multiple select box instead of a single-select 
drop-down, but it will require the user to select exactly one option (will 
return an error message otherwise).

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


[web2py] Re: Quick question about custom message for verification and password reset email sent

2014-01-14 Thread Alex Bush
Appologies if the initial email was confusing and thank you for the reply 
Anthony, I understand and am using auth.messages.verify_email and 
auth.messages.verify_email_subject however I wondered if there was any way 
to set a specific flash message for each situation (verification email sent 
and password reset email sent) instead of the 
generic auth.messages.email_sent? 

At the moment the user is directed to the login page after registering and 
the only hint of a verification email is the email sent flash.

On Tuesday, 14 January 2014 13:46:48 UTC, Anthony wrote:
>
> On Tuesday, January 14, 2014 7:28:14 AM UTC-5, Alex Bush wrote:
>>
>> Hi all,
>>
>> I'm trying to set (custom) messages for both the verification email sent 
>> for new user registration
>>
>
> Do auth.messages.verify_email and auth.messages.verify_email_subject not 
> work for you? Note, auth.messages.email_sent is for the flash message that 
> tells the user an email was sent (it is a generic message, not specific to 
> the verification email, though you could change it dynamically to a custom 
> message when the register function is called).
>  
>
>> and password reset email sent for existing users.
>>
>
> auth.messages.reset_password_subject and auth.messages.reset_password
>
> 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/groups/opt_out.


[web2py] Re: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-14 Thread Anthony
For now, if you want to do a migration, all you have to do is loop through 
the records and put a pipe character ("|") before and after each string. 
Perhaps this can be automated -- you can submit an issue on Google Code.

Anthony

On Tuesday, January 14, 2014 1:21:52 AM UTC-5, User wrote:
>
> It appears it will leave the string data that exists in the string field 
> alone in the database, however web2py will interpret it such that the first 
> and last character are truncated.  For example:
>
> "hello" -> "ell"
>
> "something" -> "omethin"
>
> "world" -> "orl"
> As soon as you add another list item to the string, then web2py 
> will overwrite the original string's first and last characters with pipe 
> characters in the database in addition to adding the new item.
>
> Migration back from list:string to string will preserve whatever 
> list:string data is there (in the web2py representation format).
>
> "hello", "world" -> "|hello|world|"
>
> "one", "two" -> "|one|two|"
>
> Would it make sense for the migration process to handle this more 
> gracefully?
>
>
> On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:
>
>> Does a migration from a 'string' field to a 'list:string' field preserve 
>> string data that is already in the database and convert it to the format 
>> required by list:string?
>>
>

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


[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Anthony
If you want db.person to be updated upon changes to db.thing, instead of a 
computed field in db.person, you probably want to create _after_insert and 
_after_update callbacks for db.thing (see 
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks
).

Anthony

On Tuesday, January 14, 2014 12:48:59 AM UTC-5, Apple Mason wrote:
>
> In the online doc on computed field, the computed fields uses a field in 
> the current table, and not in another table.
>
> I modified the one-to-many example by adding a 'total_items' field on 
> person. If I want 'total_items' to be the sum of all items the person 
> currently has, and this field should be updated when an inserted/deleted 
> 'thing' for this person happens, what should computed be?
>
>
> >>> db.define_table('person',
> Field('name'),
> Field('total_items', 'integer', compute=#lamdba r: r.??), 
>  # what should go here?
> format='%(name)s')
> >>> db.define_table('thing',
> Field('name'),
> Field('owner_id', 'reference person'),
> format='%(name)s')
>
>

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


[web2py] Re: Quick question about custom message for verification and password reset email sent

2014-01-14 Thread Anthony
On Tuesday, January 14, 2014 7:28:14 AM UTC-5, Alex Bush wrote:
>
> Hi all,
>
> I'm trying to set (custom) messages for both the verification email sent 
> for new user registration
>

Do auth.messages.verify_email and auth.messages.verify_email_subject not 
work for you? Note, auth.messages.email_sent is for the flash message that 
tells the user an email was sent (it is a generic message, not specific to 
the verification email, though you could change it dynamically to a custom 
message when the register function is called).
 

> and password reset email sent for existing users.
>

auth.messages.reset_password_subject and auth.messages.reset_password

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


[web2py] Quick question about custom message for verification and password reset email sent

2014-01-14 Thread Alex Bush
Hi all,

I'm trying to set (custom) messages for both the verification email sent 
for new user registration and password reset email sent for existing users.

I have found the list of available messages here: 
http://www.web2py.com/book/default/chapter/09 however none of them seem to 
correspond to the messages I describe. I don't really want to start 
modifying the gluon files to include these messages so I wondered if anyone 
knows of an alternate method to setting these messages. I think it is 
important to let the user know they must verify their account by email and 
currently no notification is given to them.

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


[web2py] detect a specific device

2014-01-14 Thread Paolo Valleri
Hi all,
I'd develop a web2py responsible app instead of an android app; at a first 
sight it seams to some extent feasible. The only issue is related to an 
unusual requirement, the web2py app (running on an intranet) must be 
accessible only from well defined devices (android tablet). If needed I 
can, let say, 'customize' the android tablet. 
What can I do in order to satisfy this requirement? Be aware that the 
simplest trick you have in mind should be fine because the app runs in an 
intranet; given that I don't foresee malicious attacks or any kind of hack.

Regards
Paolo

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


[web2py] Re: linux shell scripts and web2py

2014-01-14 Thread Adam Detektyw


I found that Python uses sth like that:

import subprocesssubprocess.call(['./scriptshell.sh'])

Looks fine. I must try it. Thanks a lot


Regards
Adam

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


[web2py] Re: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-14 Thread User
I just tested this with a simple app using postgresql database and it seems 
that it doesn't quite work.

It appears it will leave the string data that exists in the string field 
alone in the database, however web2py will interpret it such that the first 
and last character are truncated.  For example:

"hello" -> "ell"
"something" -> "omthin"
"world" -> "orl"

As soon as you add another list item to the string, then web2py will 
truncate the original string's first and last characters in the database in 
addition to adding the new item.

Migration back from list:string to string will preserve whatever 
list:string data is there (in the web2py representation format).

"hello", "world" -> "|hello|world|"
"one", "two" -> "|one|two|"

Would it make sense for the migration process to handle this more 
gracefully?

On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:

> Does a migration from a 'string' field to a 'list:string' field preserve 
> string data that is already in the database and convert it to the format 
> required by list:string?
>

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