[web2py] Possible to do secondary, ternary..., n-ary orderby in grid?

2013-08-20 Thread Lamps902
Is it possible to do a ranked/n-ary/sequenced orderby in SQLFORM.grid? For 
example, let's say you list user information in a grid, which includes 
first name, last name, and middle name. It's possible to use orderby to 
order the users by last name. Is it possible to order by last name, then 
first name, then middle name, for example?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Possible to do secondary, ternary..., n-ary orderby in grid?

2013-08-20 Thread Lamps902
Awesome - thanks!

On Tuesday, August 20, 2013 8:57:21 AM UTC-5, Jonathan Lundell wrote:

 On 20 Aug 2013, at 6:45 AM, Lamps902 dhea...@gmail.com javascript: 
 wrote:

 Is it possible to do a ranked/n-ary/sequenced orderby in SQLFORM.grid? For 
 example, let's say you list user information in a grid, which includes 
 first name, last name, and middle name. It's possible to use orderby to 
 order the users by last name. Is it possible to order by last name, then 
 first name, then middle name, for example?



 orderby=last|first|middle,


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Values in request.vars persist/doubled when form submitted after unexpected logout/session deletion

2013-08-09 Thread Lamps902
Sure. The version I'm using is 2.5.1-stable+timestamp.2013.06.06.15.39.19.The 
function's really long, so I'll try to distill and abstract what's 
going on to the relevant parts, and change the var names to something more 
helpful when taken out of their original context:

There's a helper function that generates the form:

def generate_form( ... ):
if image_width and image_height:
image_width, image_height = image_width if image_width else 
'15px',image_height 
if image_height else '15px'
   
inputs =  [INPUT(_type = 'image', _src = path_join('/',*
image_location_list), _alt = image_alt_text,
  _style = 'width:' + image_width + ';height:' +image_height
)]
else:
inputs = [INPUT(_type = 'submit', _value = label),hidden_variable_inputs
]
   
inputs.extend([INPUT(_type = 'hidden', _name = name, _value = value) for 
(name, value) in hidden_vars_tuple_list])
   
if form_name:
inputs.append(INPUT(_type = 'hidden', _name = '_formname', _value 
=form_name
))
if form_key:
inputs.append(INPUT(_type = 'hidden', _name = '_formkey', _value 
=form_key
))
   
return = FORM(inputs)

def generate_panel(owner_id, letter_id):

