[web2py] Web2py - Babel

2015-11-03 Thread Mirek Zvolský
Uses somebody Web2py with Flask-Babel or with Babel ?
I think there is problem with Web2py translation system that the support 
for plural is poor because there are languages with 2 forms of plural. But 
maybe I misunderstand the translation system of Web2py ?

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

2015-11-03 Thread Gary Cowell
Web2py version:
>>> import gluon.widget
>>> print gluon.widget.ProgramVersion
Version 2.12.3-stable+timestamp.2015.08.19.00.18.03


When using bootstrap3_inline for forms, the checkbox lables are not 
correctly styled:




This is my form code:

form=SQLFORM.factory(
Field('SystemName',label='System Name', length=80, required=True, 
requires=IS_NOT_EMPTY()),
Field('Image',label='Base System', requires=IS_IN_SET(imageList,zero
='Choose Base System')),
Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,dbcccs.
v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',zero='Choose 
Customer')),
Field('publicsystem','boolean',label='Public', default='False'),
Field('customports','boolean',label='Custom Ports?', default='False'
),
Field('customportlist',label='Custom Port List', required=False, 
requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited port 
list, e.g. 5001,5050,9127")),
formstyle='bootstrap3_inline'
)


And this code looks suspicious in gluon/sqlhtml.py:

def formstyle_bootstrap3_inline_factory(col_label_size=3):
""" bootstrap 3 horizontal form layout

Note:
Experimental!
"""
def _inner(form, fields):
form.add_class('form-horizontal')
label_col_class = "col-sm-%d" % col_label_size
col_class = "col-sm-%d" % (12 - col_label_size)
offset_class = "col-sm-offset-%d" % col_label_size
parent = CAT()
for id, label, controls, help in fields:
# wrappers
_help = SPAN(help, _class='help-block')
# embed _help into _controls
_controls = DIV(controls, _help, _class=col_class)
if isinstance(controls, INPUT):
if controls['_type'] == 'submit':
controls.add_class('btn btn-primary')
_controls = DIV(controls, _class="%s %s" % (col_class, 
offset_class))
if controls['_type'] == 'button':
controls.add_class('btn btn-default')
elif controls['_type'] == 'file':
controls.add_class('input-file')
elif controls['_type'] in ('text', 'password'):
controls.add_class('form-control')
elif controls['_type'] == 'checkbox':
label['_for'] = None
label.insert(0, controls)
_controls = DIV(DIV(label, _help, _class="checkbox"),
_class="%s %s" % (offset_class, 
col_class))
label = ''
elif isinstance(controls, (SELECT, TEXTAREA)):
controls.add_class('form-control')

The checkbox control type is doing something odd with labels.




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


[web2py] Re: Web2py - Babel

2015-11-03 Thread 黄祥
pardon me, not sure, i follow what is your problem. in web2py scaffold 
welcome app, there is files in folder languages start with plural-*.py, i 
think you can add it in that file for example plural-en.py, and add the new 
words, that's not in that file.

best regards,
stifan

On Tuesday, November 3, 2015 at 4:42:44 PM UTC+7, Mirek Zvolský wrote:
>
> Uses somebody Web2py with Flask-Babel or with Babel ?
> I think there is problem with Web2py translation system that the support 
> for plural is poor because there are languages with 2 forms of plural. But 
> maybe I misunderstand the translation system of Web2py ?
>

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

2015-11-03 Thread Vinicius Assef
This can help you:
http://web2py.com/books/default/chapter/29/04/the-core#Pluralization-engine

--
Vinicius Assef




On 3 November 2015 at 07:42, Mirek Zvolský  wrote:
> Uses somebody Web2py with Flask-Babel or with Babel ?
> I think there is problem with Web2py translation system that the support for
> plural is poor because there are languages with 2 forms of plural. But maybe
> I misunderstand the translation system of Web2py ?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because 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: Has somebody used codenvy for web2py application deployment?

2015-11-03 Thread Gary Cowell
No, but could you not use pythonanywhere free app, and host mercurial (or, 
git, if you must) on bitbucket?

Small projects on bitbucket can have up to five users. 

On Monday, 2 November 2015 16:55:02 UTC, at wrote:
>
> Hi,
>
> I was looking for a place where I can deploy a database driven web2py 
> application free of cost. This small application is for personal use. I am 
> familiar with deployments of such applications on AWS, DigitalOcean, 
> pythonanywhere and other hosting services. But along-with hosting I was 
> looking for git repository integration so that one of my friend can also 
> collaborate in this project. Is codenvy the right thing for my needs?
>
> Thanks,
> AT
>

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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Massimiliano
Try this way to display your pdf:

def yourcontroller()
# generate pdf
. . .
import cStringIO
data = open(filename,"rb").read()
response.headers['Content-Type']='application/pdf'
return response.stream(cStringIO.StringIO(data))




On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian 
wrote:

> Hi,
> i am a newby to web2py and need some help dislaying label in my
> application.
>
> I’m using Latex and PSTricks to create my barcode label.pdf files.
> The problem is, everthing works ok on local Windows or Ubuntu but not from
> my Linux-VServer (WEbServer).
> The label.pdf is created but not displayed.
>
> This my sourccode after the place where i creating my label.pdf file:
> //
> This does not work on webserver (only in local Systems):
>  ...
> os.system('latex label.tex')
> time.sleep(0.1)
> if sys.platform == "win32":
>  os.system('dvips -o label-pics.ps label.dvi')
> os.system('ps2pdf awblabel-pics.ps label.pdf')
>os.startfile('label.pdf')
> else:
> # os.system('dvipdf label.dvi')
> os.system('dvips -o awblabel-pics.ps label.dvi')
> os.system('ps2pdf awblabel-pics.ps label.pdf')
>if sys.platform == "darwin": subprocess.call(['open',
> 'label.pdf'])
> else: subprocess.call(['xdg-open', 'label.pdf'])
> return dict(redirect(URL('labelapp', args=req_id)))
>
> //
> This works, however my SUBMIT Button does not get released:
>  ...
>  else:
> mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
> pdfdata = open(mypdffile,"rb").read()
> os.unlink(mypdffile)
> response.headers['Content-Type']='application/pdf'
> return pdfdata
> return dict(redirect(URL('labelapp', args=req_id)))
>
> //
>
> Do i have to use something like *PDFObject.js* or *PDF.js* or is there a
> better way to do it?
> Where can i find examples that use *PDFObject.js* or *PDF.js*?
> .
>
> I just can not find any good examples.
>
> As i said i am new to web programming and web2py.
>
>
> I think web2py is a cool product.
> Hope someone can 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.
>



-- 
Massimiliano

-- 
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: Should this work in Web2py

2015-11-03 Thread Anthony Smith
Ok thanks for the help, much appreciated by newbie trying to learn 

On Tuesday, 3 November 2015 02:09:28 UTC+11, Niphlod wrote:
>
> it works but it's a rather inefficient way. first() and last() will need 
> to fetch every record of that table 
>
> you'd better rewrite 
>
> task = db(db.stock_task.id).select().last()
>
> as
>
> task = db(db.stock_task.id>0).select(limitby=(0,1), orderby=~
> db.stock_task.id).first()
>
> etc etc etc
>
> to leverage the backend capabilities instead of fetching the entire table 
> and then discarding every row that is not the last one ...
>
> On Saturday, October 31, 2015 at 7:02:03 AM UTC+1, Anthony Smith wrote:
>>
>> Thanks for the input everyone , I did get it to successfully update using 
>> the following 
>>
>> def create_stock_task():
>> form = SQLFORM (db.stock_task).process()
>> if form.accepted:
>> task = db(db.stock_task.id).select().last()
>> pdays_row = db(db.product.withholding_period>0).select().last()
>> pdays =  pdays_row.withholding_period
>> esidays_row = db(db.product.ESI_withholding>0).select().last()
>> esidays = esidays_row.ESI_withholding
>> wdate_row = db(db.stock_task.completed_date>0).select().last()
>> wdate = wdate_row.completed_date
>> fdate = wdate + datetime.timedelta(days + pdays)
>> esidate = wdate + datetime.timedelta(days + esidays)
>> db(db.stock_task.id == task).update(withhold_until_date=fdate)
>> db(db.stock_task.id == 
>> task).update(ESI_withhold_until_date=esidate)
>>
>> On Wednesday, 28 October 2015 18:00:05 UTC+11, Anthony Smith wrote:
>>>
>>> added the following
>>>
>>> def create_stock_task():
>>> form = SQLFORM (db.stock_task).process()
>>> if form.accepted:
>>> task = db(db.stock_task.id).select().first()
>>> pdays_row = db(db.product.withholding_period>0).select().first()
>>> pdays =  pdays_row.withholding_period
>>> wdate_row = db(db.stock_task.completed_date>0).select().first()
>>> wdate = wdate_row.completed_date
>>> fdate = wdate + datetime.timedelta(days + pdays)
>>> ndate_row = 
>>> db(db.stock_task.withhold_until_date>0).select().first()
>>> ndate = ndate_row.withhold_until_date
>>> db(db.stock_task.id == task).update(ndate=fdate)
>>> session.flash="New Task Added"
>>> redirect(URL('stock_tasks'))
>>> return locals()
>>>
>>>
>>>  and now getting ('ndate')
>>>
>>> further would be great 
>>>
>>> thanks.
>>>
>>> On Monday, 26 October 2015 20:09:15 UTC+11, Niphlod wrote:

 an update operation NEEDS an update() call.

 given the records you want to update are defined by a condition, namely

 db.table.column_1 == somevalue

 and the update on column_2 resulting in all those records equal to 
 "somevalue_2", you need to write

 db(db.table.column_1 == somevalue).update(column_2 = somevalue_2)

  

 On Saturday, October 24, 2015 at 7:27:20 AM UTC+2, Anthony Smith wrote:
>
> what I want to is update the stock_task.withhold until date with the 
> result of db.product.withholding_
> period (int) + stock_task.completed date (date)
>
>

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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Karl Florian

Hi Massimiliano,
it works thank you!

However there are 2 things i do not like:

1) My PDF File is renamed to the same as my Controller function Name plus a 
number and *without the Extension .pdf*. 
Example:* printlanguages+cd123452*

