[web2py] Re: Passing a list as query parameter and storing the retrieved rows in a list

2016-09-27 Thread Meinolf
Thanks Anthony, i understand clearly now, getcourseids was indeed a Rows 
object and it works now with just  this line:
s = db(db.item.id.belongs([c.item_id for c in getcourseids])).select(db.item
.course_title)

Thanks a lot really!

On Wednesday, September 21, 2016 at 8:59:05 PM UTC+2, Anthony wrote:
>
> On Wednesday, September 21, 2016 at 3:30:49 AM UTC-4, Meinolf wrote:
>>
>> OMG, Is this normal?
>> i got chills telling me it had something to do with the *For Loop*, 
>> played around with the LBs and UBs and the following worked:
>>
>>* for i in range(-1, (len(getcourseids)-1)):*
>>
>
> First, if you want the subscripts of a list, just do range(len(thelist)). 
> Do not subtract 1 from the length of the list -- range already handles that 
> for you (it returns integers that are strictly less than the second 
> argument). Also, no need to start with 0, as that is the default. And don't 
> start with -1 -- when used as a subscript, that will simply retrieve the 
> *last* item in the list, not the first. Also, in Python 2, use xrange() 
> in for loops, which is more memory efficient (in Python 3, range has been 
> replaced by xrange).
>  
>
>>* c = db.item.id ==getcourseids[i].item_id*
>> *s.append(db(c).select(db.item.course_title)[i])*
>>
>
> Here it is not clear why you are subscripting the result of the select 
> with [i]. Presumably each query returns a single matching row, which means 
> you want the subscript to always be [0] -- otherwise, you will get a list 
> index out of range error.
>
> Actually, given that you don't really need the index of each element in 
> the list, you can instead just iterate over the list itself:
>
> for item in getcourseids:
>
> And if you did need the index values in addition to the elements, the more 
> typical approach in Python would be:
>
> for i, item in enumerate(getcourseids):
>
> Anyway, in this case you should not be using the above method at all, as 
> it is very inefficient (you are doing a separate database query for every 
> single item in getcourseids, when you could instead use a single query). 
> Villas has the right idea, but getcourseids.values() assumes getcourseids 
> is a dictionary -- presumably it is actually a Rows object. So, you can do:
>
> s = db(db.item.id.belongs([c.item_id for c in 
> getcourseids])).select(db.item.course_title)
>
> Note, the above is a Rows object. You can convert it to a list if you 
> really need a list, but most likely you can work with the Rows object (it 
> can be iterated and indexed just like a list).
>
> Assuming getcourseids is a Rows object and the only reason it was created 
> was to get the item_id values to be used in this subsequent query, you can 
> instead skip the creation of getcourseids and just use a nested select 
> 
> :
>
> id_query = db([your query to retrieve course 
> ids])._select(db.your_course_table.item_id)
> s = db(db.item.id.belongs(id_query)).select(db.item.course_title)
>
>
> Anthony
>

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


[web2py] Re: How to change another user's session vars?

2016-09-27 Thread Alex Glaros
thanks Dave, I think somthing like that is the best way.

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


[web2py] Re: How to change another user's session vars?

2016-09-27 Thread Dave S


On Tuesday, September 27, 2016 at 2:24:46 PM UTC-7, Alex Glaros wrote:
>
> In a social network, I keep who_has_blocked_me in session vars so that 
> their people searches don't display people that have blocked me.
>
> However if the blocked person is logged on at same time that blocker 
> person blocks them, the blocked person's session vars will not be current.
>
> Is there a way to detect if someone else besides current user is logged on 
> and change their session vars in this type of situation?  Or do I have to 
> wait until they log on again to re-populate with updated session vars?
>
> Otherwise, I have to check the blocked_people table every time there's a 
> people search.
>

How about in the people table, you add a field for "blockingHasChanged".  
If that is true, the people search routine goes to check the blocked_people 
table and discards the row if that entry shows the searcher is blocked, 
otherwise the row is kept.

  if row.blockingHasChanged:
if (check_blocked_people == ME):
  rows.delete(row)
  display_people(row)


 

>
> thanks
>
> Alex Glaros
>


/dps

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


[web2py] Re: How to change another user's session vars?

2016-09-27 Thread Alex Glaros
it would be acceptable to force logout blocked user so they have to login 
again.  

I guess would have to make an exception for my session ;-)

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


[web2py] How to change another user's session vars?

2016-09-27 Thread Alex Glaros
In a social network, I keep who_has_blocked_me in session vars so that 
their people searches don't display people that have blocked me.

However if the blocked person is logged on at same time that blocker person 
blocks them, the blocked person's session vars will not be current.

Is there a way to deted if someone else besides current user is logged on 
and change their session vars in this type of situation?  Or do I have to 
wait until they log on again to re-populate with updated session vars?

Otherwise, I have to check the blocked_people table every time there's a 
people search.

thanks

Alex Glaros

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


Re: [web2py] Re: i wont to add a lambda link to inactivate the row (is_active=False)

2016-09-27 Thread Yoel Baez
I want to add a button on a SQLFORM.grid to inactivate the row

2016-09-27 17:07 GMT-04:00 Dave S :

>
>
> On Tuesday, September 27, 2016 at 1:12:48 PM UTC-7, Yoel Baez wrote:
>>
>> i wont to add a lambda link to inactivate the row (is_active=False)
>>
>> Can someone help me please?
>>
>
> What are you trying to do?  Is this link to appear in a form (like an edit
> link in SQLFORM)?  Is it to be a standalone link, perhaps in the the
> navigation bar?  Is the inactivate event supposed to happen automatically
> when something else happens?
>
> /dps
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/PUS6txn1y7o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Saludos,
YB

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


[web2py] Re: i wont to add a lambda link to inactivate the row (is_active=False)

2016-09-27 Thread Dave S


On Tuesday, September 27, 2016 at 1:12:48 PM UTC-7, Yoel Baez wrote:
>
> i wont to add a lambda link to inactivate the row (is_active=False)
>
> Can someone help me please?
>

What are you trying to do?  Is this link to appear in a form (like an edit 
link in SQLFORM)?  Is it to be a standalone link, perhaps in the the 
navigation bar?  Is the inactivate event supposed to happen automatically 
when something else happens?

/dps
 

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


[web2py] i wont to add a lambda link to inactivate the row (is_active=False)

2016-09-27 Thread Yoel Baez
i wont to add a lambda link to inactivate the row (is_active=False)

Can someone help me please?

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