return TABLE(TR(TD(generate_single_item_form(
 hidden_vars_tuple_list = [('letter_id',letter_id),('action'
,'important')], 
 form_name = 'important_form', form_key = web2py_uuid(

@auth.requires_login()
def attempt_to_reproduce_error():

if request.vars.action:
 
try:
letter_created_on_datetime = db.t_letters(request.vars.letter_id
).created_on
except:
letter_created_on_datetime = None

if 'important' == request.vars.action and request.vars.letter_id 
andletter_created_on_datetime
:
try:
cur_letter_flags = db.t_letters(request.vars.letter_id).
letter_flags
cur_letter_flags.remove('important') if 'important' 
incur_letter_flags 
else cur_letter_flags.append('important') 
db(db.t_letters.id == 
request.vars.letter_id).update(letter_flags 
= cur_letter_flags)

except:
pass

try:
letters_set = db(db.t_letters.user_id == session.auth.user.id)
except:
pass

   
letters_board__div = DIV([ DIV(DIV(letter.letter_title.capitalize(),_class
='letter_title'),
  DIV(A(format_user_name(formatting = 'first, 
last, id', **fetch_user_name_by_id(letter.user_id, 'dict')),
 _href=URL('default','show_user', vars=
dict(user_id=letter.user_id))), 
 _class='letter_post_author') if (notletter
.user_id == letter.owner_id) else '', 
  TABLE(TR(TD(generate_panel(owner_id=
session.auth.user.id, letter_id=letter.id),_class='letter_post_panel'),
   TD(_id='buffer_0'),
   TD(letter.letter_body, _class=
'letter_post_body')
 _id = 'letter_body__row'), _id = 
'letter_body__table'),
  DIV(letter.created_on, _class=
'letter_created_on__div'), 
 _class = 
'letter_important_container__div'   \
 if 'important' in letter.letter_flags 
else 'letter_container__div')
  for letter in letters_set.select(orderby=~
db.t_letters.created_on)],
  _class = 
'letter_thread_container__div', ) 

return dict(letter_board = letters_board__div, create_letter_panel = 
'',message 
= '')



On Wednesday, August 7, 2013 2:49:46 PM UTC-5, Anthony wrote:

 On Wednesday, August 7, 2013 11:26:05 AM UTC-4, Lamps902 wrote:

 The method of the forms was left at default/wasn't explicitly set, so 
 they had the 'post' method. Setting the method to 'get' seems to fix the 
 problem.


 Hmm, I would have expected the opposite. Can you show an example of code 
 that produces the problem? What version of web2py are you using?

 Anthony 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Values in request.vars persist/doubled when form submitted after unexpected logout/session deletion

2013-08-07 Thread Lamps902
The method was left at default/wasn't explicitly specified, so it was a 
post form. Changing the method to 'get' resolves the problem.

On Wednesday, August 7, 2013 6:21:26 AM UTC-5, Anthony wrote:

 Only GET vars should be added to the _next parameter in the URL on a 
 redirect to login. Does your form happen to be a GET form rather than a 
 POST form?

 Anthony

 On Tuesday, August 6, 2013 10:21:06 PM UTC-4, Lamps902 wrote:

 I have a controller function which is protected by a standard 
 authentication decorator (@auth.requires_login()). The function presents 
 a page containing some forms (which contain a bunch of INPUT( _type = 
 'hidden', ...) and one INPUT(_type = 'image', ...),  which presents the 
 submission button). 

 If a session terminates in a non-standard way (cookies deleted in 
 browser, logout is clicked and directed to a new tab, etc.), the page 
 with the forms is still present on screen, and if one of the forms is 
 clicked, the login prompt is presented. After the user logs in, the form is 
 processed as usual. However, if the user clicks on the form again, the 
 values submitted by the new form will be appended to the corresponding 
 values already present in request.vars, making a two-item list for each 
 var. That is, something like:

 request.vars.action = action1
 request.vars.item = 24

 will turn into

 request.vars.action = action1
   action1
 request.vars.item = 24
24

 Why are the new values appending to the old, instead of overwriting them? 
 What's the recommended way to deal with this situation? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Values in request.vars persist/doubled when form submitted after unexpected logout/session deletion

2013-08-07 Thread Lamps902
The method of the forms was left at default/wasn't explicitly set, so they 
had the 'post' method. Setting the method to 'get' seems to fix the problem.

On Wednesday, August 7, 2013 6:21:26 AM UTC-5, Anthony wrote:

 Only GET vars should be added to the _next parameter in the URL on a 
 redirect to login. Does your form happen to be a GET form rather than a 
 POST form?

 Anthony

 On Tuesday, August 6, 2013 10:21:06 PM UTC-4, Lamps902 wrote:

 I have a controller function which is protected by a standard 
 authentication decorator (@auth.requires_login()). The function presents 
 a page containing some forms (which contain a bunch of INPUT( _type = 
 'hidden', ...) and one INPUT(_type = 'image', ...),  which presents the 
 submission button). 

 If a session terminates in a non-standard way (cookies deleted in 
 browser, logout is clicked and directed to a new tab, etc.), the page 
 with the forms is still present on screen, and if one of the forms is 
 clicked, the login prompt is presented. After the user logs in, the form is 
 processed as usual. However, if the user clicks on the form again, the 
 values submitted by the new form will be appended to the corresponding 
 values already present in request.vars, making a two-item list for each 
 var. That is, something like:

 request.vars.action = action1
 request.vars.item = 24

 will turn into

 request.vars.action = action1
   action1
 request.vars.item = 24
24

 Why are the new values appending to the old, instead of overwriting them? 
 What's the recommended way to deal with this situation? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Manually creating multiple buttons to be used with SQLFORM.grid's 'selectable' parameter

2013-08-07 Thread Lamps902
 

I am attempting to create multiple buttons for an SQLFORM.grid which, upon 
being click, will have the effect of redirecting data selected in the 
grid's checkboxes to other controller functions. The code is something like 
the following:

def redirect_func(x):
if request.vars.action == 'action1':
redirect(URL('function1', vars=dict(x = x)))
elif request.vars.action == 'action2':
redirect(URL('function2', vars=dict(x = x)))
...

grid = SQLFORM.grid(...
 selectable = lambda x: redirect_func(x)
 ...)

submission_form1 = FORM(INPUT(_type='hidden', _name='action', _value='action1'),
   INPUT(_type = 'hidden', _name='_formkey', 
 _value= grid.element('form').formkey),
   INPUT(_type = 'hidden', _name='_formname', 
 _value=grid.element('form').formname),
INPUT(_type='image', ...))


submission_form2 = FORM(INPUT(_type='hidden', _name='action', _value='action2'),
...)...

grid.insert(-1, DIV(submission_form1, submission_form2))

The redirect goes to the right function, but the value of x does not end 
up getting passed to that function under request.vars.x, as expected. Any 
advice on how to get the value of x to the appropriate function? 
Otherwise, is there a better approach to accomplishing the same thing? 
Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Manually creating multiple buttons to be used with SQLFORM.grid's 'selectable' parameter

2013-08-07 Thread Lamps902
Nevermind. Took care of it by creating a series of images to be used as 
buttons, and using jquery to append a hidden var specifying to which 
function the redirect should go, and to submit the form contained within 
the grid.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Values in request.vars persist/doubled when form submitted after unexpected logout/session deletion

2013-08-06 Thread Lamps902
I have a controller function which is protected by a standard 
authentication decorator (@auth.requires_login()). The function presents 
a page containing some forms (which contain a bunch of INPUTS() of _type = 
'hidden' and one INPUT(_type = 'image',  which presents the submission 
button). If a session terminates in a non-standard way (cookies deleted in 
browser, logout is clicked and directed to a new tab, etc.), the page 
with the forms is still present on screen, and if one of the forms is 
clicked, the login prompt is presented. After the user logs in, the form is 
processed as usual. However, if the user clicks on the form again, the 
values submitted by the new form will be appended to the corresponding 
values already present in request.vars, making a two-item list for each 
var. That is, something like:

request.vars.action = action1
request.vars.item = 24

will turn into

request.vars.action = action1
  action1
request.vars.item = 24
   24

Why are the new values appending to the old, instead of overwriting them? 
What's the recommended way to deal with this situation? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering image buffer with IMG() helper?

2013-07-15 Thread Lamps902
This works fine for generating an image from a buffer:

import base64

img_buffer = io.BytesIO()
pylab.savefig(img_buffer, format = 'png')
img_buffer.seek(0)

IMG(_src='data:image/png;base64,' + base64.b64encode(img_buffer.getvalue(), 
_alt = 'image buffer not displaying'))

However, as Massimo points out, it's best if I switch to matplotlib. 
Thanks, guys!

On Monday, July 8, 2013 2:59:22 PM UTC-5, Anthony wrote:

 No, now you're trying to put the whole image in the URL query string. Just 
 let the URL point to the render_image function, and create the image in 
 that function. You cannot create the image in the same action that produces 
 the URL. First you have to return an HTML page with an image element. Then 
 the browser requests the src of the image element. The image must be 
 fetched in a separate request -- you cannot embed it in the original HTML 
 page that is returned.

 Anthony

 On Monday, July 8, 2013 3:43:22 PM UTC-4, Lamps902 wrote:

 Maybe I'm a bit confused on how to generate/stream the image, given the 
 buffer. The following should work, right?

 def render_image():
return Image.open(request.vars.image_buffer)

 ...
 img_buffer = io.BytesIO()
 pylab.savefig(img_buffer, format = 'png')
 img_buffer.seek(0)

 return dict(img = IMG(_src=URL('render_image', vars=dict(image_buffer = 
 img_buffer)), _alt = 'image buffer not displaying'))

 Or is there something other than Image.open() that's a better solution?

 On Monday, July 8, 2013 1:04:38 PM UTC-5, Anthony wrote:


 On Monday, July 8, 2013 12:49:19 PM UTC-5, Anthony wrote:

 The IMG() helper simply creates an HTML img element to be displayed 
 in the browser. The src attribute of an image element should be a URL 
 where the browser can request the image. You cannot pass an actual image 
 file object to the helper.


 Just make the src URL an action that generates the image and streams 
 it. 



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Possible to use pylab for visualization in web2py environment?

2013-07-08 Thread Lamps902
Is it possible to use pylab in web2py to generate a visualization? 
Something along these lines:

import pylab

x, y = ...
pylab.plot(x,y)
pylab.show()

Doing so produces this error: no display name and no $DISPLAY environment 
variable 

Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Rendering image buffer with IMG() helper?

2013-07-08 Thread Lamps902
I'm attempting to do the following:

img_buffer = io.BytesIO()
pylab.savefig(img_buffer, format = 'png')
img_buffer.seek(0)
IMG(_src=img_buffer, _alt = 'image buffer not displaying')

This shows the _alt message. Any ideas on how to get it to show the image? 
Thanks.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering image buffer with IMG() helper?

2013-07-08 Thread Lamps902
Thanks, Anthony. Since there is no URL associated with an image stored in a 
buffer, what would be the proper way to render it?

On Monday, July 8, 2013 12:49:19 PM UTC-5, Anthony wrote:

 The IMG() helper simply creates an HTML img element to be displayed in 
 the browser. The src attribute of an image element should be a URL where 
 the browser can request the image. You cannot pass an actual image file 
 object to the helper.

 Anthony

 On Monday, July 8, 2013 1:38:56 PM UTC-4, Lamps902 wrote:

 I'm attempting to do the following:

 img_buffer = io.BytesIO()
 pylab.savefig(img_buffer, format = 'png')
 img_buffer.seek(0)
 IMG(_src=img_buffer, _alt = 'image buffer not displaying')

 This shows the _alt message. Any ideas on how to get it to show the 
 image? Thanks.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering image buffer with IMG() helper?

2013-07-08 Thread Lamps902
Maybe I'm a bit confused on how to generate/stream the image, given the 
buffer. The following should work, right?

def render_image():
   return Image.open(request.vars.image_buffer)

...
img_buffer = io.BytesIO()
pylab.savefig(img_buffer, format = 'png')
img_buffer.seek(0)Enter code here...

return dict(img = IMG(_src=URL('render_image', vars=dict(image_buffer = 
img_buffer)), _alt = 'image buffer not displaying'))

Or is there something other than Image.open() that's a better solution?

On Monday, July 8, 2013 1:04:38 PM UTC-5, Anthony wrote:


 On Monday, July 8, 2013 12:49:19 PM UTC-5, Anthony wrote:

 The IMG() helper simply creates an HTML img element to be displayed in 
 the browser. The src attribute of an image element should be a URL where 
 the browser can request the image. You cannot pass an actual image file 
 object to the helper.


 Just make the src URL an action that generates the image and streams it. 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using _after_delete callback when enable_record_versioning() is used

2013-06-11 Thread Lamps902
Thanks, Anthony - forgot about the _after_update callback. Could you please 
clarify how to use it in this situation? I was trying this:

def create_after_update_callback(self, db, id):

def update_mytable1_record(s, f, id): 
  if not db(db.auth_user.id == 
id).is_active:   
# perform updates on table

db.auth_user._after_update.append(lambda s, f: 
update_mytable1_record(s=s, f=f, id = id))

Any attempts to select()/inspect the table row being deleted, whether 
through the set object (s) or the auth_user table, result in a list index 
out of range error (I guess I can't access the object as a result of 
is_active being set to False?).


On Monday, June 10, 2013 10:31:24 PM UTC-5, Anthony wrote:

 Can you use the _after_update callback instead?

 On Monday, June 10, 2013 5:32:12 PM UTC-4, Lamps902 wrote:

 When enable_record_versioning is being utilized, db rows aren't actually 
 deleted, but the is_active bit is flipped off instead. As far as I can 
 tell, this means that the _after_delete callback for a given table won't be 
 called, which is problematic when you are using this callback to 
 delete/flip off 'is active' bits of associated rows in other tables. Is 
 there any convenient way around this, or will it simply be necessary to 
 forgo the callback, and flip the is_active bit of associated records in 
 other tables manually by performing an update() when deleting a record?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Rendering null values in SQLFORM.grid

2013-06-10 Thread Lamps902
If there's a NULL value in my postgresql DB, SQLFORM.grid renders it as 
None. Is it there something that can be done globally for an SQLFORM.grid 
that would simply make it display all NULL values as an empty string (i.e. 
not display anything in the grid for NULLs), or does that have to be 
determined individually for every field by setting the respective field's 
*represent 
*parameter? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering null values in SQLFORM.grid

2013-06-10 Thread Lamps902
Thanks for the clarification, Niphlod.

On Monday, June 10, 2013 10:32:33 AM UTC-5, Niphlod wrote:

 The second one you said (i.e. altering the default repr for None values). 
 From a theoretical standpoint, a null value is not an empty string. If 
 your app doesn't care for the difference, set a default='' on the 
 interested fields.

 Il giorno lunedì 10 giugno 2013 15:42:21 UTC+2, Lamps902 ha scritto:

 If there's a NULL value in my postgresql DB, SQLFORM.grid renders it as 
 None. Is it there something that can be done globally for an SQLFORM.grid 
 that would simply make it display all NULL values as an empty string (i.e. 
 not display anything in the grid for NULLs), or does that have to be 
 determined individually for every field by setting the respective field's 
 *represent *parameter? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Key/constraint issue when using separate database for archiving

2013-06-10 Thread Lamps902
 

I've asked this one before, but didn't get an answer; perhaps I was being 
too vague, so I'll give it another shot with more detail:

I've got a primary postgresql database (db1), and I've set up a separate 
postgresql database (db1_archive) used for archiving several of the tables 
from db1. This functionality is implemented in a module with the following:
class db_archives():

 def __init__(self, request, response, db1_archive, db1, auth):

 ...

 auth.enable_record_versioning(
 archive_db = db1_archive,
 tables = [db1.auth_user, db1.table1, db1.table2, ...]
 archive_names='archive_%(tablename)s'
 )


When something is deleted from the relevant tables in db1, it should 
automatically be archived in db1_archive. However, upon deletion, the 
following psycopg2.IntegrityError is produced instead:

 insert or update on table archive_table1 violates foreign key constraint 
archive_table1_created_by_fkey DETAIL: Key (created_by)=(9) is  not 
present in table auth_user

I guess what's happening is that the archive DB is not finding a user with 
an ID of 9. The 'created_by' field has the following constraint:

FOREIGN KEY (created_by) REFERENCES auth_user(id) ON DELETE CASCADE

I'd like to remove all such constraints from the archive db (will doing so 
have any potentially dangerous effects?). I think this can be done with 
web2py's *[database_name].executesql() *function. However, I've tried a few 
things such as db1_archive.executesql('SET FOREIGN_KEY_CHECKS=0;'), and 
only ended up with error messages. Can anyone advise me on some SQL or 
web2py codes I could try to fix the situation? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] using _after_delete callback when enable_record_versioning() is used

2013-06-10 Thread Lamps902
When enable_record_versioning is being utilized, db rows aren't actually 
deleted, but the is_active bit is flipped off instead. As far as I can 
tell, this means that the _after_delete callback for a given table won't be 
called, which is problematic when you are using this callback to 
delete/flip off 'is active' bits of associated rows in other tables. Is 
there any convenient way around this, or will it simply be necessary to 
forgo the callback, and flip the is_active bit of associated records in 
other tables manually by performing an update() when deleting a record?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Key/constraint issue when using separate database for archiving

2013-06-10 Thread Lamps902
Thanks a lot, Niphlod! I'll go ahead and file it.

On Monday, June 10, 2013 2:29:38 PM UTC-5, Niphlod wrote:

 I'd go for filing a bug on web2py's issues and just removing the 
 constraint on your archive tables. nothing should break.
 I think that the code creating the archive tables is just the one used to 
 create the original one, so the archive table gets created with the same 
 constraint as the original, and of course it goes into exception if it 
 tries to archive a record that doesn't have the link to a valid auth_user 
 row.
 Right now the only thing that gets modified from the original table is the 
 unique constraint. We should add in the code a similar exception for 
 reference fields, although keeping a row version with a non-existant row 
 reference kinda breaks the deal if you don't archive also the referenced 
 table.
 However, smart people should take that into account in their own code, so 
 I think it can be a safe thing to do.

 On Monday, June 10, 2013 5:56:09 PM UTC+2, Lamps902 wrote:

 I've asked this one before, but didn't get an answer; perhaps I was being 
 too vague, so I'll give it another shot with more detail:

 I've got a primary postgresql database (db1), and I've set up a separate 
 postgresql database (db1_archive) used for archiving several of the tables 
 from db1. This functionality is implemented in a module with the following:
 class db_archives():

  def __init__(self, request, response, db1_archive, db1, auth):

  ...

  auth.enable_record_versioning(
  archive_db = db1_archive,
  tables = [db1.auth_user, db1.table1, db1.table2, ...]
  archive_names='archive_%(tablename)s'
  )


 When something is deleted from the relevant tables in db1, it should 
 automatically be archived in db1_archive. However, upon deletion, the 
 following psycopg2.IntegrityError is produced instead:

  insert or update on table archive_table1 violates foreign key 
 constraint archive_table1_created_by_fkey DETAIL: Key (created_by)=(9) is 
  not present in table auth_user

 I guess what's happening is that the archive DB is not finding a user 
 with an ID of 9. The 'created_by' field has the following constraint:

 FOREIGN KEY (created_by) REFERENCES auth_user(id) ON DELETE CASCADE

 I'd like to remove all such constraints from the archive db (will doing 
 so have any potentially dangerous effects?). I think this can be done with 
 web2py's *[database_name].executesql() *function. However, I've tried a 
 few things such as db1_archive.executesql('SET FOREIGN_KEY_CHECKS=0;'), and 
 only ended up with error messages. Can anyone advise me on some SQL or 
 web2py codes I could try to fix the situation? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Removing Foreign Key constraint?

2013-06-06 Thread Lamps902
To clarify, due to the SQL Foreign Key constraint (which is retained when 
archive tables are created through auth.enable_record_versioning), some of 
the archive database's tables still retain an association with the 
auth_user table's id field. However, the rows with the ids on which the new 
tables depend may not necessarily be transferred from the application's 
primary database to the archive database. Is there a way to use the DAL to 
remove the Foreign Key constraint? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Removing Foreign Key constraint?

2013-06-05 Thread Lamps902
For purposes of archiving, I've created a new db, and archived some tables 
using auth.enable_record_versioning(db, tables=[...]). Among other things, 
this has the effect of migrating Foreign Key constraints from the original 
tables, so the *modified_by*, and *created_by* fields in the tables in the 
new db have a needless dependency on data that is not in the new database.

Is there a way to safely remove the Foreign Key requirement with the DAL? 
Otherwise, is it safe to just go ahead and do it with the db admin 
interface?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Gateway time-out 504 error with enable_record_versioning

2013-06-04 Thread Lamps902
I've defined a new db to be used for archiving purposes with the following: 
db_archive = DAL(postgres://[address/authentication_info]/db_archive)

Then, I attempt to enable archiving of a table by doing this:
db.[table_name]._enable_record_versioning(db_archive)

The app seems to be successfully connecting to the db, but attempting to 
enable record versioning causes nginx to produce a gateway time-out 504 
error. Any ideas why it could be taking an inordinately long time to create 
the archive table? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Gateway time-out 504 error with enable_record_versioning

2013-06-04 Thread Lamps902
Nevermind - sorted it out. Seems that a bunch of my tables had a dependency 
on auth_user, and since a new db was created, with table names set to 
[original_table_name]_archive by default, there was no auth_user table, 
and the dependency was not being satisfied. If using 
auth.enable_record_versioning (given that a separate db is used for 
archiving), one way to solve the issue is by setting the archive_names 
parameter to '%(tablename)s'.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Excessive memory usage with uwsgi/nginx

2013-06-03 Thread Lamps902
My web2py application is running on Webfaction's servers over uwsgi/nginx. 
When the servers are started, four instances of nginx and four instances of 
uwsgi are spawned, with each nginx instance taking up ~18M of RAM, and each 
nginx instance taking up a couple of M. Accessing any part of the page 
(i.e. clicking a menu item) adds about 30M to one of the uwsgi instances. 
Clicking a menu item again can add between 2 and 30 M to any of the uwsgi 
instances (it will be 30 M if nothing has yet been added to the RAM usage 
of that particular instance). This happens until my memory limit (256 M) is 
exceeded. I think I've mitigated the behavior somewhat by moving some 
things from models to modules, and by serving static content separately, 
but I think my memory usage is still quite excessive. Is this normal 
behavior?

Should I try to move all databases from models to modules? Is it ok to have 
globals (i.e. settings = Storage()) declared in models? Is it alright to 
have import statements in models? In the controllers, is it better to have 
import statements inside or outside of functions?

As far as uwsgi goes, would it make sense to use the 'reload-on-rss' 
directive to restart when excessive memory is used? Are there any major 
downsides to this? Any other tips for optimizing uwsgi?

Any other tips for diagnosing the sources of excessive memory consumption, 
and diminishing this consumption? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Excessive memory usage with uwsgi/nginx

2013-06-03 Thread Lamps902
Thanks, Roberto. It was eventually growing to something in excess of 80M 
per uwsgi instance, then crashing when all are full. Will try the settings 
you suggested.

On Monday, June 3, 2013 9:32:10 AM UTC-5, Roberto De Ioris wrote:


 30-40 MB per worker is pretty normal. 

 To gain memory you can move to multithreading: 

 master = true 
 processes = 2 
 threads = 2 
 thread-stacksize = 512 

 should be good enough 

 Monitoring memory is a good thing, use --reload-on-rss 80 to avoid your 
 app growing up 

 -- 
 Roberto De Ioris 
 http://unbit.it 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Excessive memory usage with uwsgi/nginx

2013-06-03 Thread Lamps902
Hi, Massimo. I didn't cache much at first, and to make sure that caching 
isn't the source of the problem, I tried removing all caching. No 
noticeable improvement there. Right now, I'm focused on moving a lot of the 
model db and global var/settings stuff to modules (but I find this a bit 
perplexing, as it seems to undermine the whole notion of the MVC 
framework). 

On Monday, June 3, 2013 11:55:02 AM UTC-5, Massimo Di Pierro wrote:

 Mind that caching too much stuff will do that to you.

 On Monday, 3 June 2013 10:04:25 UTC-5, Lamps902 wrote:

 Thanks, Roberto. It was eventually growing to something in excess of 80M 
 per uwsgi instance, then crashing when all are full. Will try the settings 
 you suggested.

 On Monday, June 3, 2013 9:32:10 AM UTC-5, Roberto De Ioris wrote:


 30-40 MB per worker is pretty normal. 

 To gain memory you can move to multithreading: 

 master = true 
 processes = 2 
 threads = 2 
 thread-stacksize = 512 

 should be good enough 

 Monitoring memory is a good thing, use --reload-on-rss 80 to avoid your 
 app growing up 

 -- 
 Roberto De Ioris 
 http://unbit.it 



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Excessive memory usage with uwsgi/nginx

2013-06-03 Thread Lamps902
Initially, yes - every time I clicked on something that requires 
interaction with the server, it would add 2-30M. I don't know if there was 
a limit to how much memory would ultimately be consumed, because I would 
reach my memory limit, and Webfaction would kill my nginx/uwsgi processes. 
After moving a bunch of stuff to models, I get the impression that it has 
improved, and I get the impression that the memory consumption does seem to 
taper off after I've clicked around for a while. I'll have to look at it 
more thoroughly to find out if it really does reach some reasonable limit 
of memory use, but for now, I'm keeping uwsgi in check with reload-on-rss.

On Monday, June 3, 2013 1:21:03 PM UTC-5, Anthony wrote:

 Are you saying every single request adds 2M to 30M to the memory consumed, 
 and it just keeps growing with every request?

 On Monday, June 3, 2013 1:55:28 PM UTC-4, Lamps902 wrote:

 Hi, Massimo. I didn't cache much at first, and to make sure that caching 
 isn't the source of the problem, I tried removing all caching. No 
 noticeable improvement there. Right now, I'm focused on moving a lot of the 
 model db and global var/settings stuff to modules (but I find this a bit 
 perplexing, as it seems to undermine the whole notion of the MVC 
 framework). 

 On Monday, June 3, 2013 11:55:02 AM UTC-5, Massimo Di Pierro wrote:

 Mind that caching too much stuff will do that to you.

 On Monday, 3 June 2013 10:04:25 UTC-5, Lamps902 wrote:

 Thanks, Roberto. It was eventually growing to something in excess of 
 80M per uwsgi instance, then crashing when all are full. Will try the 
 settings you suggested.

 On Monday, June 3, 2013 9:32:10 AM UTC-5, Roberto De Ioris wrote:


 30-40 MB per worker is pretty normal. 

 To gain memory you can move to multithreading: 

 master = true 
 processes = 2 
 threads = 2 
 thread-stacksize = 512 

 should be good enough 

 Monitoring memory is a good thing, use --reload-on-rss 80 to avoid 
 your 
 app growing up 

 -- 
 Roberto De Ioris 
 http://unbit.it 



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: After update web2py version, invalid login.

2013-05-31 Thread Lamps902
Did you perform an sqlite - postgresql migration which left a bunch of 
trailing whitespace in various fields?

On Sunday, May 26, 2013 3:02:02 AM UTC-5, toni campins wrote:

 Hi,

 Why after update web2py i have to edit all passwords for invalid login?

 Thanks


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Making RSS feed auto-detectable?

2013-05-29 Thread Lamps902
Anyone knowledgeable in RSS care to take a crack at this one?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Making RSS feed auto-detectable?

2013-05-29 Thread Lamps902
Thanks, Niphlod. So it does seem to be the case that I implemented the 
standard method of embedding a feed correctly, and I can't find any issue 
with the HTML (not that this guarantees there isn't an issue). I tried a 
couple of other RSS readers, and they seem to be picking it up with no 
problem, so I guess you're right that I should check into whether there's 
something about Sage in particular that's problematic. 

On Wednesday, May 29, 2013 7:53:12 AM UTC-5, Niphlod wrote:

 it's not a matter of rss.
 The standard way to embed an alternate representation of the site is 

 link rel=alternate type=application/rss+xml title=Recent Changes 
 href=theurl

 From there on, each client has its own implementation to autodiscovery 
 all feeds. 
 Contact the Sage's creator to know why sometimes it works and sometimes 
 doesn't in your site, but first triple-check all your layout (maybe it's 
 not working in a page that has some broken HTML where Sage parser's life is 
 harder).

 Il giorno mercoledì 29 maggio 2013 14:09:45 UTC+2, Lamps902 ha scritto:

 Anyone knowledgeable in RSS care to take a crack at this one?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Making RSS feed auto-detectable?

2013-05-23 Thread Lamps902
I've added the following RSS feed function to my default controller:

def updatefeed():
list_of_rss_entry_dicts = [ dict(title = data_set.f_headline, 
   link = 'http://' + settings.domain_name, 
   description = data_set.f_content)
for data_set in db(db.t_news).select(orderby
=db.t_news.created_on)[-3:]]

return dict(title=settings.title + ' RSS feed',
link=settings.domain_name,
description=settings.title + ' RSS feed',
entries=list_of_rss_entry_dicts) 

I put this line into the header of my layout.html file:

link rel=alternative type=application/rss+xml title={{=settings.title 
+ ' RSS feed'}} href={{=URL('default','updatefeed.rss')}} /

The feed seems to be working fine when accessed from 
default/updatefeed.rss, but it cannot be detected from the site's home page 
(for example, by Firefox's Sage plugin). Any ideas on how to fix this? 
Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Twitter post function producing HTTP 401 error

2013-05-23 Thread Lamps902
I've added the Twitter posting function to my app, in the form in which 
it's presented in the book - 
http://www.web2py.com/books/default/chapter/29/14?search=twitter#Twitter-API. 
When calling this function with the username supplied in the Twitter 
Account menu's username field, my twitter password, and a generic message 
(i.e. message), I get an HTTP Error 401: Unauthorized message. Any 
suggestions as to how to fix this? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Twitter post function producing HTTP 401 error

2013-05-23 Thread Lamps902
Thanks, Anthony. Are you aware of any viable web2py solutions to making 
Twitter posts? Would it be a good idea just to use some python Twitter 
module?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Twitter post function producing HTTP 401 error

2013-05-23 Thread Lamps902
Trying to get it running with this one: 
https://pypi.python.org/pypi/twitter. Thanks!

On Thursday, May 23, 2013 9:58:34 AM UTC-5, Anthony wrote:

 I don't think web2py has anything built in, so just check the Twitter API 
 docs and/or find an existing Python module to help.

 Anthony

 On Thursday, May 23, 2013 10:24:04 AM UTC-4, Lamps902 wrote:

 Thanks, Anthony. Are you aware of any viable web2py solutions to making 
 Twitter posts? Would it be a good idea just to use some python Twitter 
 module?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Send registration email directly from local server?

2013-05-21 Thread Lamps902
Interesting info, Ales. Thanks!

On Monday, May 20, 2013 7:09:06 PM UTC-5, LightDot wrote:

 Gmail's SMTP has a limit of 100 recipients per single message, max 500 
 different recipients per day. A large number of undeliverable messages will 
 get you in trouble regardless of the limits. In case of a ban, the account 
 gets locked for 24h.

 Yahoo has similar limitations as Gmail. Hotmail used to have a 100 
 recipients per day limit and Outlook.com has this at appx. 300 per day now 
 - it varies according to the account age, etc.. I'm pretty sure all 
 mentioned providers take such factors into account. So a completely new 
 account might get locked up much faster than on that is years old.

 Lamps902, one can customize from, reply-to etc. regardless of the SMTP 
 server used - so no need to actually use your domain with gmail, for 
 example. You just need a working SMTP... A little bit of additional code 
 could also enable web2py to rotate between several SMTP servers, according 
 to some simple rules... Anyway, I would recommend a private, well 
 administered SMTP instead. Much less hassle.

 In the GNU/linux world, having an ability to send mail locally is 
 practically a given thing - most of the distributions have this 
 functionality out of the box by using the ubiquitous sendmail. Even if it 
 isn't actually sendmail anymore, the functionality is there (together with 
 the symlink named sendmail). In web2py, you should be able to simply use 
 localhost:25 as SMTP (might need additional authentication, might not. It 
 depends...). Not quite independent of the system used, but there it is...

 Regards,
 Ales


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Send registration email directly from local server?

2013-05-20 Thread Lamps902
At the moment, my custom domain is associated with Outlook, and my page's 
email settings are configured this way:

settings.email_server = 'smtp.live.com:587'
settings.email_sender = '[sender_name]@[mydomain.com]'
settings.email_login = '[username]:[pass]'

It seems that every few emails I send, Outlook detects something it doesn't 
like, and stops routing emails; when I try to log on, it demands I fill out 
a captcha before enabling the mail service again.

Is there a straightforward way to avoid this problem by bypassing the 
Outlook servers when sending registration emails (i.e. send mail directly 
from the local server)?  Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Send registration email directly from local server?

2013-05-20 Thread Lamps902
Is it necessary to have an SMTP server available on your system? I guess I 
was wondering if there is some kind of ad-hoc email server-like 
functionality that comes with web2py - for example, something like this: 
http://www.tutorialspoint.com/python/python_sending_email.htm - that can be 
readily integrated into the registration email schema. Email is really a 
weak point with me, so I'm a bit lost on this topic...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Send registration email directly from local server?

2013-05-20 Thread Lamps902


  correctly identified (reverse dns, mx, etc), so you don't get included in 
 a blacklist as soon as you start using it ^_^


Ironically, it happened with my Outlook account, although it seems to have 
been configured correctly (with a bit of assistance from my registrar's 
tech support)! In other words, receiving Outlook accounts are sending my 
sending Outlook account's email straight to Junk... very annoying!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Send registration email directly from local server?

2013-05-20 Thread Lamps902


On Monday, May 20, 2013 10:31:41 AM UTC-5, Niphlod wrote:

 I really don't think that smtp.live.com accepts happily more than a 
 few emails per day (same thing goes for google's SMTPs using a personal 
 account).
 They're not meant to be used by servers :P


Which is exactly why I'm looking for another way to send the registration 
emails! ;)

And gmail I excluded right off the bat, since they now put obstructions 
(i.e. charges) in the way of using custom domain names.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Dynamically loaded pages not found when link clicked from 'user' function/pages

2013-05-20 Thread Lamps902
I have a few pages (about, FAQ, terms of service) that are loaded from text 
files in the static folder. The setup is basically like this:

content_files = Storage()
file_handler = 
open(os.path.join(request.folder,static,content,about.txt),'r')
content_files['about'] = file_handler.read()

content_files_as_HTML['about'] = DIV(XML(content_files['about'] %
{'page_title':response.title or request.application,
'email_contact':settings.email_contact,
}), _id='about_static_content_div', _style='line-height:12px')

def about():
   return dict()


If I click on the 'about' page from home or from most other pages, it show 
up fine. If, on the other hand, the current page is one of the 'user' pages 
(i.e. default/user/register, default/user/login), and I click on one of the 
dynamically loaded pages, I get a blank page with a 404 NOT FOUND error. 
Any idea as to what's going on/how to fix it? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Dynamically loaded pages not found when link clicked from 'user' function/pages

2013-05-20 Thread Lamps902
That was pretty much it above. The corresponding html files are basically 
like this:

{{extend 'layout.html'}}
h2frequently asked questions/h2
{{=content_files_as_HTML['faq']}}


What other code should I post?

On Monday, May 20, 2013 1:56:23 PM UTC-5, Niphlod wrote:

 without the code you use to load them, it's quite impossible to figure out 
 why it doesn't work.

 On Monday, May 20, 2013 8:53:06 PM UTC+2, Lamps902 wrote:

 I have a few pages (about, FAQ, terms of service) that are loaded from 
 text files in the static folder. The setup is basically like this:

 content_files = Storage()
 file_handler = 
 open(os.path.join(request.folder,static,content,about.txt),'r')
 content_files['about'] = file_handler.read()

 content_files_as_HTML['about'] = DIV(XML(content_files['about'] %
 {'page_title':response.title or request.application,
 'email_contact':settings.email_contact,
 }), _id='about_static_content_div', _style='line-height:12px')

 def about():
return dict()


 If I click on one of the dynamically loaded pages from home or from most 
 other pages, it shows up fine. If, on the other hand, the current page is 
 one of the 'user' pages (i.e. default/user/register, default/user/login),  
 I get a blank page with a 404 NOT FOUND error. Any idea as to what's 
 going on/how to fix it? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Dynamically loaded pages not found when link clicked from 'user' function/pages

2013-05-20 Thread Lamps902
Just checked it out. request.folder stays exactly the same regardless of 
whether the current page is a user page or not.

On Monday, May 20, 2013 2:04:11 PM UTC-5, Derek wrote:

 I'd start by debugging - the variable in question would be 
 'request.folder'. does it change in some way when the current page is a 
 'user' page?

 On Monday, May 20, 2013 11:53:06 AM UTC-7, Lamps902 wrote:

 I have a few pages (about, FAQ, terms of service) that are loaded from 
 text files in the static folder. The setup is basically like this:

 content_files = Storage()
 file_handler = 
 open(os.path.join(request.folder,static,content,about.txt),'r')
 content_files['about'] = file_handler.read()

 content_files_as_HTML['about'] = DIV(XML(content_files['about'] %
 {'page_title':response.title or request.application,
 'email_contact':settings.email_contact,
 }), _id='about_div', _style='line-height:12px')

 def about():
return dict()


 If I click on one of the dynamically loaded pages from home or from most 
 other pages, it shows up fine. If, on the other hand, the current page is 
 one of the 'user' pages (i.e. default/user/register, default/user/login),  
 I get a blank page with a 404 NOT FOUND error. Any idea as to what's 
 going on/how to fix it? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Dynamically loaded pages not found when link clicked from 'user' function/pages

2013-05-20 Thread Lamps902
Oops. Just noticed something (sorry; gotten really out of practice lately, 
and I'm forgetting to check the obvious). If the current page is one of the 
'user' pages, and I click on 'about', the page looks for 
'default/user/about' instead of 'default/about' as it should. In 
layout.html. the links are along the lines of: 

a href=about.html class='footer_text'




On Monday, May 20, 2013 2:09:16 PM UTC-5, Niphlod wrote:

 request.folder never changes. There's surely some bug in the code cause if 
 you try to put , e.g.

 STATIC_SOMETHING = 'never changes'

 in models, and in a layout.html you do

 {{=STATIC_SOMETHING}}

 it gets printed in every page.

 PS: why the dinamically in the title ? it's pretty much static ^_^

 On Monday, May 20, 2013 9:04:11 PM UTC+2, Derek wrote:

 I'd start by debugging - the variable in question would be 
 'request.folder'. does it change in some way when the current page is a 
 'user' page?

 On Monday, May 20, 2013 11:53:06 AM UTC-7, Lamps902 wrote:

 I have a few pages (about, FAQ, terms of service) that are loaded from 
 text files in the static folder. The setup is basically like this:

 content_files = Storage()
 file_handler = 
 open(os.path.join(request.folder,static,content,about.txt),'r')
 content_files['about'] = file_handler.read()

 content_files_as_HTML['about'] = DIV(XML(content_files['about'] %
 {'page_title':response.title or request.application,
 'email_contact':settings.email_contact,
 }), _id='about_div', _style='line-height:12px')

 def about():
return dict()


 If I click on one of the dynamically loaded pages from home or from most 
 other pages, it shows up fine. If, on the other hand, the current page is 
 one of the 'user' pages (i.e. default/user/register, default/user/login),  
 I get a blank page with a 404 NOT FOUND error. Any idea as to what's 
 going on/how to fix it? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Dynamically loaded pages not found when link clicked from 'user' function/pages

2013-05-20 Thread Lamps902
Yep. Changing this sort of stuff:

a href=about.html class='footer_text'

   to
 
a href={{=URL('default','faq')}} class='footer_text'

Didn't really give the scaffolding/template much thought. Just sort of 
assumed it all took care of itself. Thanks!

On Monday, May 20, 2013 2:25:54 PM UTC-5, Niphlod wrote:

 always generate your urls with URL()..

 On Monday, May 20, 2013 9:19:17 PM UTC+2, Lamps902 wrote:

 Oops. Just noticed something (sorry; gotten really out of practice 
 lately, and I'm forgetting to check the obvious). If the current page is 
 one of the 'user' pages, and I click on 'about', the page looks for 
 'default/user/about' instead of 'default/about' as it should. In 
 layout.html. the links are along the lines of: 

 a href=about.html class='footer_text'




 On Monday, May 20, 2013 2:09:16 PM UTC-5, Niphlod wrote:

 request.folder never changes. There's surely some bug in the code cause 
 if you try to put , e.g.

 STATIC_SOMETHING = 'never changes'

 in models, and in a layout.html you do

 {{=STATIC_SOMETHING}}

 it gets printed in every page.

 PS: why the dinamically in the title ? it's pretty much static ^_^

 On Monday, May 20, 2013 9:04:11 PM UTC+2, Derek wrote:

 I'd start by debugging - the variable in question would be 
 'request.folder'. does it change in some way when the current page is a 
 'user' page?

 On Monday, May 20, 2013 11:53:06 AM UTC-7, Lamps902 wrote:

 I have a few pages (about, FAQ, terms of service) that are loaded from 
 text files in the static folder. The setup is basically like this:

 content_files = Storage()
 file_handler = 
 open(os.path.join(request.folder,static,content,about.txt),'r')
 content_files['about'] = file_handler.read()

 content_files_as_HTML['about'] = DIV(XML(content_files['about'] %
 {'page_title':response.title or request.application,
 'email_contact':settings.email_contact,
 }), _id='about_div', _style='line-height:12px')

 def about():
return dict()


 If I click on one of the dynamically loaded pages from home or from 
 most other pages, it shows up fine. If, on the other hand, the current 
 page 
 is one of the 'user' pages (i.e. default/user/register, 
 default/user/login),  I get a blank page with a 404 NOT FOUND error. 
 Any 
 idea as to what's going on/how to fix it? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Dynamically generating text file that isn't stored?

2013-05-03 Thread Lamps902
I would like to permit users to be able to download a text file of some 
data that's pulled up from certain fields of a DB table. This text file 
should be generated when the user clicks on a certain link, and should not 
be stored on the server's HD. Any ideas as to how to go about doing this? 
Thanks!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Finding performance bottlenecks

2013-04-15 Thread Lamps902
Hi, group. I'd like to ask a very general question, but one of great 
utility: what are some ways to go about finding performance bottlenecks in 
your web2py page? What are some specific resource hogs and sources of 
diminished performance that you've encountered in your web2py pages (I 
imagine DB-related things come up quite a bit here)? Do you have any 
recommendations regarding how to address these issues? Thanks!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Finding performance bottlenecks

2013-04-15 Thread Lamps902
Thanks, Niphlod - great set of suggestions!

On Monday, April 15, 2013 1:57:34 PM UTC-5, Niphlod wrote:

 generally any db interaction takes some time that is the predominant 
 share of the response time, so usually you start from there.
 if you don't have an iper-complicated logic in the controller, the usual 
 suspects come in handy:
 - pre-compile app
 - use session.forget if you want concurrent requests (e.g., lot of ajax)
 - use cache wisely (can definitely be the most speedup-thingy to do)
 - tune the webserver accordingly to the stack you're using
 - move models to modules whenever possible
 - etc
 that are all more or less on the book.
 Don't forget static asset serving, even if not managed by web2py a bad 
 setting can slow down the page rendering quite a bit.

 On Monday, April 15, 2013 7:26:10 PM UTC+2, Lamps902 wrote:

 Hi, group. I'd like to ask a very general question, but one of great 
 utility: what are some ways to go about finding performance bottlenecks in 
 your web2py page? What are some specific resource hogs and sources of 
 diminished performance that you've encountered in your web2py pages (I 
 imagine DB-related things come up quite a bit here)? Do you have any 
 recommendations regarding how to address these issues? Thanks!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Using field names stored as strings for db actions?

2013-04-03 Thread Lamps902
I'd like to do something to this effect: 

fields = db.table1.fields()

table_rows = [ TR( TD(*[the label associated with the field]*), TD(db(*[the 
field]*  0).count()), _id = field + '__row') for field in fields ] 


Any suggestions? Thanks.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: new feature in trunk: pack custom

2013-04-03 Thread Lamps902
Thanks, Massimo - great feature! I was going to ask for something like 
this, as it's extremely useful for cases when you have a large upload 
folder, and would like to quickly back up the code, but not the 
user-uploaded files.

On Tuesday, April 2, 2013 3:22:50 PM UTC-5, Massimo Di Pierro wrote:

 Can you help me test this. In the main admin site page under [pack all] 
 there is a [pack custom] link. It allows you to select which files to 
 include/exclude in/from the w2p file. For example you can package 
 everything except the sqlite database.

 Suggestions for improvement?

 Massimo


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Using field names stored as strings for db actions?

2013-04-03 Thread Lamps902
Thanks to both of you!

On Wednesday, April 3, 2013 12:12:29 PM UTC-5, Anthony wrote:

 table_rows = [TR(field.label, db(field  0).count()), _id = field.name + 
 '__row') for field in db.table1]

 Note, you don't have to use TD() inside TR() -- it will automatically wrap 
 the TR's components inside TD's.

 Anthony

 On Wednesday, April 3, 2013 12:12:33 PM UTC-4, Lamps902 wrote:

 I'd like to do something to this effect: 

 fields = db.table1.fields()

 table_rows = [ TR( TD(*[the label associated with the field]*), TD(db(*[the 
 field]*  0).count()), _id = field + '__row') for field in fields ] 


 Any suggestions? Thanks.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] File uploads from different tables wih SQLFORM.factory - table name issue

2013-04-01 Thread Lamps902
If you have something like the following:

form = SQLFORM.factory(db.table1, db.table2)

and table1 has an 'upload' field named 'file1', with table2 containing an 
'upload' field named 'file2', the filenames stored in the tables will end 
up as 'no_table.file[number].[unique_file_identifier].[extension]. The 
'no_table' part can be changed by passing the 'tablename' argument to 
factory(), but this will not help when there are multiple uploads from 
different tables. Is there a straightforward way (i.e. by passing arguments 
to factory()) to make the upload file names correspond to their respective 
tables, or would that have to be handled manually? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: File uploads from different tables wih SQLFORM.factory - table name issue

2013-04-01 Thread Lamps902
Just realized a possible issue. It's simple enough to rename the strings 
that will become the database contents form 'no_table.[whatever]' to 
'table_name.[whatever]' (i.e. doing a replace() on the appropriate 
form.vars), but if your upload field definitions have uploadseparate = 
True, will this thwart the appropriate renaming of files through 
os.rename()* by making the file locations unpredictable when you have a 
large enough number of files? To remedy this, is it possible to specify 
what the name of the file should be before it is stored?

* as recommended by Anthony in this 
threadhttps://groups.google.com/forum/#!searchin/web2py/change$20name$20of$20file/web2py/yaVPY02Z2ZU/AbOyfW0k-ZQJ


On Monday, April 1, 2013 9:45:03 AM UTC-5, Niphlod wrote:

 there's no feature to leverage in the current code.
 After all, a factory is something ethereal where your code needs to 
 manage db interactions (and whatever needs to be done).

 SQLFORM.factory is just a shortcut:
 - to play with your current models
 - to save you defining a table just to generate a form ('cause you can 
 pass Field() to it)
 - have default validators available

 you can't expect more auto-magic features out of it You can use 
 _filter_fields() to see which table belongs the input name, as long as your 
 input names are distinct.

 On Monday, April 1, 2013 4:31:47 PM UTC+2, Lamps902 wrote:

 If you have something like the following:

 form = SQLFORM.factory(db.table1, db.table2)

 and table1 has an 'upload' field named 'file1', with table2 containing an 
 'upload' field named 'file2', the filenames stored in the tables will end 
 up as 'no_table.file[number].[unique_file_identifier].[extension]. The 
 'no_table' part can be changed by passing the 'tablename' argument to 
 factory(), but this will not help when there are multiple uploads from 
 different tables. Is there a straightforward way (i.e. by passing arguments 
 to factory()) to make the upload file names correspond to their respective 
 tables, or would that have to be handled manually? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: File uploads from different tables wih SQLFORM.factory - table name issue

2013-04-01 Thread Lamps902
Interesting. Will give it a shot. Thanks!

On Monday, April 1, 2013 12:26:09 PM UTC-5, Anthony wrote:

 You might try something like this:

 def upload():
 if request.post_vars:
 request.post_vars._formkey = SQLFORM(db.table1).process(formname=
 'uploads').formkey
 SQLFORM(db.table2).process(formname='uploads')
 request.post_vars.clear()
 form = SQLFORM.factory(db.table1, db.table2).process(formname=
 'uploads')
 return dict(form=form)

 That uses .factory() to create the HTML form, but standard SQLFORMs to 
 process the submitted data separately for each table. Note, when the 
 db.table1 form is processed, it will then overwrite the old _formkey value 
 in the session, so the new formkey has to be assigned to 
 request.post_vars._formkey before processing the db.table2 form (so it 
 matches the new formkey stored in the session). After processing, 
 request.post_vars is cleared so the files will not be re-saved when the 
 factory form is processed in the next line.

 Anthony

 On Monday, April 1, 2013 12:04:09 PM UTC-4, Lamps902 wrote:

 Just realized a possible issue. It's simple enough to rename the strings 
 that will become the database contents form 'no_table.[whatever]' to 
 'table_name.[whatever]' (i.e. doing a replace() on the appropriate 
 form.vars), but if your upload field definitions have uploadseparate = 
 True, will this thwart the appropriate renaming of files through 
 os.rename()* by making the file locations unpredictable when you have a 
 large enough number of files? To remedy this, is it possible to specify 
 what the name of the file should be before it is stored, or is there some 
 other approach that could be taken?

 * as recommended by Anthony in this 
 threadhttps://groups.google.com/forum/#!searchin/web2py/change$20name$20of$20file/web2py/yaVPY02Z2ZU/AbOyfW0k-ZQJ


 On Monday, April 1, 2013 9:45:03 AM UTC-5, Niphlod wrote:

 there's no feature to leverage in the current code.
 After all, a factory is something ethereal where your code needs to 
 manage db interactions (and whatever needs to be done).

 SQLFORM.factory is just a shortcut:
 - to play with your current models
 - to save you defining a table just to generate a form ('cause you can 
 pass Field() to it)
 - have default validators available

 you can't expect more auto-magic features out of it You can use 
 _filter_fields() to see which table belongs the input name, as long as your 
 input names are distinct.

 On Monday, April 1, 2013 4:31:47 PM UTC+2, Lamps902 wrote:

 If you have something like the following:

 form = SQLFORM.factory(db.table1, db.table2)

 and table1 has an 'upload' field named 'file1', with table2 containing 
 an 'upload' field named 'file2', the filenames stored in the tables will 
 end up as 'no_table.file[number].[unique_file_identifier].[extension]. The 
 'no_table' part can be changed by passing the 'tablename' argument to 
 factory(), but this will not help when there are multiple uploads from 
 different tables. Is there a straightforward way (i.e. by passing 
 arguments 
 to factory()) to make the upload file names correspond to their respective 
 tables, or would that have to be handled manually? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can file/upload field value be retained when form has errors/is not accepted?

2013-03-29 Thread Lamps902
Thanks for the advice, Niphlod. I really should go read a good book on 
relational db design...

On Thursday, March 28, 2013 3:48:23 PM UTC-5, Niphlod wrote:

 cause usually you want to retrieve metadata more than you need the actual 
 contents.
 It makes you more **sure** when you have to select the entire content vs 
 just the metadata attached.
 When you'll switch to storing the contents too on the table, that table 
 can be partitioned and optimized further (some db don't handle well by 
 default large binaries).
 Generally, every application now treats the uploads in an async way, so if 
 there is any data attached is better to separate roles in different 
 tables anyway.
 Having them separated leads to a separation of concerns in the first 
 place, so your app would be less lenient to, e.g. retrieve the file 
 contents and discard it without using it.

 On Thursday, March 28, 2013 5:48:35 PM UTC+1, Lamps902 wrote:

 Thanks, niphlod and Anthony - some good suggestions and considerations 
 mentioned there. niphlod - can you clarify why you recommend using separate 
 tables specifically for large files (to prevent users from having to 
 re-upload large files when forms aren't accepted?)? The async idea sounds 
 pretty good, although it would require a pretty considerable rewrite of a 
 lot of the code I have...

 On Thursday, March 28, 2013 11:19:06 AM UTC-5, Niphlod wrote:

 It's a bad design choice using a single table with lots of fields plus 
 an attachment (if the attachment is large).
 I always store attachments in a separate table.

 That being said, I don't think that keepvalues will do the trick, cause 
 basically keepvalues sends back to the client the contents and prefills the 
 field ... throwing the file back to the client doesn't **sound smart**. 
 However, it's a chicken-and-egg problem let's say you want to upload a 
 picture, you require the picture to have a tag, but the user forgets 
 it. in this case, retaining in some way the file can be done...
 But let's say you want the file to end with .txt only . the .exe 
 file should be discarded at all.
 It's up to you to provide logic consistent with the workflow you want 
 for your users . 
 /me would provide an async upload, store the id on the session and let 
 the user play with the remaining fields in a form.
 Everyday I'd prune all the attachments received with no remaining 
 fields attached. 

 On Thursday, March 28, 2013 5:08:24 PM UTC+1, Lamps902 wrote:

 When a form has errors, the value of an upload field is reset upon 
 submission. Is there a way to retain this value, or does this pretty much 
 have to be handled manually (i.e. by storing the value of the upload field 
 or by prompting the user to specify the file again)?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-28 Thread Lamps902
Thanks to both of you guys! After a much needed rest, I got it working with 
a solution comparable to what you guys specified/described. 

Anthony - I noticed the book's section on using the *host* and 
*scheme*parameters for URL(), but was a bit thrown off - is there a way to use 
URL() to point to a page (i.e. google.com) outside of your site (whatever 
tinkering I did with URL(), it was always appending or prepending some 
elements of my site's address to the URL pointing to another page)?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-28 Thread Lamps902
Got it. Thank you!

On Thursday, March 28, 2013 9:41:03 AM UTC-5, Anthony wrote:

 The URL() function is primarily intended for generating web2py URLs, not 
 external URLs. It will always add a controller and function (if none are 
 specified, it will use the controller and function of the current request).

 Anthony

 On Thursday, March 28, 2013 10:36:15 AM UTC-4, Lamps902 wrote:

 Thanks to both of you guys! After a much needed rest, I got it working 
 with a solution comparable to what you guys specified/described. 

 Anthony - I noticed the book's section on using the *host* and 
 *scheme*parameters for URL(), but was a bit thrown off - is there a way to 
 use 
 URL() to point to a page (i.e. google.com) outside of your site 
 (whatever tinkering I did with URL(), it was always appending or prepending 
 some elements of my site's address to the URL pointing to another page)?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Can file/upload field value be retained when form has errors/is not accepted?

2013-03-28 Thread Lamps902
When a form has errors, the value of an upload field is reset upon 
submission. Is there a way to retain this value, or does this pretty much 
have to be handled manually (i.e. by storing the value of the upload field 
or by prompting the user to specify the file again)?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can file/upload field value be retained when form has errors/is not accepted?

2013-03-28 Thread Lamps902
Thanks, niphlod and Anthony - some good suggestions and considerations 
mentioned there. niphlod - can you clarify why you recommend using separate 
tables specifically for large files (to prevent users from having to 
re-upload large files when forms aren't accepted?)? The async idea sounds 
pretty good, although it would require a pretty considerable rewrite of a 
lot of the code I have...

On Thursday, March 28, 2013 11:19:06 AM UTC-5, Niphlod wrote:

 It's a bad design choice using a single table with lots of fields plus an 
 attachment (if the attachment is large).
 I always store attachments in a separate table.

 That being said, I don't think that keepvalues will do the trick, cause 
 basically keepvalues sends back to the client the contents and prefills the 
 field ... throwing the file back to the client doesn't **sound smart**. 
 However, it's a chicken-and-egg problem let's say you want to upload a 
 picture, you require the picture to have a tag, but the user forgets 
 it. in this case, retaining in some way the file can be done...
 But let's say you want the file to end with .txt only . the .exe file 
 should be discarded at all.
 It's up to you to provide logic consistent with the workflow you want for 
 your users . 
 /me would provide an async upload, store the id on the session and let the 
 user play with the remaining fields in a form.
 Everyday I'd prune all the attachments received with no remaining fields 
 attached. 

 On Thursday, March 28, 2013 5:08:24 PM UTC+1, Lamps902 wrote:

 When a form has errors, the value of an upload field is reset upon 
 submission. Is there a way to retain this value, or does this pretty much 
 have to be handled manually (i.e. by storing the value of the upload field 
 or by prompting the user to specify the file again)?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] using a representation of an absolute URL to update a db?

2013-03-27 Thread Lamps902
Let's say you have an SQL grid generated from a db with field *my_url*, 
which stores the value of an absolute URL, and has a representation defined 
in this way: 

db.my_db.my_url.represent = lambda the_url, row: A(generate_link_image(), 
_href=the_url, _target='_blank')

What would be a good way to modify the above code so that when the link is 
clicked, some field in *my_db* (for example, *number_visited*, 
corresponding to the number of times the url has been clicked) is updated? 
I'm not sure you can use _href=URL(...) with absolute links, and other 
variants I've tried end up updating every record referenced in the table 
rather than just the one that the user clicks. Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] using the IS_URL validator with complex URLs

2013-03-27 Thread Lamps902
It seems that every once in a while, the IS_URL validator doesn't want to 
accept a URL that's valid. For example, I believe the ^ character prevents 
IS_URL from accepting something like 
http://finance.yahoo.com/q/hp?s=^IXIC+Historical+Prices. Is there a 
parameter to permit IS_URL to accept certain special characters, or that 
makes the validator 'less strict', so that it can accept URLs such as the 
one above? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] using the IS_URL validator with complex URLs

2013-03-27 Thread Lamps902
Thank you!

On Wednesday, March 27, 2013 1:44:08 PM UTC-5, Jonathan Lundell wrote:

 On 27 Mar 2013, at 11:25 AM, Lamps902 dhea...@gmail.com javascript: 
 wrote:

 It seems that every once in a while, the IS_URL validator doesn't want to 
 accept a URL that's valid. For example, I believe the ^ character prevents 
 IS_URL from accepting something like 
 http://finance.yahoo.com/q/hp?s=^IXIC+Historical+Priceshttp://finance.yahoo.com/q/hp?s=%5EIXIC+Historical+Prices.
  
 Is there a parameter to permit IS_URL to accept certain special characters, 
 or that makes the validator 'less strict', so that it can accept URLs such 
 as the one above? Thanks.



 IS_URL first checks the URL against RFC 2396, which requires '^' to be 
 escaped. I don't see a way to override it; better to URL-escape your URLs.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Lamps902
In the case that I'm dealing with, the image is incidental to the problem. 
But let's say there is an image, and a relative URL (i.e. file download); 
you can do something like this:

db.my_db.file.represent = lambda x,y: \
A(generate_image(y.file),
_href=URL(args=[my_db/download, x],vars = 
dict(action=update_download_number, id=y.id)))

Can't do this for absolute links. Maybe I'm misunderstanding your 
suggestion, but the same image generator function will be invoked for all 
of the rows in the table, so if I use that, all the rows end up being 
updated, as opposed to the one which should be updated. So basically, I 
think it comes down to how to go about creating a function that's invoked 
when an absolute link is clicked, and passing an identifier related 
specifically to that link to the function.

On Wednesday, March 27, 2013 2:41:16 PM UTC-5, Niphlod wrote:

 so, you have an url (i.e. a string) that needs to return an image.
 you should have a controller that, when that URI is matched, returns the 
 image after increasing its number_visited value seems pretty standard 
 to me

 On Wednesday, March 27, 2013 7:15:12 PM UTC+1, Lamps902 wrote:

 Let's say you have an SQL grid generated from a db with field *my_url*, 
 which stores the value of an absolute URL, and has a representation defined 
 in this way: 

 db.my_db.my_url.represent = lambda the_url, row: A(generate_link_image(), 
 _href=the_url, _target='_blank')

 What would be a good way to modify the above code so that when the link 
 is clicked, some field in *my_db* (for example, *number_visited*, 
 corresponding to the number of times the url has been clicked) is updated? 
 I'm not sure you can use _href=URL(...) with absolute links, and other 
 variants I've tried end up updating every record referenced in the table 
 rather than just the one that the user clicks. Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Lamps902
Thanks, Niphlod. It may require some digression/elaboration, so do you mind 
if I get in touch with you about this tomorrow? Hopefully, after I get some 
rest, I'll be able to articulate the issue a bit better...

On Wednesday, March 27, 2013 4:08:46 PM UTC-5, Niphlod wrote:

 uhm... I didn't quite understand, but it seems that you want different 
 things to happen when printing the url and when accessing the url.
 Why is hard separating printing a link logic from the accessing the 
 link one ?
 It's a common construct, i.e. on one page 

 click here to like the image

 and on another page

 -
 image
 -
 you liked this image

 the second page, either accessed as a relative or as an absolute url, 
 makes no difference from the web2py standpoint.

 If I totally missed your requirements, can you give a plain english 
 explanation on what you're trying to accomplish ?
 PS: I'm on gtalk for the next hour if this requires a long digression :P


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Rendering HTML code and {{...}}-delimited code stored in a variable?

2013-03-20 Thread Lamps902
It's possible to render HTML code stored in a variable with the XML() 
function. However, let's say you have something like the following scenario:

a href='{{=request.vars.the_link}}'{{=request.vars.the_link}}/a

or something like

stored_code = a href='request.vars.the_link'request.vars.the_link/a

Is there a way to get web2py to evaluate the variables and render the HTML 
with the evaluated values? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering HTML code and {{...}}-delimited code stored in a variable?

2013-03-20 Thread Lamps902
Both solutions work like a charm, guru - thanks! And come to think of it, 
the HTML helper solution is so much cleaner than the HTML route that I 
think I should reconsider that aspect of the page.

Also, thanks for the security warning. It wasn't production code, just an 
ad hoc example that popped up, probably thanks to the effects of priming, 
as I was doing something with request.vars.whatever just before that.

-Lamps

On Wednesday, March 20, 2013 1:15:01 PM UTC-5, guruyaya wrote:

 I think the best way to address this problem is using the A tag, like this:
 stored_code = A(request.vars.the_link, _href=request.vars.the_link)
 or, if you insist
 stored_code = XML(a href='%(link)s'%(link)s/a % {'link': 
 request.vars.the_link})

 PS - I sure hope it's not a code sample, cauz you're just screeming for 
 hackers to spam you with links to thier website.

 On Wednesday, March 20, 2013 7:16:14 PM UTC+2, Lamps902 wrote:

 It's possible to render HTML code stored in a variable with the XML() 
 function (i.e. if your variable is stored_code, do XML(stored_code)
 to render). However, let's say you have something like the following 
 scenario:

 stored_code = a href='{{=request.vars.the_link}}'{{=request.vars.
 the_link}}/a

 or something like

 stored_code = a href='request.vars.the_link'request.vars.the_link/a

 Is there a way to get web2py to evaluate the variables and render the 
 HTML with the evaluated values? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering HTML code and {{...}}-delimited code stored in a variable?

2013-03-20 Thread Lamps902
Thanks, Anthony. I think this is exactly what I was asking about. I'll try 
it out now.


On Wednesday, March 20, 2013 1:39:21 PM UTC-5, Anthony wrote:


 stored_code = a href='{{=request.vars.the_link}}'{{=request.vars.
 the_link}}/a

 It sounds like there might be better options, but if for some reason you 
 need to execute stored template code as above, I think you can do something 
 like:

 from gluon.template import render
 html = render(stored_code, context=globals())

 Specifying context=globals() should ensure that the request object and any 
 other global objects are available for reference within the template code. 
 You could also specify a dictionary or Storage object including just the 
 objects you need:

 from gluon.template import render
 stored_code = a href='{{=the_link}}'{{=the_link}}/a
 html = render(stored_code, context=request.vars))

 Anthony


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] auth_event table not updating

2013-03-18 Thread Lamps902
Looking at my application's databases, it seems that the auth_event table 
was last updated quite some time ago. I'm not sure what changes I made to 
the code which could have caused the application to stop logging events to 
auth_event. Is there anything I should check in my database 
definitions/auth settings code? Any ideas about what the source of the 
problem could be? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] enable_record_versioning() - possible to update archive only after deletion?