2) After the *"return response.stream()"* my *submit button* that started 
the Output remains pressed until i refresh the url-page manually.

Is there a way to Redirect to the URL after the pdf file was displayed?

Do you or does anybody else have a solution for this?


Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:

> Try this way to display your pdf:
>
> def yourcontroller()
> # generate pdf 
> . . . 
> import cStringIO
> data = open(filename,"rb").read()
> response.headers['Content-Type']='application/pdf' 
> return response.stream(cStringIO.StringIO(data))  
>
>
>
>
> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  > wrote:
>
>> Hi,
>> i am a newby to web2py and need some help dislaying label in my 
>> application.
>>  
>> I’m using Latex and PSTricks to create my barcode label.pdf files. 
>> The problem is, everthing works ok on local Windows or Ubuntu but not 
>> from my Linux-VServer (WEbServer).
>> The label.pdf is created but not displayed.
>>
>> This my sourccode after the place where i creating my label.pdf file:
>> //
>> This does not work on webserver (only in local Systems):
>>  ...
>> os.system('latex label.tex')
>> time.sleep(0.1)
>> if sys.platform == "win32":
>>  os.system('dvips -o label-pics.ps label.dvi')
>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>os.startfile('label.pdf')
>> else:
>> # os.system('dvipdf label.dvi')
>> os.system('dvips -o awblabel-pics.ps label.dvi')
>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>if sys.platform == "darwin": subprocess.call(['open', 
>> 'label.pdf'])
>> else: subprocess.call(['xdg-open', 'label.pdf'])
>> return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //
>> This works, however my SUBMIT Button does not get released:
>>  ...
>>  else:
>> mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
>> pdfdata = open(mypdffile,"rb").read()
>> os.unlink(mypdffile)
>> response.headers['Content-Type']='application/pdf'
>> return pdfdata
>> return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //
>>
>> Do i have to use something like *PDFObject.js* or *PDF.js* or is there a 
>> better way to do it?
>> Where can i find examples that use *PDFObject.js* or *PDF.js*?
>> .
>>
>> I just can not find any good examples.
>>
>> As i said i am new to web programming and web2py.
>>
>>
>> I think web2py is a cool product.
>> Hope someone can 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Massimiliano
>

-- 
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: test for integer in form

2015-11-03 Thread Alex Glaros
import worked to elimitate error but requires logic doesn't take

db.auth_group.role.requires not(IS_INT_IN_RANGE(-sys.maxint -1, sys.maxint))

not sure how to structure the syntax in the try: statement.  
x=role(IS_INT_IN_RANGE(-sys.maxint 
-1, sys.maxint) ?

how about a requires clause that is some kind of lambda that requires any 
non-numeric?  Is that possible? db.auth_group.role.requires=role contains 
('a', 'b', 'c', etc)

I prefer a requires to a try: as it catches the error earlier and obviates 
housekeeping

-- 
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: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Richard Vézina
Also, let say you have delete a bunch of record and you want to keep a
sequential ID incrementation for some reason, nothing prevent you to update
your backend sequence start parameter and rewind to the last ID surrogate
number so next time you insert a record you will have consecutive ID...

Doc for manipulating sequence with postgresql :
http://www.postgresql.org/docs/9.1/static/sql-altersequence.html

You can also reset the sequence entirely if you want to start fresh for
with a testing database for instance you can even automate this in a
teardown process after each test run...

Richard

On Tue, Nov 3, 2015 at 2:14 PM, Richard Vézina 
wrote:

> I think Alex concern is about if he can reuse ID 1 which seems he deleted
> and now would reuse it for storing other information...
>
> If I am correct, this is possible as long as the ID 1 is effectively empty
> and if there is no history attach the record (though, this is not so a
> problem neither depending of how you use the historic data). So as long as
> you don't use web2py versioning feature you can do that safetly after you
> make it sure that ID 1 (for example) is effectively empty...
>
> db(db.auth_user.id == 1).insert(...)
> db.commit()
>
> From the command line in web2py shell... Or you may use an update form and
> pass to the controller the ID which will update an empty record with the ID
> 1 with the data you will input and submit...
>
> Richard
>
> On Tue, Nov 3, 2015 at 2:02 PM, Jim S  wrote:
>
>> If I understand your question properly, I think Record Versioning could
>> do it.
>>
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning
>>
>> If you 'deleted' auth_user.id == 1, all that happens then is that the
>> is_active field gets set to False.  You could then search for it and make
>> your updates as it didn't really get deleted from the DB.  Then just change
>> is_active back to True.
>>
>> -Jim
>>
>>
>> On Tuesday, November 3, 2015 at 12:25:07 PM UTC-6, Alex Glaros wrote:
>>>
>>> I'd lilke to reuse a primary key that has been deleted
>>>
>>> For example, I'd like to take deleted auth_user.id == 1, and change the
>>> first_name and other field data in it for reuse.
>>>
>>> Same for other tables, for example, db.Organization.id ==1, would like
>>> to replace old org name with "Department of Motor Vehicles"
>>>
>>> Those primary keys have been deleted and records are not accessible so I
>>> can't edit them.
>>>
>>> The only way I can think of doing it is to drop table and re-enter data
>>> in correct order.
>>>
>>> thanks,
>>>
>>> Alex Glaros
>>>
>> --
>> 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] Manage session.VARS best practices

2015-11-03 Thread Anthony
Yes, simply making the check for the session keys to see if cleanup is 
needed should add minimal overhead. Likewise, if the deleting itself is 
infrequent (or if it tends to occur when you have other session changes 
that need to be written to the file anyway), then there shouldn't be much 
additional impact of writing the updated session. On the other hand, if 
you're constantly deleting and re-adding the same session keys request 
after request, it might not be worth it.

Anthony

