Re: [web2py] Re: smartgrid orderby descending

2014-03-10 Thread Jake Lowen
Hi Dan.  Sorry, but I can't remember if I ever got that problem solved.  I
did have this response to the question "I believe the keys of the orderby
dict should be the actual table names, not the literal keys "parent" and
"child"."

I've not actually touched web2py in a while since I moved on to flask.
Sorry I'm not more help.

J


On Fri, Mar 7, 2014 at 6:41 PM, Dan Kozlowski  wrote:

> Jake,
>
> Did you ever get this to work ? Reason being I think I have the same
> problem.
>
>
> On Sunday, April 21, 2013 9:47:59 AM UTC-5, Jake Lowen wrote:
>>
>> In a normal grid the orderby descending works just fine:
>>
>> grid = SQLFORM.grid(db.meetings,
>> orderby=~db.meetings.meeting_date,
>> )
>>
>> But I can't get the parent table of a smart group to sort the same way:
>>
>> grid = SQLFORM.smartgrid(db.meetings,
>> linked_tables=['meeting_docs'],
>> orderby=dict(parent=~db.meetings.meeting_date, child=None),
>> )
>>
>> What is the correct syntax to descent sort the parent table in a
>> smartgrid?
>>
>  --
> 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/0XlEIXuCaG8/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] smartgrid orderby descending

2013-04-21 Thread Jake Lowen
In a normal grid the orderby descending works just fine:

grid = SQLFORM.grid(db.meetings,
orderby=~db.meetings.meeting_date,
)

But I can't get the parent table of a smart group to sort the same way:

grid = SQLFORM.smartgrid(db.meetings,
linked_tables=['meeting_docs'],
orderby=dict(parent=~db.meetings.meeting_date, child=None),
)

What is the correct syntax to descent sort the parent table in a smartgrid?

-- 

--- 
You received this message because you are 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: scheduler on webfaction

2013-04-11 Thread Jake Lowen
Simultaneously with Niphlod's reply also came this from webfaction customer 
support:

You can use the nohup command at the start of this command to make it 
immunte to hangups, like when you are exiting your ssh session. 
http://linux.die.net/man/1/nohup


Or you can use disown to disassociate the process with the current shell. 
http://www2.research.att.com/~gsf/man/man1/disown.html


Another, more powerful tool would be to start the process within a screen 
session. http://linux.die.net/man/1/screen and 
http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/

-- 

--- 
You received this message because you are 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] scheduler on webfaction

2013-04-09 Thread Jake Lowen
Hi.  I have web2py installed on webfaction as my production server.
I followed the web2py documentation on it's scheduler function and built an 
app where everything works as anticipated. (very cool!)

In order to run the scheduler though I need to SSH into the server and run 
this command:
"python ~/webapps/web2py/web2py/web2py.py -K statecouncil"

All is well as long as I maintain my SSH session, but (obviously) when I 
close that session, the above command no longer runs anymore. How can I 
keep that command running at all times?  Is there a tutorial for installing 
the scheduler as a service on webfaction that is not depended on my 
personal computer being connected for it to run?

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: Is it possible to use grid style search to filter records before handing off to another function?

2013-03-31 Thread Jake Lowen
Thanks Anthony for your excellent advice. I've decided to use a standard 
grid for the search and display but to use your suggested combo of 
request.vars.keywords + SQLFORM.build_query() to get at the selected 
records.

I appreciate the help!

Jake