2013-03-13 Thread Lamps902
At present, auth._enable_record_versioning and 
db.table._enable_record_versioning 
update a record every time something is modified or deleted (including the 
flipping of the *is_active* field). Is there a way to use the functionality 
provided by these functions to update an archive only upon deletion of 
records, ignoring changes that do not remove the record from the original 
database or don't flip the *is_active* bit? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: enable_record_versioning() - possible to update archive only after deletion?

2013-03-13 Thread Lamps902
Thanks, Niphlod! Will give it a go.

-Lamps

On Wednesday, March 13, 2013 6:12:41 PM UTC-5, Niphlod wrote:

 use callbacks it's not automatic as the archive functionality (that 
 basically sets smarts callbacks for you) but it's definitely 
 accomplishable.

 http://web2py.com/books/default/chapter/29/06#before-and-after-callbacks

 On Wednesday, March 13, 2013 7:27:16 PM UTC+1, Lamps902 wrote:

 At present, auth._enable_record_versioning and 
 db.table._enable_record_versioning 
 update a record every time something is modified or deleted (including 
 the flipping of the *is_active* field). Is there a way to use the 
 functionality provided by these functions to update an archive only upon 
 deletion of records, ignoring changes that do not remove the record from 
 the original database or don't flip the *is_active* bit? Thanks.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Automated IP logging?