[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Niphlod
yep, ATM I'd go for rawconfigparser but someone asked for interpolation 
 so we have two distinct "paths" . Just need to rule out one ^_^

On Tuesday, September 27, 2016 at 6:56:10 PM UTC+2, Ivan wrote:
>
> escaping % with % solves the problem
> however I think it would be better to not force the user to escape each % 
> in a .ini file
>
> the exception comes from the ConfigParser python module (more 
> precisely SafeConfigParser) used in AppConfig
> maybe a better solution is to use RawConfigParser that doesn't interpolate 
> at all
>
>
> Il giorno martedì 27 settembre 2016 17:30:21 UTC+2, Niphlod ha scritto:
>>
>> hum. did you try excaping the % with % , which means basically having %% 
>> instead of % ?
>>
>> On Tuesday, September 27, 2016 at 4:15:45 PM UTC+2, Ivan wrote:
>>>
>>> I don't want to interpolate.
>>> I have an option with a % inside and the AppConfig raises an exception.
>>>
>>

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


[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Ivan
escaping % with % solves the problem
however I think it would be better to not force the user to escape each % 
in a .ini file

the exception comes from the ConfigParser python module (more 
precisely SafeConfigParser) used in AppConfig
maybe a better solution is to use RawConfigParser that doesn't interpolate 
at all


Il giorno martedì 27 settembre 2016 17:30:21 UTC+2, Niphlod ha scritto:
>
> hum. did you try excaping the % with % , which means basically having %% 
> instead of % ?
>
> On Tuesday, September 27, 2016 at 4:15:45 PM UTC+2, Ivan wrote:
>>
>> I don't want to interpolate.
>> I have an option with a % inside and the AppConfig raises an exception.
>>
>

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


[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Niphlod
hum. did you try excaping the % with % , which means basically having %% 
instead of % ?

On Tuesday, September 27, 2016 at 4:15:45 PM UTC+2, Ivan wrote:
>
> I don't want to interpolate.
> I have an option with a % inside and the AppConfig raises an exception.
>

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


[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Ivan
I don't want to interpolate.
I have an option with a % inside and the AppConfig raises an exception.

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


[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Niphlod
and it's correct that it does, as it can work with json with doesn't have 
any interpolation facilities. if you want to interpolate, for the moment, 
use your app's code.

On Tuesday, September 27, 2016 at 3:43:24 PM UTC+2, Ivan wrote:
>
> If the .ini file contains an option with a % (eg a password), the 
> AppConfig class raise an InterpolationSyntaxError exception.
>
>

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


[web2py] Re: Search on list:reference tables with SQLFORM.Grid

2016-09-27 Thread Anthony
Are you talking about searching a list:reference field? If so, that 
wouldn't be very useful, as the end user would have to know the record IDs 
of the desired records. Instead, presumably you would want the ability to 
search based on the record representation of each reference (or some other 
fields within the referenced table). That certainly adds complexity and is 
beyond the scope of the built-in search mechanism. However, you can 
customize the search functionality. The "searchable" argument can be a 
callable that takes a list of DAL fields and the keywords submitted by the 
user and returns a DAL Query object. The "search_widget" argument can be 
used to customize the search UI on the page -- it takes a list of fields 
and a URL (where the search query should be sent) and should return a 
web2py HTML helper object (that presumably contains a form). For further 
details, see the source code of SQLFORM.grid in gluon.sqlhtml.

Anthony

On Tuesday, September 27, 2016 at 5:26:56 AM UTC-4, St. Pirsch wrote:
>
> I am coming back to this topic for a second time since I couldn’t get an 
> answer last time and it would facilitate things a lot for me:
>
>
> The SQLFORM.Grid has a very sophisticated filter system to make queries 
> over selected tables easy.
>
> It seems, however, that it  is actually not possible to query over columns 
> of referenced table lists. 
>
> Is it possible - for instance - to expand the existing functionality,has 
> anyone already worked on this and can give a hint?
>

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


[web2py] AppConfig and % interpolation

2016-09-27 Thread Ivan
If the .ini file contains an option with a % (eg a password), the AppConfig 
class raise an InterpolationSyntaxError exception.

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


Re: [web2py] Re: flot charts are not getting displayed

2016-09-27 Thread brooks lee
Got it! Had to update the jquery version.It's working now.Thanks Anthony.

On Mon, Sep 26, 2016 at 4:43 PM, Anthony  wrote:

> On Monday, September 26, 2016 at 1:53:38 AM UTC-4, @brooks wrote:
>>
>> Thanks Anthony.I corrected the two things you pointed out and then
>> checked for the errors in the console.It shows error 304(file not modified)
>> and I am not able to rectify that! :(
>>
>
> Sounds like you're looking in the network tab at the HTTP requests.
> Instead, check the Javascript console to see if any Javascript errors are
> reported.
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/YA-o1OUS_0w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Search on list:reference tables with SQLFORM.Grid

2016-09-27 Thread St. Pirsch
 

I am coming back to this topic for a second time since I couldn’t get an 
answer last time and it would facilitate things a lot for me:


The SQLFORM.Grid has a very sophisticated filter system to make queries 
over selected tables easy.

It seems, however, that it  is actually not possible to query over columns 
of referenced table lists. 

Is it possible - for instance - to expand the existing functionality,has 
anyone already worked on this and can give a hint?

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