On Sunday, March 31, 2013 11:22:10 AM UTC-5, Anthony wrote:
>
> Actually, this is a better way to generate the complete search form (you 
> may need to fiddle with the CSS):
>
> search_form = SQLFORM.grid(db.members, searchable=True).element(
> '.web2py_console')[1]
>
> That extracts just the search form from within the .web2py_console part of 
> the grid DOM. When you submit the form, the query will be available in 
> request.var.keywords, which you can then pass to the SQLFORM.build_query() 
> method to generate the DAL Query.
>
> Anthony
>
> On Sunday, March 31, 2013 11:52:56 AM UTC-4, Jake Lowen wrote:
>>
>> I appreciate the answer, but I can't figure out the syntax and can't find 
>> documentation.
>>
>> For example, I can't generate the search_menu via:
>>
>> db.define_table('members',
>> Field('first_name','string'),
>> Field('last_name','string'),
>> Field('address_street_1','string', label="Address 1"),
>> Field('address_street_2','string', label="Address 2"),
>> Field('address_city','string', label="City"),
>> Field('address_state','string', label="State", 
>> requires=IS_IN_SET(states)),
>> Field('address_zip','string', label="Zip"),
>> Field('address_zip4','string', label="+4"),
>> Field('phone_home','string'),
>> Field('phone_mobile','string'),
>> Field('phone_work','string'),
>> Field('email','string'),
>> Field('union_international','string', 
>> label="Int'l",requires=IS_IN_SET(internationals)),
>> Field('union_local','string',label="local"),
>> Field('district_ks_house','string',writable=False),
>> Field('district_ks_senate','string',writable=False),
>> )
>>
>> def search_test():
>>search = SQLFORM.search_ment([db.members.district_ks_house, 
>> db.members.district_ks_senate])
>>return locals()
>>
>>
>> On Sunday, March 31, 2013 10:26:11 AM UTC-5, Anthony wrote:
>>>
>>> You can use SQLFORM.search_menu([list of fields]) to build the search 
>>> menu, and once the search is submitted, you can use SQLFORM.build_set([list 
>>> of fields], keywords=request.vars.keywords) to get the DAL Set object 
>>> associated with the search.
>>>
>>> Anthony
>>>
>>> On Saturday, March 30, 2013 7:05:17 PM UTC-4, Jake Lowen wrote:
>>>>
>>>> I like the way that SQLFORM.grid search works. Once I've searched for 
>>>> records and come up with the set I want, How can I pass that set off to 
>>>> another function to do work just on those filtered records?   Or in other 
>>>> words.. if I have 100 records, and I use the grid search to narrow it down 
>>>> to 15... how can I pass just those 15 records to another controller 
>>>> function?
>>>>
>>>> Is it possible to get at the matching records in the grid as is or do I 
>>>> need to build another search tool?
>>>>
>>>> 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: Is it possible to use grid style search to filter records before handing off to another function?

2013-03-31 Thread Jake Lowen
I appreciate the answer, but I can't figure out the syntax and can't find 
documentation.

For example, I can't generate the search_menu via:

db.define_table('members',
Field('first_name','string'),
Field('last_name','string'),
Field('address_street_1','string', label="Address 1"),
Field('address_street_2','string', label="Address 2"),
Field('address_city','string', label="City"),
Field('address_state','string', label="State", requires=IS_IN_SET(states)),
Field('address_zip','string', label="Zip"),
Field('address_zip4','string', label="+4"),
Field('phone_home','string'),
Field('phone_mobile','string'),
Field('phone_work','string'),
Field('email','string'),
Field('union_international','string', 
label="Int'l",requires=IS_IN_SET(internationals)),
Field('union_local','string',label="local"),
Field('district_ks_house','string',writable=False),
Field('district_ks_senate','string',writable=False),
)

def search_test():
   search = SQLFORM.search_ment([db.members.district_ks_house, 
db.members.district_ks_senate])
   return locals()