2013-03-13 Thread Lamps902
Is there an automated way to log the IPs associated with the 
initiatialization and clearing of each session (i.e. when a user logs 
in/logs out), or does this have to be accomplished manually through the use 
of request.client and some auth.settings variable (i.e. 
auth.settings.login_onaccept)? If it's the latter, what would be the best 
choice of auth.settings vars to use for this purpose? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Creating a DB that mirrors the structure of an existing DB for archiving purposes?

2013-03-12 Thread Lamps902
Hi, group. For each database in a subset of my project's databases, I would 
like to have a corresponding database that (almost) clones the structure of 
the original database. The mirror databases will be used to archive records 
that have been deleted from the original databases.

For example, if I have db1 as the original database, with fields *id 
*(automatically 
generated)*, field1, field2, and field3*, db1_archive will have fields *id 
*(automatically 
generated)*, original_id *(which will store the contents of db1's id field)*, 
field1, field2, and field3.*

The structure of an archive database should be updated automatically 
whenever the structure of the original database is modified. Can anyone 
recommend a good way to go about doing this? 

Also, is there a quick one/two-liner to transfer db (original) records to 
db (archive) upon deletion from db (original), taking into account the 
discrepancies in the *id *fields? Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Creating a DB that mirrors the structure of an existing DB for archiving purposes?

2013-03-12 Thread Lamps902
Thanks, guys - this appears to be exactly what I needed! Is it generally a 
good idea, as far as performance goes, to store the archived entries in a 
separate database, as opposed to the original *db*?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Real-Time Scanning of File Upload Sizes Possible?

2013-03-01 Thread Lamps902
I've found this tip from Massimo on checking file upload progress:

In the upload form add 

 

input type='hidden' name='X-Progress-ID' value='test'/


def upload_page():
 ...
 length_bytes = cache.ram('X-Progress-ID:test:length',None,0)

 uploaded_bytes = cache.ram('X-Progress-ID:test:uploaded',None,0)
 ...


 However, I'm not certain how to go about using that to cut off the file 
upload once it reaches some size limit. Can anyone help me out on this? 
Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Real-Time Scanning of File Upload Sizes Possible?

2013-02-28 Thread Lamps902
Hi, group. Is there a way to scan file uploads in real-time, and cut off 
the file upload if it exceeds a certain size? Thank you.

-Lamps

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do you check user-uploaded files for malware?

2013-02-01 Thread Lamps902
Thanks, Massimo, I'll check it out.

-Lamps

On Friday, February 1, 2013 11:19:12 AM UTC-5, Massimo Di Pierro wrote:

 Look into the IS_IMAGE validator. You can do something like that and 
 search for specific strings into the uploaded file.

 On Thursday, 31 January 2013 06:50:05 UTC-6, Lamps902 wrote:

 Has anybody had success using a malware/virus-scanning module/tool to 
 scan user-uploaded files on their web2py page? Any suggestions as to how to 
 go about doing this? Thanks!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Preferred method for banning email domains from registering?

2013-01-31 Thread Lamps902
Hi, web2py users. Is there a preferred method for banning a set of email 
domains from registering? I know that the IS_EMAIL() validator has a 
banned parameter, but is this the best way to go about this task? If so, 
is there a way to pass multiple domains to the banned parameter (I don't 
think it accepts a list)? Also, is this: 
('^.*\domain_you_want_to_ban.com(|\..*)$') a reasonable regex for this 
purpose? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How do you check user-uploaded files for malware?

2013-01-31 Thread Lamps902
Has anybody had success using a malware/virus-scanning module/tool to scan 
user-uploaded files on their web2py page? Any suggestions as to how to go 
about doing this? Thanks!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Redirect from inside a component

2013-01-31 Thread Lamps902
Why not use the process() method's next parameter? 
http://web2py.com/books/default/chapter/29/07?search=.accepted#The-process-and-validate-methods

Otherwise, there's redirect() - 
http://web2py.com/books/default/chapter/29/07?search=redirect%28#Forms-and-redirection
 


On Thursday, January 31, 2013 4:18:37 AM UTC-5, Loïc wrote:

 Hello All,

 I have a question about my application organized as follows:
 *A main page : render_page
 *A component load_newsletter. This component displays a form with an 
 email field and a submit button

 What I want to do : 
 When the user fill the form in my component load_newsletter, I want to 
 redirect the main page to an other page (full_newsletter)
 This other page contains a more complete form to add some information

 I don't know if I can redirect the page which contains a component, from 
 inside this component?

 Example of code:

 ##  View render_page.html  ##
 {{extend 'layout.html'}}
 {{block right_sidebar}}
 {{=LOAD('default','load_newsletter.html',ajax=True)}} 
 {{end}}
 ###

 ##  Controller load_newsletter  ##
 form=FORM(DIV(T('Your email'), _class='blueText'),
 INPUT(_name='email', _type='email', 
 requires=IS_NOT_EMPTY()),
 INPUT(_type='submit'))
 if form.process().accepted:
 #  Here I want to redirect the page which contains me to 
 full_newsletter 
 elif form.errors:
 response.flash = T('There was an error in the form')
 return dict(form=form)
 ###

 Thank you for your help



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Preferred method for banning email domains from registering?

2013-01-31 Thread Lamps902
Yep, just tried it, and it appears to be working well! Thanks a lot, Andrew.

-Lamps

On Thursday, January 31, 2013 10:31:22 AM UTC-5, Andrew Buchan wrote:

 Lamps,

 I believe using banned is the best way of doing it. You would cover 
 multiple domains in the regex. 

 The following snippet would ensure that addresses ending in gmail.com or 
 hotmail.com fail registration...

 auth_table.email.requires = [
   IS_EMAIL(error_message=auth.messages.invalid_email, 
 banned='^.*gmail\.com$|^.*hotmail\.com$'),  
   IS_NOT_IN_DB(db, auth_table.email)
   ]

 Remember that the model files are plain python, so you could build up the 
 regex string from a list or external source before passing it to as a 
 parameter.

 regards,

 Andy.


 On Thursday, January 31, 2013 12:29:18 PM UTC, Lamps902 wrote:

 Hi, web2py users. Is there a preferred method for banning a set of email 
 domains from registering? I know that the IS_EMAIL() validator has a 
 banned parameter, but is this the best way to go about this task? If so, 
 is there a way to pass multiple domains to the banned parameter (I don't 
 think it accepts a list)? Also, is this: 
 ('^.*\domain_you_want_to_ban.com(|\..*)$') 
 a reasonable regex for this purpose? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-30 Thread Lamps902
Jim - a much nicer solution came to mind that would be useful if you don't 
need those fields to be checkboxes at any other point in your program. You 
can probably do this in the model:

Field('rebates_tiered', represent=INPUT(_type='button'), ...)

Sorry not to think of it sooner. Probably an availability heuristic issue, 
given that I tend to change elements (including type) in the controller 
pretty regularly.

-Lamps

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Lamps902
Thank you for the replies, guys! I think my abstract/trivial example may 
have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
in combination with a custom validator (yet to be fully written) to make it 
so that all the elements of a dropdown menu/select are taken from a given 
set of options (a list of file formats), and for the selected option (file 
format), the custom validator will make sure the file is in that format. 
Something like this might be a better description than the initial post:

Field('f_file_format, type='list:string', 
  
requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
selection'), error_message=T(some_error_message)),
  CUSTOM_VALIDATOR(request.vars.f_file_format, 
request.vars.file, error_message=T(some_error_message2))]

 )