On Tuesday, November 3, 2015 at 2:28:08 PM UTC-5, Richard wrote:
>
> Thank you Anthony, I appreciate you input... I was concern about exactly 
> that, I mean keep clean up the session each request has a cost... I will 
> need to make a check, it would be logic that if the session keys to be are 
> not present in session that the only overhead should be the clean up 
> funciton call and the session keys check...
>
> Thanks again
>
> Richard
>
> On Tue, Nov 3, 2015 at 2:19 PM, Anthony wrote:
>
>> On Tuesday, November 3, 2015 at 2:04:21 PM UTC-5, Richard wrote:
>>>
>>> There is large amount of that data that why I have this concern...
>>>
>>
>> You might want to do some testing (i.e., checking response times and RAM 
>> usage) before bothering to manage session keys. Note, the session data for 
>> a given user is only loaded into RAM during the period of a given request 
>> (in between requests, it resides in the session file).
>>
>> If there is a large portion of the session that can safely be deleted at 
>> some point, feel free to do something like what you have suggested and just 
>> delete the relevant keys. One thing to keep in mind is that if the session 
>> doesn't change during a given request, web2py does not bother to write out 
>> to the session file, so if you do delete some keys, you will be prompted a 
>> file write during that request. The overhead of the extra file writes must 
>> therefore be balanced against the overhead of keeping the extra data in the 
>> session instead.
>>  
>>
>>>
>>> Is cleaning the sessions/* files delete data put in session?
>>>
>>
>> When you clean up session files, you are typically deleting files of 
>> sessions that have already expired (based on the Auth login expiration) 
>> and/or are presumed no longer to be active (based on the time since last 
>> modified). The entire file is deleted, so of course you lose all the data.
>>
>> 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.
>>
>
>

-- 
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] Manage session.VARS best practices

2015-11-03 Thread Anthony
I'm not sure there is any need to clean up individual sessions unless you 
are storing a large amount of data. On the other hand, you might want to 
clean up expired session files once in a while -- there is a script for 
that.

Anthony

On Tuesday, November 3, 2015 at 1:43:47 PM UTC-5, Richard wrote:
>
> Hello,
>
> Let say I put some data in session.var1 for reuse in case user want to 
> download the content of the page with the help of buttons for the purpose 
> which call the same function with one more prameter telling the controller 
> function which file format the user expect...
>
> So you can check if file format parameter is there and pass the 
> session.var1 to the sub funciton :
>
> if request.vars.file_format:
> export_to_file(session.var1)
> else:
> del(session.var1)  # Here I can't delete var1 from session in case a 
> new call is made to the controller for the first time...
>
> But, what to do with session.var1 in case the which will remain there if I 
> load any other app pages??
>
> Should I create a clean_up_session()?
>
> Something like this :
>
> def clean_up_session():
> if session.var1 and request.function != 'my_controller_func' and not 
> request.vars.file_format:
> del(session.var1)
>
> Which I would need to executed at every request (can't be put in model 
> file for that purpose)...
>
> But I am curious what is consider the best practices regarding session 
> variables ?
>
> Thanks
>
> Richard
>

-- 
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] Manage session.VARS best practices

2015-11-03 Thread Anthony
On Tuesday, November 3, 2015 at 2:04:21 PM UTC-5, Richard wrote:
>
> There is large amount of that data that why I have this concern...
>

You might want to do some testing (i.e., checking response times and RAM 
usage) before bothering to manage session keys. Note, the session data for 
a given user is only loaded into RAM during the period of a given request 
(in between requests, it resides in the session file).

If there is a large portion of the session that can safely be deleted at 
some point, feel free to do something like what you have suggested and just 
delete the relevant keys. One thing to keep in mind is that if the session 
doesn't change during a given request, web2py does not bother to write out 
to the session file, so if you do delete some keys, you will be prompted a 
file write during that request. The overhead of the extra file writes must 
therefore be balanced against the overhead of keeping the extra data in the 
session instead.
 

>
> Is cleaning the sessions/* files delete data put in session?
>

When you clean up session files, you are typically deleting files of 
sessions that have already expired (based on the Auth login expiration) 
and/or are presumed no longer to be active (based on the time since last 
modified). The entire file is deleted, so of course you lose all the data.

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: test for integer in form

2015-11-03 Thread Dave S


On Tuesday, November 3, 2015 at 8:46:57 AM UTC-8, Alex Glaros wrote:
>
> (1)  is there way to write it as a requires clause only for the 
> controllers that user's use?  E.g.:
>
> db.auth_group.role.requires = not IS_INT_IN_RANGE(-sys.maxint -1, sys.
> maxint)
>
> doesn't raise errors but doesn't work: db.auth_group.role.requires = not
>  IS_INT_IN_RANGE(0,100)
>
> (2) the sys syntax causes this error: 
>  global name 'sys' is not defined
>
> thanks Dave,
>
> Alex
>


Did you jmport sys?
 
/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: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Richard Vézina
I think Alex concern is about if he can reuse ID 1 which seems he deleted
and now would reuse it for storing other information...

If I am correct, this is possible as long as the ID 1 is effectively empty
and if there is no history attach the record (though, this is not so a
problem neither depending of how you use the historic data). So as long as
you don't use web2py versioning feature you can do that safetly after you
make it sure that ID 1 (for example) is effectively empty...

db(db.auth_user.id == 1).insert(...)
db.commit()

>From the command line in web2py shell... Or you may use an update form and
pass to the controller the ID which will update an empty record with the ID
1 with the data you will input and submit...

Richard

On Tue, Nov 3, 2015 at 2:02 PM, Jim S  wrote:

> If I understand your question properly, I think Record Versioning could do
> it.
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning
>
> If you 'deleted' auth_user.id == 1, all that happens then is that the
> is_active field gets set to False.  You could then search for it and make
> your updates as it didn't really get deleted from the DB.  Then just change
> is_active back to True.
>
> -Jim
>
>
> On Tuesday, November 3, 2015 at 12:25:07 PM UTC-6, Alex Glaros wrote:
>>
>> I'd lilke to reuse a primary key that has been deleted
>>
>> For example, I'd like to take deleted auth_user.id == 1, and change the
>> first_name and other field data in it for reuse.
>>
>> Same for other tables, for example, db.Organization.id ==1, would like
>> to replace old org name with "Department of Motor Vehicles"
>>
>> Those primary keys have been deleted and records are not accessible so I
>> can't edit them.
>>
>> The only way I can think of doing it is to drop table and re-enter data
>> in correct order.
>>
>> thanks,
>>
>> Alex Glaros
>>
> --
> 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: Way to query from a select object

2015-11-03 Thread Mark Billion
Yep.  Am using the same data over and over and over

On Tuesday, November 3, 2015 at 11:51:53 AM UTC-5, Anthony wrote:
>
> Assuming there is some reason you can't move the additional query 
> conditions to the database and you must do the filtering in Python (e.g., 
> the query is complex or you need to filter the same set of rows in multiple 
> ways), you can use the .find() method 
> 
>  
> of the Rows object:
>
> primary_residence_rows = all_rows.find(lambda r: r.primary_residence == 
> True)
>
> Anthony
>
> On Tuesday, November 3, 2015 at 8:53:49 AM UTC-5, Mark Billion wrote:
>>
>> This seems ugly:
>> foo = db(db.xxx.id==x.id).select()
>> for a in foo:
>> if a.primary_residence == True:
>> nine_b_count = 1
>> ..
>> Is there a way for me to select only the elements of foo that meet the 
>> secondary test.  Something like foo.select(a.primary_residence == True) #I 
>> know this is wrong
>>
>>

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


[web2py] Re: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Jim S
If I understand your question properly, I think Record Versioning could do 
it.

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning

If you 'deleted' auth_user.id == 1, all that happens then is that the 
is_active field gets set to False.  You could then search for it and make 
your updates as it didn't really get deleted from the DB.  Then just change 
is_active back to True.

-Jim


On Tuesday, November 3, 2015 at 12:25:07 PM UTC-6, Alex Glaros wrote:
>
> I'd lilke to reuse a primary key that has been deleted
>
> For example, I'd like to take deleted auth_user.id == 1, and change the 
> first_name and other field data in it for reuse.
>
> Same for other tables, for example, db.Organization.id ==1, would like to 
> replace old org name with "Department of Motor Vehicles"
>
> Those primary keys have been deleted and records are not accessible so I 
> can't edit them.
>
> The only way I can think of doing it is to drop table and re-enter data in 
> correct order.
>
> thanks,
>
> Alex Glaros
>

-- 
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: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Anthony

>
> db(db.auth_user.id == 1).insert(...)
>

The .insert() method applies to tables, not Set objects. It would be:

db.auth_user.insert(id=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/d/optout.


[web2py] is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Alex Glaros
I'd lilke to reuse a primary key that has been deleted

For example, I'd like to take deleted auth_user.id == 1, and change the 
first_name and other field data in it for reuse.

Same for other tables, for example, db.Organization.id ==1, would like to 
replace old org name with "Department of Motor Vehicles"

Those primary keys have been deleted and records are not accessible so I 
can't edit them.

The only way I can think of doing it is to drop table and re-enter data in 
correct order.

thanks,

Alex Glaros

-- 
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] Manage session.VARS best practices

2015-11-03 Thread Richard Vézina
There is large amount of that data that why I have this concern...

Is cleaning the sessions/* files delete data put in session?

Richard

On Tue, Nov 3, 2015 at 1:59 PM, Anthony  wrote:

> I'm not sure there is any need to clean up individual sessions unless you
> are storing a large amount of data. On the other hand, you might want to
> clean up expired session files once in a while -- there is a script for
> that.
>
> Anthony
>
>
> On Tuesday, November 3, 2015 at 1:43:47 PM UTC-5, Richard wrote:
>>
>> Hello,
>>
>> Let say I put some data in session.var1 for reuse in case user want to
>> download the content of the page with the help of buttons for the purpose
>> which call the same function with one more prameter telling the controller
>> function which file format the user expect...
>>
>> So you can check if file format parameter is there and pass the
>> session.var1 to the sub funciton :
>>
>> if request.vars.file_format:
>> export_to_file(session.var1)
>> else:
>> del(session.var1)  # Here I can't delete var1 from session in case a
>> new call is made to the controller for the first time...
>>
>> But, what to do with session.var1 in case the which will remain there if
>> I load any other app pages??
>>
>> Should I create a clean_up_session()?
>>
>> Something like this :
>>
>> def clean_up_session():
>> if session.var1 and request.function != 'my_controller_func' and not
>> request.vars.file_format:
>> del(session.var1)
>>
>> Which I would need to executed at every request (can't be put in model
>> file for that purpose)...
>>
>> But I am curious what is consider the best practices regarding session
>> variables ?
>>
>> Thanks
>>
>> Richard
>>
> --
> 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] Manage session.VARS best practices

2015-11-03 Thread Richard Vézina
Thank you Anthony, I appreciate you input... I was concern about exactly
that, I mean keep clean up the session each request has a cost... I will
need to make a check, it would be logic that if the session keys to be are
not present in session that the only overhead should be the clean up
funciton call and the session keys check...

Thanks again

Richard

On Tue, Nov 3, 2015 at 2:19 PM, Anthony  wrote:

> On Tuesday, November 3, 2015 at 2:04:21 PM UTC-5, Richard wrote:
>>
>> There is large amount of that data that why I have this concern...
>>
>
> You might want to do some testing (i.e., checking response times and RAM
> usage) before bothering to manage session keys. Note, the session data for
> a given user is only loaded into RAM during the period of a given request
> (in between requests, it resides in the session file).
>
> If there is a large portion of the session that can safely be deleted at
> some point, feel free to do something like what you have suggested and just
> delete the relevant keys. One thing to keep in mind is that if the session
> doesn't change during a given request, web2py does not bother to write out
> to the session file, so if you do delete some keys, you will be prompted a
> file write during that request. The overhead of the extra file writes must
> therefore be balanced against the overhead of keeping the extra data in the
> session instead.
>
>
>>
>> Is cleaning the sessions/* files delete data put in session?
>>
>
> When you clean up session files, you are typically deleting files of
> sessions that have already expired (based on the Auth login expiration)
> and/or are presumed no longer to be active (based on the time since last
> modified). The entire file is deleted, so of course you lose all the data.
>
> 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.
>

-- 
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] Manage session.VARS best practices

2015-11-03 Thread Richard
Hello,

Let say I put some data in session.var1 for reuse in case user want to 
download the content of the page with the help of buttons for the purpose 
which call the same function with one more prameter telling the controller 
function which file format the user expect...

So you can check if file format parameter is there and pass the 
session.var1 to the sub funciton :

if request.vars.file_format:
export_to_file(session.var1)
else:
del(session.var1)  # Here I can't delete var1 from session in case a 
new call is made to the controller for the first time...

But, what to do with session.var1 in case the which will remain there if I 
load any other app pages??

Should I create a clean_up_session()?

Something like this :

def clean_up_session():
if session.var1 and request.function != 'my_controller_func' and not 
request.vars.file_format:
del(session.var1)

Which I would need to executed at every request (can't be put in model file 
for that purpose)...

But I am curious what is consider the best practices regarding session 
variables ?

Thanks

Richard

-- 
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: test for integer in form

2015-11-03 Thread Alex Glaros
This is wrong:

how about a requires clause that is some kind of lambda that requires any 
non-numeric?  Is that possible?how about a requires clause that is some 
kind of lambda that requires any non-numeric?  Is that possible? db.
auth_group.role.requires=role contains ('a', 'b', 'c', etc)

because doesn't handle foreign languages. 

So if can't use a requires clause, then am stuck with try, which works...

-- 
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] Manage session.VARS best practices

2015-11-03 Thread Richard Vézina
The data are not the same or I can make this assomption since they can
change each time the controller function it calls... The controller take
parameters into vars and make db query and render a resulting table...
There is numerous differents parameters and the requested data are by
nature changing or say differently the interess about these data shift over
new available data...

Am I right in my understanding that session.keys get write into session
file only once when it get define for a given request and in the next
request if the session.key1 is still there (unchanged) it won't be re-write
to session file? At start I would just avoid that the session populated
data were not transported all around the app on each request for nothing...
If they get write once when they get created/updated and that there is no
overhead at having it there, I can leave with them, though if they stays in
memory (ram) it can start to be an issue if many user start to generate
these reports...

Thanks

Richard

On Tue, Nov 3, 2015 at 2:36 PM, Anthony  wrote:

> Yes, simply making the check for the session keys to see if cleanup is
> needed should add minimal overhead. Likewise, if the deleting itself is
> infrequent (or if it tends to occur when you have other session changes
> that need to be written to the file anyway), then there shouldn't be much
> additional impact of writing the updated session. On the other hand, if
> you're constantly deleting and re-adding the same session keys request
> after request, it might not be worth it.
>
> Anthony
>
> On Tuesday, November 3, 2015 at 2:28:08 PM UTC-5, Richard wrote:
>>
>> Thank you Anthony, I appreciate you input... I was concern about exactly
>> that, I mean keep clean up the session each request has a cost... I will
>> need to make a check, it would be logic that if the session keys to be are
>> not present in session that the only overhead should be the clean up
>> funciton call and the session keys check...
>>
>> Thanks again
>>
>> Richard
>>
>> On Tue, Nov 3, 2015 at 2:19 PM, Anthony wrote:
>>
>>> On Tuesday, November 3, 2015 at 2:04:21 PM UTC-5, Richard wrote:

 There is large amount of that data that why I have this concern...

>>>
>>> You might want to do some testing (i.e., checking response times and RAM
>>> usage) before bothering to manage session keys. Note, the session data for
>>> a given user is only loaded into RAM during the period of a given request
>>> (in between requests, it resides in the session file).
>>>
>>> If there is a large portion of the session that can safely be deleted at
>>> some point, feel free to do something like what you have suggested and just
>>> delete the relevant keys. One thing to keep in mind is that if the session
>>> doesn't change during a given request, web2py does not bother to write out
>>> to the session file, so if you do delete some keys, you will be prompted a
>>> file write during that request. The overhead of the extra file writes must
>>> therefore be balanced against the overhead of keeping the extra data in the
>>> session instead.
>>>
>>>

 Is cleaning the sessions/* files delete data put in session?

>>>
>>> When you clean up session files, you are typically deleting files of
>>> sessions that have already expired (based on the Auth login expiration)
>>> and/or are presumed no longer to be active (based on the time since last
>>> modified). The entire file is deleted, so of course you lose all the data.
>>>
>>> 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.
>>>
>>
>> --
> 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 

Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Dave S


On Tuesday, November 3, 2015 at 1:26:26 PM UTC-8, Karl Florian wrote:
>
> I think i found my own solution.
> Wo ever has the same Problem, try this!!!
>
> import webbrowser 
> webbrowser.open_new(r'file://C:\path\to\file.pdf')
>
>
> It works just the way i Need it.
>
>

I'm glad it works for you, but it won't work on a lot of systems (Linux 
systems usually don't know what "C:" means, and their slashes are forward 
leaning).

You might look at using response.stream, which has an option for setting a 
filename (sets the header field "Content-Disposition"), and the browser 
should send that to a sensible place, like the Downloads directory.



/dps

 

>
>
>
> Am Dienstag, 3. November 2015 16:38:06 UTC+1 schrieb Karl Florian:
>
>>
>> Hi Massimiliano,
>> it works thank you!
>>
>> However there are 2 things i do not like:
>>
>> 1) My PDF File is renamed to the same as my Controller function Name plus 
>> a number and *without the Extension .pdf*. 
>> Example:* printlanguages+cd123452*
>>
>> 2) After the *"return response.stream()"* my *submit button* that 
>> started the Output remains pressed until i refresh the url-page manually.
>>
>> Is there a way to Redirect to the URL after the pdf file was displayed?
>>
>> Do you or does anybody else have a solution for this?
>>
>>
>> Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:
>>
>>> Try this way to display your pdf:
>>>
>>> def yourcontroller()
>>> # generate pdf 
>>> . . . 
>>> import cStringIO
>>> data = open(filename,"rb").read()
>>> response.headers['Content-Type']='application/pdf' 
>>> return response.stream(cStringIO.StringIO(data))  
>>>
>>>
>>>
>>>
>>> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  
>>> wrote:
>>>
 Hi,
 i am a newby to web2py and need some help dislaying label in my 
 application.
  
 I’m using Latex and PSTricks to create my barcode label.pdf files. 
 The problem is, everthing works ok on local Windows or Ubuntu but not 
 from my Linux-VServer (WEbServer).
 The label.pdf is created but not displayed.

 This my sourccode after the place where i creating my label.pdf file:
 //
 This does not work on webserver (only in local Systems):
  ...
 os.system('latex label.tex')
 time.sleep(0.1)
 if sys.platform == "win32":
  os.system('dvips -o label-pics.ps label.dvi')
 os.system('ps2pdf awblabel-pics.ps label.pdf')
os.startfile('label.pdf')
 else:
 # os.system('dvipdf label.dvi')
 os.system('dvips -o awblabel-pics.ps label.dvi')
 os.system('ps2pdf awblabel-pics.ps label.pdf')
if sys.platform == "darwin": subprocess.call(['open', 
 'label.pdf'])
 else: subprocess.call(['xdg-open', 'label.pdf'])
 return dict(redirect(URL('labelapp', args=req_id)))

 //
 This works, however my SUBMIT Button does not get released:
  ...
  else:
 mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
 pdfdata = open(mypdffile,"rb").read()
 os.unlink(mypdffile)
 response.headers['Content-Type']='application/pdf'
 return pdfdata
 return dict(redirect(URL('labelapp', args=req_id)))

 //

 Do i have to use something like *PDFObject.js* or *PDF.js* or is there 
 a better way to do it?
 Where can i find examples that use *PDFObject.js* or *PDF.js*?
 .

 I just can not find any good examples.

 As i said i am new to web programming and web2py.


 I think web2py is a cool product.
 Hope someone can 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>> -- 
>>> Massimiliano
>>>
>>

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

Re: [web2py] Manage session.VARS best practices

2015-11-03 Thread Anthony
On Tuesday, November 3, 2015 at 5:12:32 PM UTC-5, Richard wrote:
>
> Thank you for clarification I really appreciate...
>
> Also about previous posted kind of pseudo code above this work better in 
> case var1 is not yet defined :
>
> elif 'var1' in session:
> del(session.var1)
>

Sure, or just:

session.pop('var1', None)

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] Manage session.VARS best practices

2015-11-03 Thread Richard Vézina
Thank you for clarification I really appreciate...

Also about previous posted kind of pseudo code above this work better in
case var1 is not yet defined :

elif 'var1' in session:
del(session.var1)

On Tue, Nov 3, 2015 at 4:41 PM, Anthony  wrote:

> Am I right in my understanding that session.keys get write into session
>> file only once when it get define for a given request and in the next
>> request if the session.key1 is still there (unchanged) it won't be re-write
>> to session file?
>>
>
> Writes to the session file are not granular -- it's all or nothing. If the
> session changes at all during a request, then the existing session file is
> completely overwritten with the updated version of the session. However, as
> long as the session doesn't change at all during a request, then no write
> is performed. If you have a large session and delete a single key, you will
> prompt a write of the entire remaining session to the file.
>
> 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.
>

-- 
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: virtual fields and lambda functions

2015-11-03 Thread Pierre
thanks Anthony


Le lundi 2 novembre 2015 19:35:27 UTC+1, Anthony a écrit :
>
> It's row.tablename.fieldname, and yes, in virtual field functions, you 
> must use both the tablename and fieldname (same as when a Row comes from a 
> join of multiple tables).
>
> Anthony
>
> On Monday, November 2, 2015 at 12:51:25 PM UTC-5, Pierre wrote:
>>
>> def func(row):
>> compute something
>> return result
>>
>> func doesn't understand row.fieldname
>> but it seems to understand row.databaseName.fieldname
>>
>> Is this last expression in a function correct ?
>>
>>
>> Le lundi 2 novembre 2015 17:42:40 UTC+1, Anthony a écrit :
>>>
>>> No. Please show your code.
>>>
>>> On Monday, November 2, 2015 at 10:58:24 AM UTC-5, Pierre wrote:

 Hi everyone,

 I try to combine virtual fields with a normal function (not lambda)  
 but it doesn't seem to work

 Is it mandatory to use lambda functions with virtual fields / virtual 
 method fields  ?



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


Re: [web2py] Re: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Alex Glaros
it worked!  wow... thanks guys!

Alex

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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Karl Florian
I think i found my own solution.
Wo ever has the same Problem, try this!!!

import webbrowser 
webbrowser.open_new(r'file://C:\path\to\file.pdf')


It works just the way i Need it.




Am Dienstag, 3. November 2015 16:38:06 UTC+1 schrieb Karl Florian:

>
> Hi Massimiliano,
> it works thank you!
>
> However there are 2 things i do not like:
>
> 1) My PDF File is renamed to the same as my Controller function Name plus 
> a number and *without the Extension .pdf*. 
> Example:* printlanguages+cd123452*
>
> 2) After the *"return response.stream()"* my *submit button* that started 
> the Output remains pressed until i refresh the url-page manually.
>
> Is there a way to Redirect to the URL after the pdf file was displayed?
>
> Do you or does anybody else have a solution for this?
>
>
> Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:
>
>> Try this way to display your pdf:
>>
>> def yourcontroller()
>> # generate pdf 
>> . . . 
>> import cStringIO
>> data = open(filename,"rb").read()
>> response.headers['Content-Type']='application/pdf' 
>> return response.stream(cStringIO.StringIO(data))  
>>
>>
>>
>>
>> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  
>> wrote:
>>
>>> Hi,
>>> i am a newby to web2py and need some help dislaying label in my 
>>> application.
>>>  
>>> I’m using Latex and PSTricks to create my barcode label.pdf files. 
>>> The problem is, everthing works ok on local Windows or Ubuntu but not 
>>> from my Linux-VServer (WEbServer).
>>> The label.pdf is created but not displayed.
>>>
>>> This my sourccode after the place where i creating my label.pdf file:
>>> //
>>> This does not work on webserver (only in local Systems):
>>>  ...
>>> os.system('latex label.tex')
>>> time.sleep(0.1)
>>> if sys.platform == "win32":
>>>  os.system('dvips -o label-pics.ps label.dvi')
>>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>>os.startfile('label.pdf')
>>> else:
>>> # os.system('dvipdf label.dvi')
>>> os.system('dvips -o awblabel-pics.ps label.dvi')
>>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>>if sys.platform == "darwin": subprocess.call(['open', 
>>> 'label.pdf'])
>>> else: subprocess.call(['xdg-open', 'label.pdf'])
>>> return dict(redirect(URL('labelapp', args=req_id)))
>>>
>>> //
>>> This works, however my SUBMIT Button does not get released:
>>>  ...
>>>  else:
>>> mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
>>> pdfdata = open(mypdffile,"rb").read()
>>> os.unlink(mypdffile)
>>> response.headers['Content-Type']='application/pdf'
>>> return pdfdata
>>> return dict(redirect(URL('labelapp', args=req_id)))
>>>
>>> //
>>>
>>> Do i have to use something like *PDFObject.js* or *PDF.js* or is there 
>>> a better way to do it?
>>> Where can i find examples that use *PDFObject.js* or *PDF.js*?
>>> .
>>>
>>> I just can not find any good examples.
>>>
>>> As i said i am new to web programming and web2py.
>>>
>>>
>>> I think web2py is a cool product.
>>> Hope someone can 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Massimiliano
>>
>

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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Dave S


On Tuesday, November 3, 2015 at 3:30:59 PM UTC-8, Karl Florian wrote:
>
> No it didn't work on the web.
> local Linux and Windows worked fine.
> *I am using str(os.path.join(request.folder, 'tex', 'languages.tex')) to 
> set the path to my files.*
>
> I am using Massimiliano's code to start my pdf's.
> But i still have the 2 Problems i mentioned before.
>

I'm not sure about the button problem, but response.stream's filename 
parameter should help with the ugly name.  


 

>
> Am Dienstag, 3. November 2015 23:31:07 UTC+1 schrieb Dave S:
>
>>
>>
>> On Tuesday, November 3, 2015 at 1:26:26 PM UTC-8, Karl Florian wrote:
>>>
>>> I think i found my own solution.
>>> Wo ever has the same Problem, try this!!!
>>>
>>> import webbrowser 
>>> webbrowser.open_new(r'file://C:\path\to\file.pdf')
>>>
>>>
>>> It works just the way i Need it.
>>>
>>>
>>
>> I'm glad it works for you, but it won't work on a lot of systems (Linux 
>> systems usually don't know what "C:" means, and their slashes are forward 
>> leaning).
>>
>> You might look at using response.stream, 
>>
>
[sorry, careless reading on the first pass]
 

> which has an option for setting a filename (sets the header field 
>> "Content-Disposition"), and the browser should send that to a sensible 
>> place, like the Downloads directory.
>>
>> > http://web2py.com/books/default/chapter/29/04/the-core?search=content-type#response
>> >
>>
>> /dps
>>
>>  
>>
>>>
>>>
>>>
>>> Am Dienstag, 3. November 2015 16:38:06 UTC+1 schrieb Karl Florian:
>>>

 Hi Massimiliano,
 it works thank you!

 However there are 2 things i do not like:

 1) My PDF File is renamed to the same as my Controller function Name 
 plus a number and *without the Extension .pdf*. 
 Example:* printlanguages+cd123452*

 2) After the *"return response.stream()"* my *submit button* that 
 started the Output remains pressed until i refresh the url-page manually.

 Is there a way to Redirect to the URL after the pdf file was displayed?

 Do you or does anybody else have a solution for this?


 Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:

> Try this way to display your pdf:
>
> def yourcontroller()
> # generate pdf 
> . . . 
> import cStringIO
> data = open(filename,"rb").read()
> response.headers['Content-Type']='application/pdf' 
> return response.stream(cStringIO.StringIO(data))  
>
>
>
>
> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  
> wrote:
>
>> Hi,
>> i am a newby to web2py and need some help dislaying label in my 
>> application.
>>  
>> I’m using Latex and PSTricks to create my barcode label.pdf files. 
>> The problem is, everthing works ok on local Windows or Ubuntu but not 
>> from my Linux-VServer (WEbServer).
>> The label.pdf is created but not displayed.
>>
>> This my sourccode after the place where i creating my label.pdf file:
>> //
>> This does not work on webserver (only in local Systems):
>>  ...
>> os.system('latex label.tex')
>> time.sleep(0.1)
>> if sys.platform == "win32":
>>  os.system('dvips -o label-pics.ps label.dvi')
>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>os.startfile('label.pdf')
>> else:
>> # os.system('dvipdf label.dvi')
>> os.system('dvips -o awblabel-pics.ps label.dvi')
>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>if sys.platform == "darwin": subprocess.call(['open', 
>> 'label.pdf'])
>> else: subprocess.call(['xdg-open', 'label.pdf'])
>> return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //
>> This works, however my SUBMIT Button does not get released:
>>  ...
>>  else:
>> mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
>> pdfdata = open(mypdffile,"rb").read()
>> os.unlink(mypdffile)
>> response.headers['Content-Type']='application/pdf'
>> return pdfdata
>> return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //
>>
>> Do i have to use something like *PDFObject.js* or *PDF.js* or is 
>> there a better way to do it?
>> Where can i find examples that use *PDFObject.js* or *PDF.js*?
>> .
>>
>> I just can not find any good examples.
>>
>> As i said i am new to web programming and web2py.
>>
>>
>> I think web2py is a cool product.
>> Hope someone can help.
>>
>>  
/dps

-- 
Resources:
- 

[web2py] Re: list:reference does not apply notnull=True

2015-11-03 Thread 黄祥
just confirmation :
is this right (the example : multiple = (1, x) ) ?
e.g. when try to use x in above example it return an error NameError: global 
name 'x' is not defined
db.define_table('test0', 
Field('test1', 'list:reference test1'),
format = '%(test1)s')

db.test0.test1.requires = IS_IN_DB(db(), db.test1.id, db.test1._format, 
multiple = (1, db.test1.id) )

thanks and best regards,
stifan

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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-03 Thread Karl Florian
No it didn't work on the web.
local Linux and Windows worked fine.
*I am using str(os.path.join(request.folder, 'tex', 'languages.tex')) to 
set the path to my files.*

I am using Massimiliano's code to start my pdf's.
But i still have the 2 Problems i mentioned before.


Am Dienstag, 3. November 2015 23:31:07 UTC+1 schrieb Dave S:

>
>
> On Tuesday, November 3, 2015 at 1:26:26 PM UTC-8, Karl Florian wrote:
>>
>> I think i found my own solution.
>> Wo ever has the same Problem, try this!!!
>>
>> import webbrowser 
>> webbrowser.open_new(r'file://C:\path\to\file.pdf')
>>
>>
>> It works just the way i Need it.
>>
>>
>
> I'm glad it works for you, but it won't work on a lot of systems (Linux 
> systems usually don't know what "C:" means, and their slashes are forward 
> leaning).
>
> You might look at using response.stream, which has an option for setting a 
> filename (sets the header field "Content-Disposition"), and the browser 
> should send that to a sensible place, like the Downloads directory.
>
>  http://web2py.com/books/default/chapter/29/04/the-core?search=content-type#response
> >
>
> /dps
>
>  
>
>>
>>
>>
>> Am Dienstag, 3. November 2015 16:38:06 UTC+1 schrieb Karl Florian:
>>
>>>
>>> Hi Massimiliano,
>>> it works thank you!
>>>
>>> However there are 2 things i do not like:
>>>
>>> 1) My PDF File is renamed to the same as my Controller function Name 
>>> plus a number and *without the Extension .pdf*. 
>>> Example:* printlanguages+cd123452*
>>>
>>> 2) After the *"return response.stream()"* my *submit button* that 
>>> started the Output remains pressed until i refresh the url-page manually.
>>>
>>> Is there a way to Redirect to the URL after the pdf file was displayed?
>>>
>>> Do you or does anybody else have a solution for this?
>>>
>>>
>>> Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:
>>>
 Try this way to display your pdf:

 def yourcontroller()
 # generate pdf 
 . . . 
 import cStringIO
 data = open(filename,"rb").read()
 response.headers['Content-Type']='application/pdf' 
 return response.stream(cStringIO.StringIO(data))  




 On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  
 wrote:

> Hi,
> i am a newby to web2py and need some help dislaying label in my 
> application.
>  
> I’m using Latex and PSTricks to create my barcode label.pdf files. 
> The problem is, everthing works ok on local Windows or Ubuntu but not 
> from my Linux-VServer (WEbServer).
> The label.pdf is created but not displayed.
>
> This my sourccode after the place where i creating my label.pdf file:
> //
> This does not work on webserver (only in local Systems):
>  ...
> os.system('latex label.tex')
> time.sleep(0.1)
> if sys.platform == "win32":
>  os.system('dvips -o label-pics.ps label.dvi')
> os.system('ps2pdf awblabel-pics.ps label.pdf')
>os.startfile('label.pdf')
> else:
> # os.system('dvipdf label.dvi')
> os.system('dvips -o awblabel-pics.ps label.dvi')
> os.system('ps2pdf awblabel-pics.ps label.pdf')
>if sys.platform == "darwin": subprocess.call(['open', 
> 'label.pdf'])
> else: subprocess.call(['xdg-open', 'label.pdf'])
> return dict(redirect(URL('labelapp', args=req_id)))
>
> //
> This works, however my SUBMIT Button does not get released:
>  ...
>  else:
> mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
> pdfdata = open(mypdffile,"rb").read()
> os.unlink(mypdffile)
> response.headers['Content-Type']='application/pdf'
> return pdfdata
> return dict(redirect(URL('labelapp', args=req_id)))
>
> //
>
> Do i have to use something like *PDFObject.js* or *PDF.js* or is 
> there a better way to do it?
> Where can i find examples that use *PDFObject.js* or *PDF.js*?
> .
>
> I just can not find any good examples.
>
> As i said i am new to web programming and web2py.
>
>
> I think web2py is a cool product.
> Hope someone can 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 

[web2py] Re: list:reference does not apply notnull=True

2015-11-03 Thread 黄祥
thank you so much for detail explanation, Anthony.
what i want to achieve is maximum number of allowed values same like total 
counted record that store in reference table
e.g.
count_test1 = db(db.test1.id > 0).count()

db.define_table('test0', 
Field('test1', 'list:reference test1'),
format = '%(test1)s')

db.test0.test1.requires = IS_IN_DB(db(), db.test1.id, db.test1._format, 
multiple = (1, count_test1) )

thanks and best regards,
stifan


On Wednesday, November 4, 2015 at 9:49:34 AM UTC+7, Anthony wrote:
>
> multiple = (1, db.test1.id)
>
> The second value of the tuple should be an integer representing the 
> maximum number of allowed values. It cannot be a Field object, and I'm not 
> sure what you are trying to achieve with that.
>
> Anthony
>
> On Tuesday, November 3, 2015 at 7:59:07 PM UTC-5, 黄祥 wrote:
>>
>> just confirmation :
>> is this right (the example : multiple = (1, x) ) ?
>> e.g. when try to use x in above example it return an error NameError: global 
>> name 'x' is not defined
>> db.define_table('test0', 
>> Field('test1', 'list:reference test1'),
>> format = '%(test1)s')
>>
>> db.test0.test1.requires = IS_IN_DB(db(), db.test1.id, db.test1._format, 
>> multiple = (1, db.test1.id) )
>>
>> thanks and best regards,
>> stifan
>>
>

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


[web2py] Re: list:reference does not apply notnull=True

2015-11-03 Thread Anthony
multiple = (1, db.test1.id)

The second value of the tuple should be an integer representing the maximum 
number of allowed values. It cannot be a Field object, and I'm not sure 
what you are trying to achieve with that.

Anthony

On Tuesday, November 3, 2015 at 7:59:07 PM UTC-5, 黄祥 wrote:
>
> just confirmation :
> is this right (the example : multiple = (1, x) ) ?
> e.g. when try to use x in above example it return an error NameError: global 
> name 'x' is not defined
> db.define_table('test0', 
> Field('test1', 'list:reference test1'),
> format = '%(test1)s')
>
> db.test0.test1.requires = IS_IN_DB(db(), db.test1.id, db.test1._format, 
> multiple = (1, db.test1.id) )
>
> thanks and best regards,
> stifan
>

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


Re: [web2py] Re: is there any way to resurrect a past deleted primary key?

2015-11-03 Thread Richard Vézina
Oups!

On Tue, Nov 3, 2015 at 3:15 PM, Alex Glaros  wrote:

> it worked!  wow... thanks guys!
>
> Alex
>
> --
> 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] Manage session.VARS best practices

2015-11-03 Thread Anthony

>
> Am I right in my understanding that session.keys get write into session 
> file only once when it get define for a given request and in the next 
> request if the session.key1 is still there (unchanged) it won't be re-write 
> to session file?
>

Writes to the session file are not granular -- it's all or nothing. If the 
session changes at all during a request, then the existing session file is 
completely overwritten with the updated version of the session. However, as 
long as the session doesn't change at all during a request, then no write 
is performed. If you have a large session and delete a single key, you will 
prompt a write of the entire remaining session to the file.

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] bootstrap3 formstyle checkboxes

2015-11-03 Thread Gary Cowell
That the labels for boolean fields are consistent in appearance with the 
labels for other classes of field.

So, emboldened and on the left. 

On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:
>
> What is the expected behavior?
>
> On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell  > wrote:
>
>> Web2py version:
>> >>> import gluon.widget
>> >>> print gluon.widget.ProgramVersion
>> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>>
>>
>> When using bootstrap3_inline for forms, the checkbox lables are not 
>> correctly styled:
>>
>>
>>
>>
>> This is my form code:
>>
>> form=SQLFORM.factory(
>> Field('SystemName',label='System Name', length=80, required=True, 
>> requires=IS_NOT_EMPTY()),
>> Field('Image',label='Base System', requires=IS_IN_SET(imageList,
>> zero='Choose Base System')),
>> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
>> dbcccs.v_clients.cc_customer_id,'%(cc_name)s 
>> (%(cc_customer_id)s)',zero='Choose 
>> Customer')),
>> Field('publicsystem','boolean',label='Public', default='False'),
>> Field('customports','boolean',label='Custom Ports?', default=
>> 'False'),
>> Field('customportlist',label='Custom Port List', required=False, 
>> requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited port 
>> list, e.g. 5001,5050,9127")),
>> formstyle='bootstrap3_inline'
>> )
>>
>>
>> And this code looks suspicious in gluon/sqlhtml.py:
>>
>> def formstyle_bootstrap3_inline_factory(col_label_size=3):
>> """ bootstrap 3 horizontal form layout
>>
>> Note:
>> Experimental!
>> """
>> def _inner(form, fields):
>> form.add_class('form-horizontal')
>> label_col_class = "col-sm-%d" % col_label_size
>> col_class = "col-sm-%d" % (12 - col_label_size)
>> offset_class = "col-sm-offset-%d" % col_label_size
>> parent = CAT()
>> for id, label, controls, help in fields:
>> # wrappers
>> _help = SPAN(help, _class='help-block')
>> # embed _help into _controls
>> _controls = DIV(controls, _help, _class=col_class)
>> if isinstance(controls, INPUT):
>> if controls['_type'] == 'submit':
>> controls.add_class('btn btn-primary')
>> _controls = DIV(controls, _class="%s %s" % (col_class
>> , offset_class))
>> if controls['_type'] == 'button':
>> controls.add_class('btn btn-default')
>> elif controls['_type'] == 'file':
>> controls.add_class('input-file')
>> elif controls['_type'] in ('text', 'password'):
>> controls.add_class('form-control')
>> elif controls['_type'] == 'checkbox':
>> label['_for'] = None
>> label.insert(0, controls)
>> _controls = DIV(DIV(label, _help, _class="checkbox"),
>> _class="%s %s" % (offset_class, 
>> col_class))
>> label = ''
>> elif isinstance(controls, (SELECT, TEXTAREA)):
>> controls.add_class('form-control')
>>
>> The checkbox control type is doing something odd with labels.
>>
>>
>>
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Way to query from a select object

2015-11-03 Thread Massimiliano
What about?

foo = db((db.xxx.id==x.id) & (db.xxx.primary_residence == True)).select()

On Tue, Nov 3, 2015 at 2:53 PM, Mark Billion  wrote:

> This seems ugly:
> foo = db(db.xxx.id==x.id).select()
> for a in foo:
> if a.primary_residence == True:
> nine_b_count = 1
> ..
> Is there a way for me to select only the elements of foo that meet the
> secondary test.  Something like foo.select(a.primary_residence == True) #I
> know this is 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.
>



-- 
Massimiliano

-- 
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] bootstrap3 formstyle checkboxes

2015-11-03 Thread Richard Vézina
What is the expected behavior?

On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell  wrote:

> Web2py version:
> >>> import gluon.widget
> >>> print gluon.widget.ProgramVersion
> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>
>
> When using bootstrap3_inline for forms, the checkbox lables are not
> correctly styled:
>
>
>
>
> This is my form code:
>
> form=SQLFORM.factory(
> Field('SystemName',label='System Name', length=80, required=True,
> requires=IS_NOT_EMPTY()),
> Field('Image',label='Base System', requires=IS_IN_SET(imageList,
> zero='Choose Base System')),
> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,dbcccs
> .v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',zero='Choose
> Customer')),
> Field('publicsystem','boolean',label='Public', default='False'),
> Field('customports','boolean',label='Custom Ports?', default=
> 'False'),
> Field('customportlist',label='Custom Port List', required=False,
> requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited port
> list, e.g. 5001,5050,9127")),
> formstyle='bootstrap3_inline'
> )
>
>
> And this code looks suspicious in gluon/sqlhtml.py:
>
> def formstyle_bootstrap3_inline_factory(col_label_size=3):
> """ bootstrap 3 horizontal form layout
>
> Note:
> Experimental!
> """
> def _inner(form, fields):
> form.add_class('form-horizontal')
> label_col_class = "col-sm-%d" % col_label_size
> col_class = "col-sm-%d" % (12 - col_label_size)
> offset_class = "col-sm-offset-%d" % col_label_size
> parent = CAT()
> for id, label, controls, help in fields:
> # wrappers
> _help = SPAN(help, _class='help-block')
> # embed _help into _controls
> _controls = DIV(controls, _help, _class=col_class)
> if isinstance(controls, INPUT):
> if controls['_type'] == 'submit':
> controls.add_class('btn btn-primary')
> _controls = DIV(controls, _class="%s %s" % (col_class,
> offset_class))
> if controls['_type'] == 'button':
> controls.add_class('btn btn-default')
> elif controls['_type'] == 'file':
> controls.add_class('input-file')
> elif controls['_type'] in ('text', 'password'):
> controls.add_class('form-control')
> elif controls['_type'] == 'checkbox':
> label['_for'] = None
> label.insert(0, controls)
> _controls = DIV(DIV(label, _help, _class="checkbox"),
> _class="%s %s" % (offset_class,
> col_class))
> label = ''
> elif isinstance(controls, (SELECT, TEXTAREA)):
> controls.add_class('form-control')
>
> The checkbox control type is doing something odd with labels.
>
>
>
>
> --
> 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: Submissão Python Brasil 11

2015-11-03 Thread Matheus Cardoso
5K? Eu achei que tinha isso no mundo. :P Eu sempre achei que, no Brasil, o 
web2py é um framework de nicho. E esse nicho somos...Nós. :) O que eu vejo 
é a predominância da dicotomia Flask vs Django (um flameware em cada 
esquina), com o bottle e o pyramid aparecendo uma vez ou outra - e nada do 
web2py. E eu acho que a cara da comunidade brazuca hoje é o que o Vinicius 
falou: muita gente usa, mas estão "incubando" o web2py nos seus projetos 
privados (tipo eu ~~). Tem um canal no slack da python brasil do web2py. É 
um canal fantasma, infelizmente. E sobre a submissão, está foda viajar 
esses tempos. 

On Monday, November 2, 2015 at 10:17:06 AM UTC-3, Ovidio Marinho wrote:
>
>
> Bom Dia Senhores,
>
> Acho que no brasil hoje temos mais de 5 mil usuarios do framework Web2py, 
> não tenho isso preciso , mas seria uma boa ideia, levantar e publicar, que 
> seja menos esta conta, não nos envergonharia ficar de fora de uma Python 
> Brasil, sendo o framework que está entre os cinco mais utilizados em 
> Python, não estou aqui pedindo para alguém submeter nada, só acho que a 
> comunidade deveria ter planejado e colocado algo. Sabemos da Crise 
> Financeira que atravessamos e os palestrantes mais distantes não tem 
> realmente condições proprias de arcar sozinho com as despesas, mas pelo que 
> me parece tem gente que domina o framework ai perto da regiao do evento. 
> Fica aqui o meu registro. 
>
> Obrigado!
>
>
>
>[image: http://itjp.net.br] 
>  http://itjp.net.b r
>   *Ovidio Marinho Falcao Neto*
>  ovid...@gmail.com 
> Brasil
>  
>

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


[web2py] Re: [web2py-users-brazil:8162] Re: Submissão Python Brasil 11

2015-11-03 Thread Ari Sobel
Interessante teu comentário @matheus
Poderia explicar melhor:

   - o que vc chama de "framework de nicho" - e contextualizar para o
   'universo web2py';
   - o que quer dizer 'mas estão "incubando" o web2py nos seus projetos
   privados';

Eu, por exemplo, sou um desenvolvedor amador (aprendiz, pode-se dizer),
desenvolvimento ainda não é meu ganha-pão (espero que seja, em breve). Uso
muito para fabricar minhas próprias ferramentas - substituindo,
principalmente o MS Access e MS Excell (que ainda uso). Tenho muito o que
aprender ainda sobre web (HTML + CSS + JS), MVC, boas práticas, Python,
web2py, etc etc etc. Mas, ainda assim, consigo fazer algumas brincadeiras
que me ajudam muito (e no meu trabalho). Coisas que sem o que o web2py
oferece de facilidade e velocidade de desenvolvimento, não conseguiria de
outra forma (ou conseguiria com resultados muito mais precários e lentos).

É esse o Nicho o qual vc se refere (desenvolvedores iniciantes, assim como
eu)?

Outra coisa interessante. Vejo gente que já se aprofundou muito em web2py,
depois de um tempo indo pra Flask (vide Bruno Rocha, Julia Rizzia).

De qualquer forma, acho que deveríamos fortalecer a 'comunidade' (?) web2py
no Brasil. Mesmo que seja compartilhando pequenos progressos obtidos. Uma
ou outra funcionalidade interessante, etc.


Em 3 de novembro de 2015 11:41, Matheus Cardoso 
escreveu:

> 5K? Eu achei que tinha isso no mundo. :P Eu sempre achei que, no Brasil, o
> web2py é um framework de nicho. E esse nicho somos...Nós. :) O que eu vejo
> é a predominância da dicotomia Flask vs Django (um flameware em cada
> esquina), com o bottle e o pyramid aparecendo uma vez ou outra - e nada do
> web2py. E eu acho que a cara da comunidade brazuca hoje é o que o Vinicius
> falou: muita gente usa, mas estão "incubando" o web2py nos seus projetos
> privados (tipo eu ~~). Tem um canal no slack da python brasil do web2py. É
> um canal fantasma, infelizmente. E sobre a submissão, está foda viajar
> esses tempos.
>
> On Monday, November 2, 2015 at 10:17:06 AM UTC-3, Ovidio Marinho wrote:
>>
>>
>> Bom Dia Senhores,
>>
>> Acho que no brasil hoje temos mais de 5 mil usuarios do framework Web2py,
>> não tenho isso preciso , mas seria uma boa ideia, levantar e publicar, que
>> seja menos esta conta, não nos envergonharia ficar de fora de uma Python
>> Brasil, sendo o framework que está entre os cinco mais utilizados em
>> Python, não estou aqui pedindo para alguém submeter nada, só acho que a
>> comunidade deveria ter planejado e colocado algo. Sabemos da Crise
>> Financeira que atravessamos e os palestrantes mais distantes não tem
>> realmente condições proprias de arcar sozinho com as despesas, mas pelo que
>> me parece tem gente que domina o framework ai perto da regiao do evento.
>> Fica aqui o meu registro.
>>
>> Obrigado!
>>
>>
>>
>>[image: http://itjp.net.br] 
>>  http://itjp.net.b r
>>   *Ovidio Marinho Falcao Neto*
>>  ovid...@gmail.com
>> Brasil
>>
>>
> --
> Você recebeu essa mensagem por estar inscrito no grupo web2py-users-brazil.
> Para enviar uma mensagem ao grupo, envie email a:
> web2py-users-bra...@googlegroups.com
> Para se desinscrever, envie email a:
> web2py-users-brazil+unsubscr...@googlegroups.com
> Para mais opções, visite o site do grupo em:
> http://groups.google.com/group/web2py-users-brazil?hl=en
> ---
> Você recebeu essa mensagem porque está inscrito no grupo
> "web2py-users-brazil" dos Grupos do Google.
> Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie
> um e-mail para web2py-users-brazil+unsubscr...@googlegroups.com.
> Para mais opções, acesse 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] Way to query from a select object

2015-11-03 Thread Mark Billion
This seems ugly:
foo = db(db.xxx.id==x.id).select()
for a in foo:
if a.primary_residence == True:
nine_b_count = 1
..
Is there a way for me to select only the elements of foo that meet the 
secondary test.  Something like foo.select(a.primary_residence == True) #I 
know this is 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.


Re: [web2py] Way to query from a select object

2015-11-03 Thread Massimiliano
You could  also do something like:

query = (db.xxx.id==x.id) mainset = db(query) subquery = (db.xxx.
primary_residence == True)
subset = mainset(subquery)
rows = subset.select()

take a look here



On Tue, Nov 3, 2015 at 3:14 PM, Massimiliano  wrote:

> What about?
>
> foo = db((db.xxx.id==x.id) & (db.xxx.primary_residence == True)).select()
>
> On Tue, Nov 3, 2015 at 2:53 PM, Mark Billion 
> wrote:
>
>> This seems ugly:
>> foo = db(db.xxx.id==x.id).select()
>> for a in foo:
>> if a.primary_residence == True:
>> nine_b_count = 1
>> ..
>> Is there a way for me to select only the elements of foo that meet the
>> secondary test.  Something like foo.select(a.primary_residence == True) #I
>> know this is 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.
>>
>
>
>
> --
> Massimiliano
>



-- 
Massimiliano

-- 
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] switching tabs in built in editor...

2015-11-03 Thread Edward Shave
Just wondering if there is a keyboard short-cut for switching tabs in built 
in editor?

-- 
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: test for integer in form

2015-11-03 Thread Alex Glaros
(1)  is there way to have it as a requires clause only for the controllers 
that user's use?  E.g.:

db.auth_group.role.requires = not IS_INT_IN_RANGE(-sys.maxint -1, sys.maxint
)

above doesn't raise errors but doesn't work

(2) the sys syntax causes this error: 
 global name 'sys' is not defined

thanks Dave,

Alex

-- 
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: Way to query from a select object

2015-11-03 Thread Anthony
Assuming there is some reason you can't move the additional query 
conditions to the database and you must do the filtering in Python (e.g., 
the query is complex or you need to filter the same set of rows in multiple 
ways), you can use the .find() method 

 
of the Rows object:

primary_residence_rows = all_rows.find(lambda r: r.primary_residence == True
)

Anthony

On Tuesday, November 3, 2015 at 8:53:49 AM UTC-5, Mark Billion wrote:
>
> This seems ugly:
> foo = db(db.xxx.id==x.id).select()
> for a in foo:
> if a.primary_residence == True:
> nine_b_count = 1
> ..
> Is there a way for me to select only the elements of foo that meet the 
> secondary test.  Something like foo.select(a.primary_residence == True) #I 
> know this is 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.