On Sunday, March 31, 2013 10:26:11 AM UTC-5, Anthony wrote:
>
> You can use SQLFORM.search_menu([list of fields]) to build the search 
> menu, and once the search is submitted, you can use SQLFORM.build_set([list 
> of fields], keywords=request.vars.keywords) to get the DAL Set object 
> associated with the search.
>
> Anthony
>
> On Saturday, March 30, 2013 7:05:17 PM UTC-4, Jake Lowen wrote:
>>
>> I like the way that SQLFORM.grid search works. Once I've searched for 
>> records and come up with the set I want, How can I pass that set off to 
>> another function to do work just on those filtered records?   Or in other 
>> words.. if I have 100 records, and I use the grid search to narrow it down 
>> to 15... how can I pass just those 15 records to another controller 
>> function?
>>
>> Is it possible to get at the matching records in the grid as is or do I 
>> need to build another search tool?
>>
>> 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] Is it possible to use grid style search to filter records before handing off to another function?

2013-03-30 Thread Jake Lowen
I like the way that SQLFORM.grid search works. Once I've searched for 
records and come up with the set I want, How can I pass that set off to 
another function to do work just on those filtered records?   Or in other 
words.. if I have 100 records, and I use the grid search to narrow it down 
to 15... how can I pass just those 15 records to another controller 
function?

Is it possible to get at the matching records in the grid as is or do I 
need to build another search tool?

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: Problem with difficult query

2013-02-07 Thread Jake Lowen
Solved:  It was a dumb mistake.. I was trying to group by a field in the 
left join table.. so of course it was eliminating all records not found in 
the second table.  I switched the group by to a first table field and all 
is well.

Final working query was:

foo = db(db.benchmark_targets.benchmark == 
for_benchmark.id).select(db.benchmark_targets.ALL, db.lobby_report.ALL, 
left=db.lobby_report.on(db.lobby_report.KPID == db.benchmark_targets.KPID), 
orderby=~db.lobby_report.datetime, groupby=db.benchmark_targets.KPID)

Hours in front of a screen stumped me, but I go for a drive and the 
solution occurs to me instantly.

-- 

--- 
You received this message because you are 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: Problem with difficult query

2013-02-07 Thread Jake Lowen
I'm only talking to myself here, but the notes are helpful...

This is how I get the desired result in web2py using the executesql command:

foo = db.executesql('SELECT * FROM benchmark_targets AS t2 LEFT JOIN 
(SELECT * from lobby_report GROUP BY KPID ORDER BY datetime DESC) AS t1 ON 
t2.KPID = t1.KPID WHERE t2.benchmark = ' + str(request.args(1)))

Now if only someone could guide me to doing it the web2py way!

-- 

--- 
You received this message because you are 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: Problem with difficult query

2013-02-07 Thread Jake Lowen
Forgot the WHERE in my SQL statement. Should be: 

SELECT * FROM benchmark_targets t2 
LEFT JOIN (SELECT * from lobby_report GROUP BY KPID ORDER BY datetime 
DESC)t1 ON t2.KPID = t1.KPID 
WHERE t2.benchmark = 10;

-- 

--- 
You received this message because you are 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: Problem with difficult query

2013-02-07 Thread Jake Lowen
If it helps, here is how I can get the desired result in raw SQL:

SELECT * FROM benchmark_targets t2 LEFT JOIN (SELECT * from lobby_report 
GROUP BY KPID ORDER BY datetime DESC)t1 ON t2.KPID = t1.KPID;

Now how to do it in DAL?


-- 

--- 
You received this message because you are 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] Problem with difficult query

2013-02-07 Thread Jake Lowen

Thanks for a great framework. I'm loving web2py, but I just encountered a 
difficult query

One query generates a list of people.
Each of those persons has 0 to many reports filed about them.
I wanted to see only the newest report on each person AND I want to see 
Null or None if no reports have been filed.

This query almost works:

foo = db(db.benchmark_targets.benchmark == 
for_benchmark.id).select(left=db.lobby_report.on(db.lobby_report.KPID == 
db.benchmark_targets.KPID), orderby=~db.lobby_report.datetime)

but a person is listed twice if they have multiple reports filed about 
them.  If I add a groupby to the query it shows the right report but only 
people with reports filed (does not show people with 0 matching reports).

How do I see only the newest report Left outer joined to a group of people?

Thanks in advance 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.