To clarify - I'm not seeking to let the user be able to select multiple 
options from the drop down list. Maybe it's better to implement the custom 
validator functionality I'm looking for in the controller, or can it be 
done in the model? Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Lamps902
Thanks, Anthony. I was under the impression that list:string is the 
convention if you want the field to render as a selector with SQLFORM(). 
You're right that it's possible to change the field from list:string to 
string and use IS_IN_SET() to maintain the field as a select element. 
However, I still cannot apply a list of validators after doing this. Having 
changed the field from list:string to string, when I apply the validators 
as such: Field(... requires=[IS_IN_SET(...)] ...), SQLFORM now renders the 
field as an input field rather than a drop-down menu/select element. 

On Tuesday, January 29, 2013 9:39:09 AM UTC-5, Anthony wrote:

 If you don't want to allow the user to select multiple options, then why 
 is the field type list:string rather than just string? If you make it just 
 a string type, then you will be able to apply a list of validators, as 
 below.

 Anthony

 On Tuesday, January 29, 2013 5:39:59 AM UTC-5, Lamps902 wrote:

 Thank you for the replies, guys! I think my abstract/trivial example may 
 have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
 in combination with a custom validator (yet to be fully written) to make it 
 so that all the elements of a dropdown menu/select are taken from a given 
 set of options (a list of file formats), and for the selected option (file 
 format), the custom validator will make sure the file is in that format. 
 Something like this might be a better description than the initial post:

 Field('f_file_format, type='list:string', 
   
 requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
 selection'), error_message=T(some_error_message)),
   CUSTOM_VALIDATOR(request.vars.f_file_format, 
 request.vars.file, error_message=T(some_error_message2))]

 )

 To clarify - I'm not seeking to let the user be able to select multiple 
 options from the drop down list. Maybe it's better to implement the custom 
 validator functionality I'm looking for in the controller, or can it be 
 done in the model? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
Hi, Jim. What about doing the following:

form.elements('input',_id='checkbox_field_n')[0]['_type'] = 'button'


I imagine the value can then be toggled with, for example, javascript's 
'onclick' functionality, and stored in the db as usual.

On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want to 
 change them to buttons instead of checkboxes so I can use the bootstrap 
 button widgets.  How can I chance the boolean widget from a checkbox to a 
 button and have the value properly put back into the database?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
Just tried the code I posted above with IE 9, and it did change the 
checkbox to a button. Did you give it a shot?


On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change the 
 type of an element.  Therefore, I need to generate it as a type=button 
 from the start.  The bootstrap example also shows this as a button 
 element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, javascript's 
 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I want 
 to change them to buttons instead of checkboxes so I can use the bootstrap 
 button widgets.  How can I chance the boolean widget from a checkbox to a 
 button and have the value properly put back into the database?



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
It looks like you might be sort of conflating javascript and python code 
there. Before you do anything with javascript, modify the checkbox element 
in the [controller_name].py file, as I described above. For example, if you 
used SQLFORM() to generate your form from a database table, in your 
controller, you should have something like:

form = SQLFORM( ... )
form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

This will turn the checkbox with the id rebates_tiered into a button. 
Then, whatever functionality you need from javascript, if any, is 
implemented in the appropriate view (html) file.

On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('input',_id='rebates_tiered')[0]['_type'] = 
 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the 
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to change 
 the type of an element.  Therefore, I need to generate it as a 
 type=button from the start.  The bootstrap example also shows this as a 
 button element and not an input.  Not sure if that is relevant though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**checkbox_field_n')[0]['_type'] = 'button'


 I imagine the value can then be toggled with, for example, 
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I 
 want to change them to buttons instead of checkboxes so I can use the 
 bootstrap button widgets.  How can I chance the boolean widget from a 
 checkbox to a button and have the value properly put back into the 
 database?

  -- 
  
 --- 

  




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Can I change a boolean field widget to a button?

2013-01-29 Thread Lamps902
No problem. I think I see where the misunderstanding came from - it's 
possible that javascript can't be used to change an element's type in IE, 
since that would be done after the element has been rendered. In the python 
controller, the element's type is changed before the element is rendered, 
so there's no problem. Glad it worked out!


On Tuesday, January 29, 2013 9:11:31 PM UTC-5, Jim S wrote:

 Yup, worked just as you stated.  Thanks for carrying me along...

 -Jim


 On Tue, Jan 29, 2013 at 8:02 PM, Jim Steil ato@gmail.comjavascript:
  wrote:

 Yes, I was thinking this was javascript code.  Sorry I missed that, it's 
 been a long day...


 On Tue, Jan 29, 2013 at 7:59 PM, Lamps902 dhea...@gmail.comjavascript:
  wrote:

 It looks like you might be sort of conflating javascript and python code 
 there. Before you do anything with javascript, modify the checkbox element 
 in the [controller_name].py file, as I described above. For example, if you 
 used SQLFORM() to generate your form from a database table, in your 
 controller, you should have something like:

 form = SQLFORM( ... )
 form.elements('input',_id='rebates_tiered')[0]['_type'] = 'button'

 This will turn the checkbox with the id rebates_tiered into a button. 
 Then, whatever functionality you need from javascript, if any, is 
 implemented in the appropriate view (html) file.


 On Tuesday, January 29, 2013 8:16:04 PM UTC-5, Jim S wrote:

 Please forgive me for not knowing this, but here is what I tried:

 $('.web2py_form').elements('**input',_id='rebates_tiered')[**0]['_type'] 
 = 'button';

 But, I get:

 TypeError: $(...).elements is not a function

 Any clues on what I'm specifying incorrectly?

 -Jim

 On Tuesday, January 29, 2013 2:14:51 PM UTC-6, Jim S wrote:

 Nope, but will now!

 Thanks

 -Jim

 On Tue, Jan 29

 Just tried the code I posted above with IE 9, and it did change the 
 checkbox to a button. Did you give it a shot?



 On Tuesday, January 29, 2013 2:00:45 PM UTC-5, Jim S wrote:

 The research I've done is telling me that IE won't allow you to 
 change the type of an element.  Therefore, I need to generate it as a 
 type=button from the start.  The bootstrap example also shows this as 
 a 
 button element and not an input.  Not sure if that is relevant 
 though.

 -Jim

 On Tuesday, January 29, 2013 12:53:50 PM UTC-6, Lamps902 wrote:

 Hi, Jim. What about doing the following:

 form.elements('input',_id='**che**ckbox_field_n')[0]['_type'] = 
 'button'


 I imagine the value can then be toggled with, for example, 
 javascript's 'onclick' functionality, and stored in the db as usual.

 On Tuesday, January 29, 2013 11:46:55 AM UTC-5, Jim S wrote:

 I have a form that is going to hold a number of boolean fields.  I 
 want to change them to buttons instead of checkboxes so I can use the 
 bootstrap button widgets.  How can I chance the boolean widget from a 
 checkbox to a button and have the value properly put back into the 
 database?

  -- 
  
 --- 

  


  -- 
  
 --- 
 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 javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  





-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-29 Thread Lamps902
Yep, that took care of it. Thanks a lot!

-Lamps

On Tuesday, January 29, 2013 10:56:41 PM UTC-5, Anthony wrote:

 The IS_IN_DB validator takes an _and argument to get around this problem, 
 but there is no _and argument for IS_IN_SET(). Instead, you can explicitly 
 set the widget for the field:

 Field('f_file_format,
 requires=[IS_IN_SET(list_of_acceptable_options), 
 CUSTOM_VALIDATOR(...)],
 widget=SQLFORM.widgets.options.widget)

 As long as the IS_IN_SET validator is the first one in the list, the 
 widget will build its options using the IS_IN_SET options.

 For more on widgets, see 
 http://web2py.com/books/default/chapter/29/07#Widgets.

 Anthony

 On Tuesday, January 29, 2013 1:36:24 PM UTC-5, Lamps902 wrote:

 Thanks, Anthony. I was under the impression that list:string is the 
 convention if you want the field to render as a selector with SQLFORM(). 
 You're right that it's possible to change the field from list:string to 
 string and use IS_IN_SET() to maintain the field as a select element. 
 However, I still cannot apply a list of validators after doing this. Having 
 changed the field from list:string to string, when I apply the validators 
 as such: Field(... requires=[IS_IN_SET(...)] ...), SQLFORM now renders the 
 field as an input field rather than a drop-down menu/select element. 

 On Tuesday, January 29, 2013 9:39:09 AM UTC-5, Anthony wrote:

 If you don't want to allow the user to select multiple options, then why 
 is the field type list:string rather than just string? If you make it just 
 a string type, then you will be able to apply a list of validators, as 
 below.

 Anthony

 On Tuesday, January 29, 2013 5:39:59 AM UTC-5, Lamps902 wrote:

 Thank you for the replies, guys! I think my abstract/trivial example 
 may have obfuscated things a bit. I'm trying to use the IS_IN_SET() 
 validator in combination with a custom validator (yet to be fully written) 
 to make it so that all the elements of a dropdown menu/select are taken 
 from a given set of options (a list of file formats), and for the selected 
 option (file format), the custom validator will make sure the file is in 
 that format. Something like this might be a better description than the 
 initial post:

 Field('f_file_format, type='list:string', 
   
 requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
 selection'), error_message=T(some_error_message)),
   CUSTOM_VALIDATOR(request.vars.f_file_format, 
 request.vars.file, error_message=T(some_error_message2))]

 )

 To clarify - I'm not seeking to let the user be able to select multiple 
 options from the drop down list. Maybe it's better to implement the custom 
 validator functionality I'm looking for in the controller, or can it be 
 done in the model? Thank you.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Is it possible to use IS_IN_SET() in combination with other validators to validate a list?

2013-01-28 Thread Lamps902
Hi, web2py users. In my model, I've got a field of type list:string which 
I'm trying to validate. The field is defined as follows:

Field('f_field_name', type='list:string', 
   
 requires=IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), 
 error_message=T(some_error_message)))


This renders perfectly well as a select element/drop-down menu when the 
table that contains it is passed to SQLFORM(). However, if I pass a list of 
validators to requires, the list renders as an unordered list containing 
an input box and a javascript:void(0) reference. For instance, the 
following trivial example would render in the fashion described:

Field('f_field_name', type='list:string', 
   
 requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), 
 error_message=T(some_error_message)),
   
 IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), 
 error_message=T(some_error_message))]
 )


Any ideas as to what the issue could be? Any recommendations on how to use 
IS_IN_SET() in combination with another validator? Thanks!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] List items not loading in profile form

2013-01-10 Thread Lamps902
Hi, group. My user_auth model includes list fields such as the user's home 
country and home state, which are declared thus:

  Field 
http://127.0.0.1:8000/examples/global/vars/Field('home_state',type=list:string,length=2,
 label=T http://127.0.0.1:8000/examples/global/vars/T('Home State'), 
 requires=IS_EMPTY_OR 
 http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IN_SET 
 http://127.0.0.1:8000/examples/global/vars/IS_IN_SET(state_list,  ))),   
   Field 
 http://127.0.0.1:8000/examples/global/vars/Field('home_country',type=list:string,
  label=T http://127.0.0.1:8000/examples/global/vars/T('Home Country'), 
 requires=IS_EMPTY_OR 
 http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IN_SET 
 http://127.0.0.1:8000/examples/global/vars/IS_IN_SET(country_list,  ))), 


The profile form on my page is called up with auth_form = auth(), and some 
cosmetic customization is performed on the form here and there, and the 
default functionality is generally left intact. However, the select / 
list fields (i. e. state, country) come up empty in the profile. As things 
stand, the user is either forced to re-enter the data, or overwrite the 
data in these fields with empty values when saving the form. There may be 
something obvious here that I'm overlooking, or maybe something subtle. Any 
ideas as to how to address this issue? Thank you.

-- 





[web2py] Modifying auth.navbar

2012-12-27 Thread Lamps902
Hi, group. Is there a straightforward way to modify web2py's navbar? I 
would like to customize the default navbar so that it redirects to a custom 
'register' function when that option is selected, keeping all other 
functionality as it is. Thanks!

-- 





[web2py] Re: Modifying auth.navbar

2012-12-27 Thread Lamps902
Thanks, Anthony. Made the necessary changes.

-Lamps

On Thursday, December 27, 2012 6:51:01 AM UTC-8, Anthony wrote:

 if not auth.user:
 auth.navbar()[3]['_href'] = URL('register')

 auth.navbar() simply returns a SPAN object containing the navbar elements, 
 so it can be manipulated via the server-side 
 DOMhttp://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing
 .

 Anthony

 On Thursday, December 27, 2012 9:32:30 AM UTC-5, Lamps902 wrote:

 Hi, group. Is there a straightforward way to modify web2py's navbar? I 
 would like to customize the default navbar so that it redirects to a custom 
 'register' function when that option is selected, keeping all other 
 functionality as it is. Thanks!



-- 





[web2py] Re: web2py forum solutions

2012-11-27 Thread Lamps902
Thanks, Ales. However, it appears to be more of a self-contained/standalone 
solution than something that can be readily integrated into an existing 
web2py page. Anything else out there that matches the criteria?

-Lamps


On Monday, November 26, 2012 3:19:52 PM UTC-5, LightDot wrote:

 Well, there is a forum written in web2py.

 Take a look - http://pyforum.org/

 I haven't used it for more than to test it out, perhaps someone else will 
 have additional feedback.

 Regards,
 Ales

 On Monday, November 26, 2012 8:16:51 PM UTC+1, Lamps902 wrote:

 Hi, group. What are some options for forums/message boards that can be 
 readily integrated into a web2py page (i.e. forum solutions that can be 
 wholly contained within your page's content window, maintain the integrity 
 of your page's theme, and have access to the page's DB - preferably with 
 minimal fuss)? Thank you.



-- 





[web2py] web2py forum solutions

2012-11-26 Thread Lamps902
Hi, group. What are some options for forums/message boards that can be 
readily integrated into a web2py page (i.e. forum solutions that can be 
wholly contained within your page's content window, maintain the integrity 
of your page's theme, and have access to the page's DB - preferably with 
minimal fuss)? Thank you.

-- 





[web2py] Preventing 'back' button from clearing session

2012-11-12 Thread Lamps902
Sorry to ask something so seemingly basic, but it's posing quite an issue 
at the moment. I've got a back button that is set to appear when a DB query 
doesn't result in any items being returned (i.e. a grid is blank). The 
button is implemented like this:

back_button_form = FORM(INPUT(_type='submit',_value=T('Back'),_id=
'back_button'),_name='back_form',_id='back_form',_action='grid_search')

Clicking on this returns the user to the grid, but clears the session 
variables, which is problematic as session is being used to store the 
user's search terms. Is it a normal web2py behaviour that session is 
cleared when the user is redirected, whether to request.env.http_referer or 
to another page, or could it be something idiosyncratic that's going on 
with my site (I've checked for code that could be doing it, but have not 
been able to find anything that could be responsible)? Is there a way to 
retain the session values, or preferably, to prevent them from being 
cleared? Thank you.

-- 





[web2py] Re: Is it possible to submit multiple forms with one submit button?

2012-11-04 Thread Lamps902
Thanks. Took care of it by having a form with a submit button and a bunch 
of hidden fields, and a bunch of forms with a single input field, in the 
headers. When the submit' button is pressed on the form with the hidden 
fields, the values from the other forms are copied to its corresponding 
fields, and all of the necessary vars are passed via get. So that's 
basically how I went about implementing a multi filter with input fields 
under the headers for web2py's grid, though I'm sure there's a better way...

-Lamps

On Sunday, November 4, 2012 11:41:58 AM UTC-5, howesc wrote:

 i suspect there are a couple of options here, though i encourage you to 
 think carefully before implementing them (i assume that there is good 
 reason why forms still work the way they do).

  - you can create a button with an onclick action that will collect data 
 from various input fields and post it to the server in one or more AJAX 
 calls
  - sure you can create one large form, but you'll need to carefully name 
 all the input fields so that you know what is what.

 On Saturday, November 3, 2012 7:44:06 AM UTC-7, Lamps902 wrote:

 I have a grid in which I'd like to put a form between each column 
 header/label. Is it possible to submit and pass the data from all of these 
 forms with a single submit button? Tried a couple of jquery solutions, but 
 it wasn't quite working out.

 Alternatively, is it possible to make a single form and split its input 
 fields among the column headers?

 Thanks.



-- 





[web2py] Is it possible to submit multiple forms with one submit button?

2012-11-03 Thread Lamps902
I have a grid in which I'd like to put a form between each column 
header/label. Is it possible to submit and pass the data from all of these 
forms with a single submit button? Tried a couple of jquery solutions, but 
it wasn't quite working out.

Alternatively, is it possible to make a single form and split its input 
fields among the column headers?

Thanks.

-- 





Re: [web2py] How to implement multiple filter for grid?

2012-11-01 Thread Lamps902
I've followed Jim's model in creating my search filter, and it appears to 
be working beautifully! Just have some questions that I would like to ask. 
First - I slightly modified the selector code so that entries show up as 
unique, by adding the distinct clause and ordering alphabetically by 
category, by doing the following:


category_list = db().select(db.t_files.f_category, distinct=True, 
orderby=db.t_files.f_category)
options = [OPTION(category_list[i].f_category, 
  _value=str(category_list[i].f_category)) for i inrange
(len(category_list))]

Will this become extremely inefficient and slow, and grind the system to a 
halt as the database become large?

The second question concerns an important cosmetic change  - is there a 
good way to put the filter input fields (no labels) under the column 
headers/labels in the grid?

Finally, if you wanted to redesign the filters to update after a certain 
number of characters have been modified in an input field (i.e. without 
having to click search), how would you go about doing that?

Thanks again!

-Lamps

On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:

 I'm attaching a quick-n-dirty search example.  You'll have to provide your 
 own data to get it running.  It worked with my test data.  Let me know if 
 you have troubles and I'll be glad to work through them with you.

 -Jim

 On Wed, Oct 31, 2012 at 8:53 AM, Lamps902 dhea...@gmail.com javascript:
  wrote:

 Hi, Jim. It would be great if you could provide more details and some 
 code illustrating how you went about doing it. Thanks!

 -Lamps


 On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:

 Using .smartgrid, I override the default filtering capabilities and 
 provide my own.  See attached screenshot.  Let me know if you want more 
 details.  I think I uploaded a small example app to the list some time ago 
 and should be able to find it or recreate it if you like.

 -Jim

 On Wednesday, October 31, 2012 8:33:52 AM UTC-5, Lamps902 wrote:

 Hi, Johann - I know you can build a complex query using the search box, 
 but that is far from intuitive for most users. I'd like to implement the 
 same look/feel/usability as was available in webgrid, and as is shown in 
 the image. Is there a reasonable way to do this? Thanks.

 -Lamps

 On Wednesday, October 31, 2012 2:40:05 AM UTC-4, Johann Spies wrote:

 You can do that by building a complex query using the search box.

 Regards
 Johann


 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)

  -- 
  
  
  




-- 





Re: [web2py] How to implement multiple filter for grid?

2012-11-01 Thread Lamps902
Regarding the first point, the concern is not that the selector (as defined 
in the DB model) is instantiated with a huge variety of fields. If I'm not 
mistaken, if the distinct keyword in the select() function is left out, 
the program literally goes through every entry in the DB that matches the 
search criteria. I suspect that it does the same thing when distinct is 
used, and adds the additional step of filtering them down to the unique 
entries. I'm guessing this process may be quite resource intensive for a 
large DB. If there were a way to get the list of possible selector options 
straight from the model definition, that would seem to be much more 
efficient way of doing it (with the minor downside that there may not yet 
be any DB entries that match a given selector option), but I haven't found 
a way to do this.

I guess I may need to start a new thread for the second point - might bring 
up some good tips on how to customize the grid. Thanks for the suggestion 
about the widget; I'll check it out. And thanks again for all the help - 
saved a tremendous amount of time on this task, and I'm sure others will 
find it useful as well!

-Lamps


On Thursday, November 1, 2012 12:44:26 PM UTC-4, Jim S wrote:

 Lamps

 Wish I could be more help with your questions.  Here is my take.

 1.  If you are thinking about having a large list, I would try to avoid 
 that.  Maybe your DISTINCT keyword will keep the list small.  My thoughts 
 are that a long list (25 entries or more) is not very user friendly and if 
 I had that situation, I'd just use the search box and filter on the fields 
 base on the text entered.

 2.  I don't see how you'd be able to do this very easily.  Can probably be 
 done, but you'd have to get into /gluon/sqlhtml.py and make some changes 
 there to implement.

 3.  I think you could probably do this.  If it were me doing it I'd look 
 into the suggest_widget plugin available from 
 http://dev.s-cubism.com/plugin_suggest_widget.

 Best of luck!  Sorry I couldn't be more helpful.

 -Jim

 On Thu, Nov 1, 2012 at 11:35 AM, Lamps902 dhea...@gmail.com javascript:
  wrote:

 I've followed Jim's model in creating my search filter, and it appears to 
 be working beautifully! Just have some questions that I would like to ask. 
 First - I slightly modified the selector code so that entries show up as 
 unique, by adding the distinct clause and ordering alphabetically by 
 category, by doing the following:


 category_list = db().select(db.t_files.f_category, distinct=True, 
 orderby=db.t_files.f_category)
 options = [OPTION(category_list[i].f_category, 
   _value=str(category_list[i].f_category)) for i inrange
 (len(category_list))]

 Will this become extremely inefficient and slow, and grind the system to 
 a halt as the database become large?

 The second question concerns an important cosmetic change  - is there a 
 good way to put the filter input fields (no labels) under the column 
 headers/labels in the grid?

 Finally, if you wanted to redesign the filters to update after a certain 
 number of characters have been modified in an input field (i.e. without 
 having to click search), how would you go about doing that?

 Thanks again!

 -Lamps

 On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:

 I'm attaching a quick-n-dirty search example.  You'll have to provide 
 your own data to get it running.  It worked with my test data.  Let me know 
 if you have troubles and I'll be glad to work through them with you.

 -Jim


 On Wed, Oct 31, 2012 at 8:53 AM, Lamps902 dhea...@gmail.com wrote:

 Hi, Jim. It would be great if you could provide more details and some 
 code illustrating how you went about doing it. Thanks!

 -Lamps


 On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:

 Using .smartgrid, I override the default filtering capabilities and 
 provide my own.  See attached screenshot.  Let me know if you want more 
 details.  I think I uploaded a small example app to the list some time 
 ago 
 and should be able to find it or recreate it if you like.

 -Jim

 On Wednesday, October 31, 2012 8:33:52 AM UTC-5, Lamps902 wrote:

 Hi, Johann - I know you can build a complex query using the search 
 box, but that is far from intuitive for most users. I'd like to 
 implement 
 the same look/feel/usability as was available in webgrid, and as is 
 shown 
 in the image. Is there a reasonable way to do this? Thanks.

 -Lamps

 On Wednesday, October 31, 2012 2:40:05 AM UTC-4, Johann Spies wrote:

 You can do that by building a complex query using the search box.

 Regards
 Johann


 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)

  -- 
  
  
  


  -- 
  
  
  




-- 





[web2py] Is there a way to put a grid's search form beneath the column headers of a grid?

2012-11-01 Thread Lamps902
In a previous 
threadhttps://groups.google.com/forum/#!searchin/web2py/filter/web2py/oH7eMYNHt6Y/Izss3tRfTOkJ,
 
we discussed how to implement multiple search filter fields for a grid. 
That being done, I'm curious if there's a reasonable way to put the filters 
(all currently part of a single FORM) under their corresponding column 
headers in the grid. This 
linkhttp://www.web2pyslices.com/main/static/share/images/webgrid.jpgis an 
example of the look that I was going for. Thanks.

-- 





Re: [web2py] How to implement multiple filter for grid?

2012-11-01 Thread Lamps902
Hi, Niphlod. If I understood correctly, you're saying that 
.select(distinct=True) on a large db does indeed require a lot of 
resources, but all of the heavy work is done by the server, rather than the 
client's computer, and that web2py doesn't have an inbuilt way around it. 
That sort of heavy lifting is indeed, something to be avoided if possible. 

I guess you can avoid the problem by keeping duplicates of the options 
lists/sets somewhere that's easily accessible - this takes up more 
space/requires more administrative effort, but the decrease in utilization 
of server resources should be worth it. Thank you for the clarification.

-Lamps


On Thursday, November 1, 2012 3:57:42 PM UTC-4, Niphlod wrote:

 only on the db part. select(distinct=...) sends a different query to the 
 db than select(). It's not web2py that uniquify the sets of the record 
 returned to make it distinct.
 Then.
 It's true that doing a distinct on a million rows table forces the db to 
 scan through a million of rows but doing distinct
 a) the db doesn't need to return one million of rows to your program 
 (wire transfer from db to app is less bulky)
 b) your program doesn't need to load it into memory and transform it in a 
 SELECT widget

 Last but not least.web2py hasn't an API to create indexes on the db, 
 but indexes on a db are a powerful/somewhat required thing to do/think 
 about when designing large applications. If you put an index in the table 
 column you're requesting that distinct, the db scans only the index and not 
 the million rows table

 On Thursday, November 1, 2012 8:18:50 PM UTC+1, Lamps902 wrote:

 Regarding the first point, the concern is not that the selector (as 
 defined in the DB model) is instantiated with a huge variety of fields. If 
 I'm not mistaken, if the distinct keyword in the select() function is 
 left out, the program literally goes through every entry in the DB that 
 matches the search criteria. I suspect that it does the same thing when 
 distinct is used, and adds the additional step of filtering them down to 
 the unique entries. I'm guessing this process may be quite resource 
 intensive for a large DB. If there were a way to get the list of possible 
 selector options straight from the model definition, that would seem to be 
 much more efficient way of doing it (with the minor downside that there may 
 not yet be any DB entries that match a given selector option), but I 
 haven't found a way to do this.

 I guess I may need to start a new thread for the second point - might 
 bring up some good tips on how to customize the grid. Thanks for the 
 suggestion about the widget; I'll check it out. And thanks again for all 
 the help - saved a tremendous amount of time on this task, and I'm sure 
 others will find it useful as well!

 -Lamps


 On Thursday, November 1, 2012 12:44:26 PM UTC-4, Jim S wrote:

 Lamps

 Wish I could be more help with your questions.  Here is my take.

 1.  If you are thinking about having a large list, I would try to avoid 
 that.  Maybe your DISTINCT keyword will keep the list small.  My thoughts 
 are that a long list (25 entries or more) is not very user friendly and if 
 I had that situation, I'd just use the search box and filter on the fields 
 base on the text entered.

 2.  I don't see how you'd be able to do this very easily.  Can probably 
 be done, but you'd have to get into /gluon/sqlhtml.py and make some changes 
 there to implement.

 3.  I think you could probably do this.  If it were me doing it I'd look 
 into the suggest_widget plugin available from 
 http://dev.s-cubism.com/plugin_suggest_widget.

 Best of luck!  Sorry I couldn't be more helpful.

 -Jim

 On Thu, Nov 1, 2012 at 11:35 AM, Lamps902 dhea...@gmail.com wrote:

 I've followed Jim's model in creating my search filter, and it appears 
 to be working beautifully! Just have some questions that I would like to 
 ask. First - I slightly modified the selector code so that entries show up 
 as unique, by adding the distinct clause and ordering alphabetically by 
 category, by doing the following:


 category_list = db().select(db.t_files.f_category, distinct=True, 
 orderby=db.t_files.f_category)
 options = [OPTION(category_list[i].f_category, 
   _value=str(category_list[i].f_category)) for i 
 inrange
 (len(category_list))]

 Will this become extremely inefficient and slow, and grind the system 
 to a halt as the database become large?

 The second question concerns an important cosmetic change  - is there a 
 good way to put the filter input fields (no labels) under the column 
 headers/labels in the grid?

 Finally, if you wanted to redesign the filters to update after a 
 certain number of characters have been modified in an input field (i.e. 
 without having to click search), how would you go about doing that?

 Thanks again!

 -Lamps

 On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:

 I'm attaching a quick-n-dirty search

  1   2   >