Re: [web2py] no json - cont.

2011-03-01 Thread Lorin Rivers
On Mar 1, 2011, at 5:18 AM, darkblue_b wrote:
 as per the very simple instructions, I wrote a controller function to
 return a few items..
 generic.html and generic.xml work, but generic.json and generic.rss
 fail
 
  just learning still, I searched the newsgroup and found
 
 Lorin Rivers Jan 13, 2:26 pm
 OK, if I specify which columns get returned in my rows, generic.json returns 
 no json.
 If my function returns rows.as_list(), generic.json works, but my 
 generic.csv breaks.
 I figured out this, though, which seems to work, but I don't know if it's 
 wise. Also, it doesn't seem like it should be necessary.
 def function():
 dbset = db()
 records = dbset.select(db.table.field1, db.table.field2, 
 orderby=db.table.field1)
 otherrecords = records.as_list()
 Then in my generic.csv, I use records and in generic.json I use otherrecords.
 --
 
 does this apply ? is this a FAQ?
 I would like to get to authenticated JSON next
 thanks  -Brian
 


@jonathan: Yes, a more detailed error messages than no json would be awesome.

@brian: if the other generics work, then it's probably a non-serializable 
value. In my case, it was a date object. Once I realized that, I converted the 
date to a string and it then worked peachily.


-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Using multiprocessing in web2py

2011-03-01 Thread Lorin Rivers
David,

If you can do any of the analysis ahead of time and store that, it might help. 
That's what I had to do.

In my case, I also discovered that the database I was using wanted more RAM 
than I could give it at the time and had to do my real-time analysis in smaller 
chunks.


-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Setting the title tag

2011-02-09 Thread Lorin Rivers
One of the mental challenges I have with mvc/layout approach is how to assign 
values from the inside-out. Almost all the work I have done so far is in the 
views.

I'd like to dynamically change the title tag (e.g., title in the head 
element).

How does that work?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




smime.p7s
Description: S/MIME cryptographic signature


Re: [web2py] Re: Setting the title tag

2011-02-09 Thread Lorin Rivers
OK, I'm getting there.

How do I specify response.title in my view?

On Feb 9, 2011, at 12:55 PM, DenesL wrote:

 If you are using the default layout.html file then just set
 response.title to whatever title you want.
 
 
 On Feb 9, 1:50 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 One of the mental challenges I have with mvc/layout approach is how to 
 assign values from the inside-out. Almost all the work I have done so far 
 is in the views.
 
 I'd like to dynamically change the title tag (e.g., title in the head 
 element).
 
 How does that work?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
  smime.p7s
 6KViewDownload

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




smime.p7s
Description: S/MIME cryptographic signature


Re: [web2py] Re: Setting the title tag

2011-02-09 Thread Lorin Rivers
Denes,

I'm a little dense. You sent me down the right path and I just had to struggle 
with it a little.

I didn't realize you could simply build response.title in in the controller and 
it just works.

Then I had to unroll the tuple I built.

It's all good now, though! Thanks!

In case someone stumbles upon this thread, here's what I did:

controller:
theTitle = ctab.title, str(timestart), to, str(timeend)
response.title =  .join(theTitle)

layout.html:
title{{=response.title or URL()}}/title

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] rows.find doesn't find anything

2011-01-18 Thread Lorin Rivers
semaphore_query = db4.rollup_semaphore.id  0
semaphore_set = db4(semaphore_query)
semaphore_rows = semaphore_set.select()
for row in semaphore_rows.find(lambda row: row.table_name[0]=='data_table'):
print row


returns nothing. While:
print db4(db4.rollup_semaphore.table_name=='data_table').select()

Returns:
rollup_semaphore.id,rollup_semaphore.table_name,rollup_semaphore.rollup_status
1,data_table,False

Which is what I expect the first to return.

What am I doing wrong?


-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: rows.find doesn't find anything

2011-01-18 Thread Lorin Rivers
Right!

Hey, it might be good to have an example in The Book that uses a different 
construction than the one I mistakenly tried to use.


On Jan 18, 2011, at 15:30 , Massimo Di Pierro wrote:

 
for row in semaphore_rows.find(lambda row:
 row.table_name[0]=='data_table'):
print row
 
 should be
 
for row in semaphore_rows.find(lambda row:
 row.table_name=='data_table'):
print row
 
 else you compare only the first char with 'date_table'
 
 On Jan 18, 1:05 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 semaphore_query = db4.rollup_semaphore.id  0
 semaphore_set = db4(semaphore_query)
 semaphore_rows = semaphore_set.select()
 for row in semaphore_rows.find(lambda row: 
 row.table_name[0]=='data_table'):
 print row
 
 returns nothing. While:
 print db4(db4.rollup_semaphore.table_name=='data_table').select()
 
 Returns:
 rollup_semaphore.id,rollup_semaphore.table_name,rollup_semaphore.rollup_sta 
 tus
 1,data_table,False
 
 Which is what I expect the first to return.
 
 What am I doing wrong?
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Basic Python ignorance? simplejson throwing TypeError(key + repr(key) + is not a string)

2011-01-17 Thread Lorin Rivers
No doubt this is my base Python ignorance being the problem.

I've made some progress on my pivot problem, using this recipe 
http://code.activestate.com/recipes/334695-pivotcrosstabdenormalization-of-a-normalized-list/
 (actually, the improved one from the comments).

I'm getting what I want now (or close to it):
[   {   'FreezeTime': datetime.datetime(2010, 12, 12, 21, 0),
('S',): 643.882600715039,
('S0001',): '',
('S0002',): 621.511925599709},
{   'FreezeTime': datetime.datetime(2010, 12, 12, 22, 0),
('S',): 159.230736027886,
('S0001',): '',
('S0002',): 166.628191452988}, ...
]

But when I try to convert it to json using this in my view:
 var optimizerdata = {{response.write(json(optimizers), escape=False)}};

Where optimizers is a list that looks like this:

It throws the error, saying this:
  TypeError: key ('S0001',) is not a string
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] social network idea

2011-01-17 Thread Lorin Rivers
Actually, Facebook also uses social graphs to identify people you may know.

This part of it is a pretty tough problem, but there are some pretty sharp 
people on this list…
On Jan 17, 2011, at 13:43 , Massimo Di Pierro wrote:

 Most social network assue you know who your friends are and allow you
 to share info with your friends. How about the opposite? Something
 like a bookmarking app that tells me who my friends should be based on
 physical distance and recent common bookmarks?
 
 It seems to me the main problem to me is that a lot of people are
 alone they because do not necessarily share interests with their
 colleagues and family members. Facebook is popular because it allows
 people to connect with people that they knew and therefore assume had
 something in common. Until people find out time has passed by and
 there is not really much to talk about. You can be a scientist and
 soon find your page polluted with somebody's horoscope.
 
 - a bookmarking system like http://radbox.me/
 - when you bookmark something you tag with fixed categories
 - a way to sort/organize and rate own bookmarks using mouse drag and
 drop.
 - you have a profile and public pages showing your bookmarks only (can
 be used by a prof to share links with students for example)
 - Once logged in you can see other users nearby that bookmarked -
 independently - the same links, and filter then by location, gender,
 age, bookmark category (could compete with match.com too)
 - You can then choose to be notified when a given person bookmarks
 something new (like twitter)
 - You can check who is following your bookmarks.
 
 Massimo

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Trying to pivot some date, need to add nulls for missing rows

2011-01-16 Thread Lorin Rivers
I have a list of distinct values for a column StringID: 'S', 
'S0001', S0002'.

A FreezeTime value can have 1 to 3 rows (one row for each StringID) like this:
FreezeTime, StringID, Po_avg_sum
12/13/2010 22:00:00, S, 76
12/13/2010 22:00:00, S0001, 265
12/13/2010 22:00:00, S0002, 195

or it could have just one or two of the StringIDs for a particular FreezeTime.

What I want to get is this:
FreezeTime, po_S, po_S0001, po_S0002
12/13/2010 22:00:00, 76, 265, 195

The library I found that will do the pivot I need works fine if all three 
StringIDs are present, but if any are missing, it breaks. So what I need to do 
is insert into my list null values for Po_avg_sum for that StringID and 
FreezeTime so that my FreezeTime row would look like this:
12/13/2010 22:00:00,76,,195

If the 'S0001' data was missing for that time.

It's probably really easy, but I'm struggling.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Output of sum(), simplifying the JSON

2011-01-14 Thread Lorin Rivers
Controller:
export_optimizer_records = 
dbset(db.table.FreezeTime,db.table.StringID,db.table.Po_avg.sum(),groupby=..FreezeTime|..StringID).as_list()

View:
var optimizerdata = {{response.write(json(export_optimizer_records), 
escape=False)}};


The JSON looks like this:

[{
panel_1hrs: {
FreezeTime: 2010-12-12 19:00:00,
StringID: S0001
},
_extra: {
sum(panel_1hrs.Po_avg): 519.912549612443
}
},
{
panel_1hrs: {
FreezeTime: 2010-12-12 19:00:00,
StringID: S0002
},
_extra: {
sum(panel_1hrs.Po_avg): 532.390706326218
}
}]

What I want is this:

[{
FreezeTime: 2010-12-12 19:00:00,
StringID: S0001,
Po_avg_sum: 519.912549612443
},
{
FreezeTime: 2010-12-12 19:00:00,
StringID: S0002,
Po_avg_sum: 532.390706326218
}]

What's the easiest way to get that?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] generic.csv works perfectly, generic.json reports no json?

2011-01-13 Thread Lorin Rivers
In my app, I can build somewhat complex urls (ex: 
/Debug/reports/exportRecords.csv/strings/60?att=FreezeTimeatt=StringIDatt=Vi_avgatt=Vo_avgatt=Ii_avgatt=Io_avgatt=Pi_avgatt=Po_avgorderby=FreezeTimeorderby=StringID
 that give me precisely the csv output I require. The function exportRecords 
returns a dict (records=records) and records is a rows object.

If I change the url from using exportRecords.csv to using exportRecords.json it 
reports no json. What gives? How can I make this more generic?

I'd like to be able to use the same url conventions to return json for use in 
charts.

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Best practice for including python libraries with my app

2011-01-13 Thread Lorin Rivers
I am using tabular http://www.parsemydata.com/tabular (which requires numpy), 
as well as psycopg2 and a number of other libraries.

The default location for such things is one of the local site-packages 
directories, which of course, doesn't migrate to another machine automagically.

What's the best practice for this sort of thing?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Best practice for including python libraries with my app

2011-01-13 Thread Lorin Rivers
That's exactly the kind of user experience I want to avoid.


On Jan 13, 2011, at 13:34 , Alexandre Andrade wrote:

 try to import, and if fails, generate message to user to install it on the
 system
 
 
 Alexandre Andrade
 Hipercenter.com Classificados Gratuitos e Inteligentes
 
 
 
 2011/1/13 Lorin Rivers lriv...@mosasaur.com
 
 I am using tabular http://www.parsemydata.com/tabular (which requires
 numpy), as well as psycopg2 and a number of other libraries.
 
 The default location for such things is one of the local site-packages
 directories, which of course, doesn't migrate to another machine
 automagically.
 
 What's the best practice for this sort of thing?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 -- 
 Atenciosamente

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: generic.csv works perfectly, generic.json reports no json?

2011-01-13 Thread Lorin Rivers
What do I put in generic.json to expose the details of the exception?

On Jan 13, 2011, at 13:46 , Wikus van de Merwe wrote:

 Do you have the generic.json view? Change it to print out the details of 
 the exception thrown there. My guess is that you need escaping=True.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] JSON questions and a workaround

2011-01-13 Thread Lorin Rivers
OK, if I specify which columns get returned in my rows, generic.json returns 
no json.

If my function returns rows.as_list(), generic.json works, but my generic.csv 
breaks.

I figured out this, though, which seems to work, but I don't know if it's wise. 
Also, it doesn't seem like it should be necessary.

def function():
  dbset = db()
  records = dbset.select(db.table.field1, db.table.field2, 
orderby=db.table.field1)
  otherrecords = records.as_list()

Then in my generic.csv, I use records and in generic.json I use otherrecords.



-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Not open source yet... but

2011-01-06 Thread Lorin Rivers
Thanks, Massimo!

Looking forward to checking out the processing stuff!

On Dec 30, 2010, at 18:32 , mdipierro wrote:

 Source: http://code.google.com/p/emte-trading/
 
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Cron: what happens if a process isn't finished and the next time to start it comes again?

2010-12-28 Thread Lorin Rivers
I am working on moving some of the computation-intensive processes to a
cron-launched scheme. I have some that run every minute, every 2 minutes,
every 5 minutes and every 15 minutes.

In production, it's possible that the volume of incoming data would result
in the task not finishing before its next cron slot fires again. In
development , however, I can flood the system quite easily by importing data
in larger chunks.

At the moment, my laptop (fairly decent machine) is essentially unusable
because there are so many python processes consuming RAM.

Here's a slightly cleaned-up sample of ps:

 6716 ttys0000:01.70 ../Python web2py.py -a 1234 -i 127.0.0.1 -p 8000
 6722 ttys0000:36.46 ../Python ../web2py.py -J -M -S Debug/DAQ/setup_DAQ
-a recycle
 6724 ttys0000:00.00 (Python)
 7239 ttys0000:00.00 (Python)
 7543 ttys0000:00.00 (Python)
 7641 ttys0000:00.00 (Python)
 7720 ttys0000:00.00 (Python)
 7819 ttys0000:00.00 (Python)
 8781 ttys0000:00.00 (Python)
 8783 ttys0000:00.00 (Python)
 8784 ttys0000:00.00 (Python)
 8787 ttys0000:00.00 (Python)
 8789 ttys0000:00.00 (Python)
 8790 ttys0000:00.00 (Python)
 8791 ttys0000:00.00 (Python)
 8792 ttys0000:00.00 (Python)
 8867 ttys0000:00.00 (Python)
 8868 ttys0000:00.00 (Python)
 8872 ttys0000:00.00 (Python)
 8946 ttys0000:00.00 (Python)
 8947 ttys0000:00.00 (Python)
 8949 ttys0000:00.00 (Python)
 8950 ttys0000:00.00 (Python)
 8951 ttys0000:00.00 (Python)
 8948 ttys0000:00.46 ../Python ../web2py.py -J -M -S
Debug/rounding/array_1minsRollup -a recycle
 7320 ttys0001:04.75 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7424 ttys0000:56.54 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7544 ttys0000:50.19 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7643 ttys0000:42.32 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7722 ttys0000:36.26 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7820 ttys0000:30.36 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 7899 ttys0000:25.12 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8013 ttys0000:20.99 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8090 ttys0000:17.28 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8189 ttys0000:14.05 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8271 ttys0000:11.55 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8364 ttys0000:07.50 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8455 ttys0000:07.51 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8557 ttys0000:05.08 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8635 ttys0000:00.73 ../Python ../web2py.py -J -M -S
Debug/rounding/data_tableRollup -a recycle
 8458 ttys0000:18.24 ../Python ../web2py.py -J -M -S
Debug/rounding/panel_1minsRollup -a recycle
 8638 ttys0000:16.68 ../Python ../web2py.py -J -M -S
Debug/rounding/panel_1minsRollup -a recycle
 8786 ttys0000:00.57 ../Python ../web2py.py -J -M -S
Debug/rounding/panel_1minsRollup -a recycle
 7061 ttys0000:43.78 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7140 ttys0000:12.82 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7240 ttys0000:12.35 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7319 ttys0000:12.37 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7423 ttys0000:12.20 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7541 ttys0000:12.10 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7640 ttys0000:12.26 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7721 ttys0000:12.31 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7818 ttys0000:12.59 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 7898 ttys0000:12.53 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8012 ttys0000:12.46 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8092 ttys0000:12.46 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8188 ttys0000:12.26 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8270 ttys0000:11.96 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8363 ttys0000:12.05 ../Python ../web2py.py -J -M -S
Debug/rounding/stringdataRollup -a recycle
 8454 ttys0000:12.12 ../Python ../web2py.py -J -M -S

[web2py] List of fields to orderby expression

2010-12-20 Thread Lorin Rivers
How do I turn a list of fields to an orderby expression?

In other words, If I have this: [db.table.field1, db.table.field2]

I want this: db(db.table).select(orderby = db.table.field1 | db.table.field2)

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: List of fields to orderby expression

2010-12-20 Thread Lorin Rivers
Yep, thanks!

On Dec 20, 2010, at 11:28 , mdipierro wrote:

 I think this is what you are asking:
 
 myorderlist = [db.table.field1, db.table.field2]
 orderby = reduce(lambda a,b:a|b, myorderlist)
 rows = db(db.table).select(orderby = orderby)
 
 
 On Dec 20, 11:07 am, Lorin Rivers lriv...@mosasaur.com wrote:
 How do I turn a list of fields to an orderby expression?
 
 In other words, If I have this: [db.table.field1, db.table.field2]
 
 I want this: db(db.table).select(orderby = db.table.field1 | db.table.field2)
 
 Thanks!
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] logging.conf for debugging

2010-12-16 Thread Lorin Rivers
I have logging writing to the console, but not to the log file.

Starting with the example, I changed WARNING to DEBUG (everywhere--as
soon as I get it working, I'll be more selective), I set [keys] to
keys=consoleHandler,rotatingFileHandler.

logs/web2py.log gets created on startup, but never gets any data
written to it, despite the copious log events in the console.

What am I missing?


Re: [web2py] logging.conf for debugging

2010-12-16 Thread Lorin Rivers
[loggers]
keys=root,rocket,markdown,web2py,rewrite,app,welcome,cron

# the default configuration is console-based (stdout) for backward compatibility
#
# note that file-based handlers are thread-safe but not mp-safe;
# for mp-safe logging, configure the appropriate syslog handler

[handlers]
#keys=consoleHandler
keys=consoleHandler,rotatingFileHandler
#keys=osxSysLogHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=INFO
handlers=consoleHandler

[logger_web2py]
level=INFO
handlers=consoleHandler
qualname=web2py
propagate=0

[logger_cron]
level=INFO
handlers=consoleHandler
qualname=web2py.cron
propagate=0

[logger_rewrite]
level=INFO
qualname=web2py.rewrite
handlers=consoleHandler
propagate=0

# generic app handler
[logger_app]
level=INFO
qualname=web2py.app
handlers=consoleHandler
propagate=0

# welcome app handler
[logger_welcome]
level=WARNING
qualname=web2py.app.welcome
handlers=consoleHandler
propagate=0

# loggers for legacy getLogger calls: Rocket and markdown
[logger_rocket]
level=INFO
handlers=consoleHandler
qualname=Rocket
propagate=0

[logger_markdown]
level=WARNING
handlers=consoleHandler
qualname=markdown
propagate=0

[handler_consoleHandler]
class=StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stdout,)

# Rotating file handler
#   mkdir logs in the web2py base directory if not already present
#   args: (filename[, mode[, maxBytes[, backupCount[, encoding[, delay])
#
[handler_rotatingFileHandler]
class=handlers.RotatingFileHandler
level=INFO
formatter=simpleFormatter
args=(logs/web2py.log, a, 100, 5)

[handler_osxSysLogHandler]
class=handlers.SysLogHandler
level=INFO
formatter=simpleFormatter
args=(/var/run/syslog, handlers.SysLogHandler.LOG_DAEMON)

[handler_linuxSysLogHandler]
class=handlers.SysLogHandler
level=INFO
formatter=simpleFormatter
args=(/dev/log, handlers.SysLogHandler.LOG_DAEMON)

[handler_remoteSysLogHandler]
class=handlers.SysLogHandler
level=INFO
formatter=simpleFormatter
args=(('sysloghost.domain.com', handlers.SYSLOG_UDP_PORT), 
handlers.SysLogHandler.LOG_DAEMON)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=

On Dec 16, 2010, at 16:47 , Jonathan Lundell wrote:

 On Dec 16, 2010, at 11:00 AM, Lorin Rivers wrote:
 
 I have logging writing to the console, but not to the log file.
 
 Starting with the example, I changed WARNING to DEBUG (everywhere--as
 soon as I get it working, I'll be more selective), I set [keys] to
 keys=consoleHandler,rotatingFileHandler.
 
 logs/web2py.log gets created on startup, but never gets any data
 written to it, despite the copious log events in the console.
 
 What am I missing?
 
 Please post your logging.conf.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Rounding time

2010-12-16 Thread Lorin Rivers
I have  a function that I use to round time increments. I just realized it 
fails when the time rolls over the 24 hour period.

I also found myself needing to make a second version for rounding to hours. 
Anyone care to take a stab at fixing it to handle the rollover AND hours?

def round_off(mins, secs, to_nearest=1):
div_result, remainder = divmod(mins, to_nearest)

if remainder  7:   
return to_nearest * div_result
elif remainder  7:
return to_nearest * (div_result + 1)
else:#remainder == 7 
if secs  30:
return to_nearest * div_result
else:
return to_nearest * (div_result + 1)

If the the time is 2010, 12, 16, 23, 54 and the to_nearest is 5 (round to 
nearest 5 minutes), it works. 
If the time is 2010, 12, 16, 23, 55

it errors with the message minutes must be 0..59

I use it like this:
finishtime = lasttime.replace(minute=round_off(lasttime.minute, 
lasttime.second, to_nearest=5), second=0)

I'm too tired  ignorant to figure it out.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Simple debugger

2010-12-14 Thread Lorin Rivers
I couldn't get NetBeans to debug my web2py code. On a Mac.

Eclipse was a challenge to get set up and in one case, where I had some oddly 
broken code, the breakpoints didn't work how I expected them to. I had to step 
into EVERYTHING, down into the bowels of web2py, which was a real pain. I 
expect that if I have a BP at the beginning of a function and another inside 
that function that I should be able to resume and have it break again at the 
second BP, but that was not reliable for me.

Very frustrating.

I'm going to try ipdb.

On Dec 13, 2010, at 23:32 , weheh wrote:

 I want to go to Eclipse but didn't succeed in getting it to install 
 run the first time through.
 
 On Dec 14, 12:13 am, Branko Vukelic bg.bra...@gmail.com wrote:
 On Tue, Dec 14, 2010 at 5:45 AM, Bruno Rocha rochacbr...@gmail.com wrote:
 Someone else has any debug tip or advice for sharing?
 
 I used this:http://pypi.python.org/pypi/ipdb
 
 All the IPython goodness + pdb-style debugging. You get auto-complete
 and command history, too. ;)
 
 --
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog:http://www.brankovukelic.com/
 Check out my portfolio:http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca:http://identi.ca/foxbunny
 
 Gimp Brushmakers Guildhttp://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] basic views question

2010-12-14 Thread Lorin Rivers
I have an app Debug, a controller reports.py, functions in that controller 
index and test (plus a bunch of others).

  def index(): return dict(message=reports index)

  def test(): return dict(message=hello from reports.py)


In the directory structure ../views:
  appadmin.html
  /default:
display_debug_form.html
index.html
  generic.csv
  generic.html
  layout.html
  test.html
  web2py_ajax.html

When I go to ../Debug/reports/test.html

I get the generic.html view instead of test.html

Contents of test.html:
  
{{response.files.append(URL(r=request,c='static/stylesheets',f='styles.css'))}}
  {{extend 'layout.html'}}

What's up?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] basic views question

2010-12-14 Thread Lorin Rivers
No, it's in reports.py, a controller.

On Dec 14, 2010, at 13:37 , Bruno Rocha wrote:

 if def test() is defined inside default.py, the test.html should be in
 /views/default/test.html
 
 2010/12/14 Lorin Rivers lriv...@mosasaur.com
 
 I have an app Debug, a controller reports.py, functions in that
 controller index and test (plus a bunch of others).
 
 def index(): return dict(message=reports index)
 
 def test(): return dict(message=hello from reports.py)
 
 
 In the directory structure ../views:
 appadmin.html
 /default:
   display_debug_form.html
   index.html
 generic.csv
 generic.html
 layout.html
 test.html
 web2py_ajax.html
 
 When I go to ../Debug/reports/test.html
 
 I get the generic.html view instead of test.html
 
 Contents of test.html:
 
 {{response.files.append(URL(r=request,c='static/stylesheets',f='styles.css'))}}
 {{extend 'layout.html'}}
 
 What's up?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 -- 
 
 Bruno Rocha
 http://about.me/rochacbruno/bio

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] basic views question

2010-12-14 Thread Lorin Rivers
Thanks, I got it now.

On Dec 14, 2010, at 14:10 , Bruno Rocha wrote:

 so, you need views inside /views/reports/.html
 
 2010/12/14 Lorin Rivers lriv...@mosasaur.com
 
 No, it's in reports.py, a controller.
 
 On Dec 14, 2010, at 13:37 , Bruno Rocha wrote:
 
 if def test() is defined inside default.py, the test.html should be in
 /views/default/test.html
 
 2010/12/14 Lorin Rivers lriv...@mosasaur.com
 
 I have an app Debug, a controller reports.py, functions in that
 controller index and test (plus a bunch of others).
 
 def index(): return dict(message=reports index)
 
 def test(): return dict(message=hello from reports.py)
 
 
 In the directory structure ../views:
 appadmin.html
 /default:
  display_debug_form.html
  index.html
 generic.csv
 generic.html
 layout.html
 test.html
 web2py_ajax.html
 
 When I go to ../Debug/reports/test.html
 
 I get the generic.html view instead of test.html
 
 Contents of test.html:
 
 
 {{response.files.append(URL(r=request,c='static/stylesheets',f='styles.css'))}}
 {{extend 'layout.html'}}
 
 What's up?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 --
 
 Bruno Rocha
 http://about.me/rochacbruno/bio
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 -- 
 
 Bruno Rocha
 http://about.me/rochacbruno/bio

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Simple debugger

2010-12-14 Thread Lorin Rivers
Branko,

Can you explain how you use iPython and ipdb together to debug web2py apps?

How do I invoke web2py? How do I pass parameters to it like I do when invoking 
it with python (e.g., python web2py -a mumble -p 8000 -i 127.0.0.1)

Thanks!

On Dec 13, 2010, at 23:13 , Branko Vukelic wrote:

 On Tue, Dec 14, 2010 at 5:45 AM, Bruno Rocha rochacbr...@gmail.com wrote:
 Someone else has any debug tip or advice for sharing?
 
 I used this: http://pypi.python.org/pypi/ipdb
 
 All the IPython goodness + pdb-style debugging. You get auto-complete
 and command history, too. ;)
 
 
 -- 
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog: http://www.brankovukelic.com/
 Check out my portfolio: http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca: http://identi.ca/foxbunny
 
 Gimp Brushmakers Guild
 http://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Simple debugger

2010-12-14 Thread Lorin Rivers
Branko,

Thanks for that.

When I attempt to invoke web2py in iPython it seems to hang.

I tried this:
ipython web2py.py -a 1234 -i 127.0.0.1 -p 8000


On Dec 14, 2010, at 15:09 , Branko Vukelic wrote:

 Think of ipdb as of a print statement on steroids. If you want to
 debug a particular part of your app, you simply add this before that
 section in the source code:
 
import ipdb; ipdb.set_trace()
 
 When the server hits that part of the code, it will halt execution and
 display a prompt in the terminal. It's a regular IPython shell that
 accepts arbitrary python statements and expressions, as well as a
 debugging environment that supports pdb-style commands, like ``s`` for
 step, ``r`` for return (I think), etc. I don't remember the exact
 commands, but I think you can get help by typing ``h`` or ``help``.
 
 On Tue, Dec 14, 2010 at 10:02 PM, Lorin Rivers lriv...@mosasaur.com wrote:
 Branko,
 
 Can you explain how you use iPython and ipdb together to debug web2py apps?
 
 How do I invoke web2py? How do I pass parameters to it like I do when 
 invoking it with python (e.g., python web2py -a mumble -p 8000 -i 
 127.0.0.1)
 
 Thanks!
 
 On Dec 13, 2010, at 23:13 , Branko Vukelic wrote:
 
 On Tue, Dec 14, 2010 at 5:45 AM, Bruno Rocha rochacbr...@gmail.com wrote:
 Someone else has any debug tip or advice for sharing?
 
 I used this: http://pypi.python.org/pypi/ipdb
 
 All the IPython goodness + pdb-style debugging. You get auto-complete
 and command history, too. ;)
 
 
 --
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog: http://www.brankovukelic.com/
 Check out my portfolio: http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca: http://identi.ca/foxbunny
 
 Gimp Brushmakers Guild
 http://bit.ly/gbg-group
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 
 -- 
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog: http://www.brankovukelic.com/
 Check out my portfolio: http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca: http://identi.ca/foxbunny
 
 Gimp Brushmakers Guild
 http://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Translate this SQL to DAL?

2010-12-12 Thread Lorin Rivers
THere are a few aspects of the DAL that I can't  quite get my head around. For 
example, how would I do this?

select max(reqtime) from arraydata_table where rollupid = 0

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: anybody use the web2py IRC chat?

2010-12-12 Thread Lorin Rivers
I wish IRC was a little more active...

On Dec 12, 2010, at 8:30 , Luther Goh Lu Feng wrote:

 I do. But there are only about 10 people in the channel each time and
 many are afk. The mailing list is a better bet.
 
 On Dec 12, 10:18 pm, Branko Vukelic bg.bra...@gmail.com wrote:
 On Sun, Dec 12, 2010 at 8:48 AM, weheh richard_gor...@verizon.net wrote:
 Just curious. I don't use it, but I probably would if I thought I
 could get a fast response from an expert.
 
 Don't worry, you'll get answers here fast enough.
 
 --
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog:http://www.brankovukelic.com/
 Check out my portfolio:http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca:http://identi.ca/foxbunny
 
 Gimp Brushmakers Guildhttp://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Test for null not in a form

2010-12-12 Thread Lorin Rivers
Sometimes in the app I'm working on the default values aren't set in a column 
(for reasons outside of my control).

So, instead of using the default value as a filter, I need to also test for 
null.

How do I do that in the DAL?

In other words, select * from table where field is not NULL;


-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Test for null not in a form

2010-12-12 Thread Lorin Rivers
No kidding. That should be called out in The Book.

On Dec 12, 2010, at 17:14 , mdipierro wrote:

 db(db.mytable.myfield!=None).select()
 
 On Dec 12, 5:02 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 Sometimes in the app I'm working on the default values aren't set in a 
 column (for reasons outside of my control).
 
 So, instead of using the default value as a filter, I need to also test for 
 null.
 
 How do I do that in the DAL?
 
 In other words, select * from table where field is not NULL;
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Test for null not in a form

2010-12-12 Thread Lorin Rivers
As far as I can tell, the only place null is mentioned in the DAL page is in 
the definition of tables.


On Dec 12, 2010, at 17:35 , mdipierro wrote:

 The book never says that None is NULL?
 I will check. That would be a big omission.
 
 Massimo
 
 On Dec 12, 5:24 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 No kidding. That should be called out in The Book.
 
 On Dec 12, 2010, at 17:14 , mdipierro wrote:
 
 
 
 db(db.mytable.myfield!=None).select()
 
 On Dec 12, 5:02 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 Sometimes in the app I'm working on the default values aren't set in a 
 column (for reasons outside of my control).
 
 So, instead of using the default value as a filter, I need to also test 
 for null.
 
 How do I do that in the DAL?
 
 In other words, select * from table where field is not NULL;
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] web2py entry on wikipedia needs to be updated

2010-12-12 Thread Lorin Rivers
I made a few updates, version, book editions.

On Dec 12, 2010, at 18:23 , Bruno Rocha wrote:

 web2py entry on wikipedia[0] seens to be a little outdated showing
 deprecated information about web2py.
 
 [ Who uses.., latest version, applied stack, T2 T3(??), book editions, wiki,
 bazzar(?)...]
 
 I never created or edited wikipedia pages before, I need to learn a little
 about this markup to start helping on this page, if there is someone here
 who has the ability for writing in wikipedia and willing to help to keep
 this page updated, include a logo. some screenshots of new admin and
 welcome, mentioning the /poweredby and application wizard, and also the
 stand alone feature of the new dal.
 
 This is important because a search[1] on google shows wikipedia entry as the
 6th, bing[2] as the 3th, 2nd on Yahoo[3] and most people could take first
 impressions about the framework by this wikipedia entry.
 
 
 
 
 [0] http://en.wikipedia.org/wiki/Web2py
 
 [1] http://www.google.com/#sclient=psyhl=ensite=source=hpq=web2py
 
 [2] http://www.bing.com/search?q=web2pygo=form=QBREfilt=lf
 
 [3]
 http://search.yahoo.com/search;_ylt=AgEtnq9o2r4IzMOQfEIWyNubvZx4?p=web2pytoggle=1cop=mssei=UTF-8fr=yfp-t-701
 
 
 
 -- 
 
 Bruno Rocha
 http://about.me/rochacbruno/bio

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Basic models question

2010-12-06 Thread Lorin Rivers
If a model is defined in db.py, everything in that application has access to 
it, correct?

The only reason to define a model in a different file is if you only need to 
access that particular model in a similarly named controller, correct?

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] routes conundrum

2010-12-06 Thread Lorin Rivers
We've encountered a bug where our app behaves differently if you access it via 
/AppName/ than it does if you access it via /AppName/default/index

What would likely explain that and how should I go about ensuring identical 
behavior in either case?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] routes conundrum

2010-12-06 Thread Lorin Rivers
Richard,

Hence my confusion about it working differently depending on which url you 
access it with.

On Dec 6, 2010, at 11:40 , Richard Vézina wrote:

 By default http://YOURDOMAIN/AppName should redirect to
 http://YOURDOMAIN/AppName*/default/index*
 *
 *
 *Richard
 *
 On Mon, Dec 6, 2010 at 12:35 PM, Lorin Rivers lriv...@mosasaur.com wrote:
 
 We've encountered a bug where our app behaves differently if you access it
 via /AppName/ than it does if you access it via /AppName/default/index
 
 What would likely explain that and how should I go about ensuring identical
 behavior in either case?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] List of fields, want to use in .select(myList)

2010-12-03 Thread Lorin Rivers
I have a list of Field variables
whichAttributes = [t.f1, t.f2, t.f3]

 and I want to use them in my .select, like so:
records = dbset.select(whichAttributes,orderby=t.f4|t.f5)

How do I unroll that list into the select?

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: List of fields, want to use in .select(myList)

2010-12-03 Thread Lorin Rivers
SRSLY?!?!

facepalm.

On Dec 3, 2010, at 17:29 , mr.freeze wrote:

 records = dbset.select(*whichAttributes,orderby=t.f4|t.f5)
 * unpacks a list
 ** unpacks a dict
 
 On Dec 3, 5:16 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 I have a list of Field variables
 whichAttributes = [t.f1, t.f2, t.f3]
 
  and I want to use them in my .select, like so:
 records = dbset.select(whichAttributes,orderby=t.f4|t.f5)
 
 How do I unroll that list into the select?
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] convert a string to a table or field?

2010-12-01 Thread Lorin Rivers
I tried making a generic function that created a table variable by 
concatenating strings.

myTable = tableBuilder('inverter',period=5)

def tableBuilder(element,period=0):
  if element == 'inverter':
if period = 0:
  return 'db4.' + 'arraydata_table'
elif period = 1:
  return 'db4.array_mins'
else:
  return 'db4.array_' + period + 'mins'

That results in a syntax error. Can I do this or do I have to consider every 
elif? Like this:
  elif element == 'arrays':
if period = 0:
  return db4.arraydata_table
elif period = 1:
  return db4.array_mins
elif period = 5:
  return db4.array_5mins



-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Tweaking JSON

2010-11-29 Thread Lorin Rivers
I need to change the JSON output I get from this:
[{FreezeTime: 2010-11-08 21:00, Irrad_avg: 605.00}, {FreezeTime: 
2010-11-08 21:01, Irrad_avg: 600.66}]

to something more like this:

[['2010-11-08 21:00',605.00], ['2010-11-08 21:01',600.66]]

At the moment I'm using the simplejson.dumps method as explained in The Book 
http://web2py.com/book/default/chapter/09?search=json#simplejson.

What should I do?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] JSON into a html view

2010-11-29 Thread Lorin Rivers
How do I insert the results of a function into an html view as JSON?

Specifically I need a javascript variable in the view to include my JSON.
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The project I'm working on has hired a consultant who is now recommending .Net 
in place of web2py or even rails.

What's the 'largest' scale web2py is known to perform well on?

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
We're looking at utility scale deployments with thousands of nodes reporting 
data back to the server. That and the ability to compile .NET.

On Nov 29, 2010, at 12:05 , mdipierro wrote:

 You achieve scalability by replicating the web server behind a load
 balancer. This is documented in the book, chapter 11, using HAProxy.
 All frameworks work the same way in this respect. web2py has no
 intrinsic limitations. The bottle neck is the database connection. All
 frameworks have the same problem. You can replicate the database too
 and web2py supports multiple database clients with Round-Robin.
 
 On a small VPS, web2py in average, should execute one page in 20ms.
 Depending on how many requests/second you need you can determine how
 many servers you need.
 
 web2py apps run on Google App Engine and that means arbitrary
 scalability as long as you can live with the constraints imposed by
 the Google datastore (these limitations will go away as soon as Google
 releases MySQL in the cloud, which they announced some time ago).
 
 Please ask the consultant: which .NET feature makes it scale any
 better than web2py or Rails? If he explains we can address it more
 specifically.
 
 Massimo
 
 On Nov 29, 11:56 am, Lorin Rivers lriv...@mosasaur.com wrote:
 The project I'm working on has hired a consultant who is now recommending 
 .Net in place of web2py or even rails.
 
 What's the 'largest' scale web2py is known to perform well on?
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
Unfortunately, the killing argument is we know .NET will scale to thousands of 
nodes, blah, blah, blah.

This from (a guy who's smart and I respect, honestly) who uses his brand-new 
top-of-the-line 17 MBP to run Windows VMs in Parallels.

On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:

 And this without considering vendor lock-in. web2py can run on a
 variety of platforms such as windows, macs. Linux and others, same
 goes for the selection of the back-end database. Much more flexibility
 under web2py in my opinion and prototyping is much faster in python.
 
 On Nov 29, 10:05 am, mdipierro mdipie...@cs.depaul.edu wrote:
 You achieve scalability by replicating the web server behind a load
 balancer. This is documented in the book, chapter 11, using HAProxy.
 All frameworks work the same way in this respect. web2py has no
 intrinsic limitations. The bottle neck is the database connection. All
 frameworks have the same problem. You can replicate the database too
 and web2py supports multiple database clients with Round-Robin.
 
 On a small VPS, web2py in average, should execute one page in 20ms.
 Depending on how many requests/second you need you can determine how
 many servers you need.
 
 web2py apps run on Google App Engine and that means arbitrary
 scalability as long as you can live with the constraints imposed by
 the Google datastore (these limitations will go away as soon as Google
 releases MySQL in the cloud, which they announced some time ago).
 
 Please ask the consultant: which .NET feature makes it scale any
 better than web2py or Rails? If he explains we can address it more
 specifically.
 
 Massimo
 
 On Nov 29, 11:56 am, Lorin Rivers lriv...@mosasaur.com wrote:
 
 
 
 The project I'm working on has hired a consultant who is now recommending 
 .Net in place of web2py or even rails.
 
 What's the 'largest' scale web2py is known to perform well on?
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The good news is that the guy who hired ME picked web2py in the first place…

On Nov 29, 2010, at 13:51 , mdipierro wrote:

 Some political considerations (which may be wrong and off topic and
 improper)...
 
 Here is a problem with external consultants. They make more per hours
 than the average employees. They get hired because of their specific
 expertise to tell you what the boss wants to say but he prefers
 somebody else to say (so he does not take the responsibility for
 saying it).
 
 You cannot win this argument on technical merits. I would dismiss this
 argument and point to Google as a scalability example and it is not
 written in .net. I would address the real concern... you push web2py
 therefore you are a single point of failure. If you leave who takes
 care of this software? Not a problem with .net, they can always hire a
 consultant.
 
 I would stress that using web2py is good for rapid prototyping and it
 will allow the company to have a test product much sooner than
 with .net and at much lower cost. Once the prototype is built you will
 be in a better situation to assess whether web2py or .net is the best
 tool for the job. If you start developing in .net you will have higher
 startup costs and limited flexibility to change the specs. web2py code
 is much more compact and readable than .net code and it will be easier
 to train other people to work with it and learn how it works than
 with .net. Tell them experts4solutions.com can sell them long term
 support contracts and code review.
 
 The scalability bottle neck is the database. Offer something to the
 consultant. .net uses mssql. If he claims mssql scales well for your
 case, web2py will use mssql.
 
 If mssql does not scale well with web2py you have other options and do
 not need to rewrite code.
 
 You can always reuse most of the design (html, js, css, images).
 
 Management costs. I am sure you can make the case it costs less to run
 linux vps than windows ones (although I have no experience with the
 latter).
 
 Massimo

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Scalability of web2py?

2010-11-29 Thread Lorin Rivers
The number of people that can write code better than I can is close to the 
number of people who CAN write code…

On Nov 29, 2010, at 17:08 , Branko Vukelic wrote:

 We know .NET will scale to thousands of nodes IF you write the .NET
 code right. If you write crappy code (and that's inevitable if you
 don't like .NET or you don't know .NET), it will not only NOT run on
 thousands of nodes, but will probably crash all of them.
 
 Having said that... if they can help you write better code on .NET
 than you currently write in web2py, the above argument turns on you.
 
 On Mon, Nov 29, 2010 at 7:49 PM, Lorin Rivers lriv...@mosasaur.com wrote:
 Unfortunately, the killing argument is we know .NET will scale to thousands 
 of nodes, blah, blah, blah.
 
 This from (a guy who's smart and I respect, honestly) who uses his brand-new 
 top-of-the-line 17 MBP to run Windows VMs in Parallels.
 
 On Nov 29, 2010, at 12:20 , Julio Schwarzbeck wrote:
 
 And this without considering vendor lock-in. web2py can run on a
 variety of platforms such as windows, macs. Linux and others, same
 goes for the selection of the back-end database. Much more flexibility
 under web2py in my opinion and prototyping is much faster in python.
 
 On Nov 29, 10:05 am, mdipierro mdipie...@cs.depaul.edu wrote:
 You achieve scalability by replicating the web server behind a load
 balancer. This is documented in the book, chapter 11, using HAProxy.
 All frameworks work the same way in this respect. web2py has no
 intrinsic limitations. The bottle neck is the database connection. All
 frameworks have the same problem. You can replicate the database too
 and web2py supports multiple database clients with Round-Robin.
 
 On a small VPS, web2py in average, should execute one page in 20ms.
 Depending on how many requests/second you need you can determine how
 many servers you need.
 
 web2py apps run on Google App Engine and that means arbitrary
 scalability as long as you can live with the constraints imposed by
 the Google datastore (these limitations will go away as soon as Google
 releases MySQL in the cloud, which they announced some time ago).
 
 Please ask the consultant: which .NET feature makes it scale any
 better than web2py or Rails? If he explains we can address it more
 specifically.
 
 Massimo
 
 On Nov 29, 11:56 am, Lorin Rivers lriv...@mosasaur.com wrote:
 
 
 
 The project I'm working on has hired a consultant who is now recommending 
 .Net in place of web2py or even rails.
 
 What's the 'largest' scale web2py is known to perform well on?
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 
 
 
 
 -- 
 Branko Vukelić
 
 bg.bra...@gmail.com
 stu...@brankovukelic.com
 
 Check out my blog: http://www.brankovukelic.com/
 Check out my portfolio: http://www.flickr.com/photos/foxbunny/
 Registered Linux user #438078 (http://counter.li.org/)
 I hang out on identi.ca: http://identi.ca/foxbunny
 
 Gimp Brushmakers Guild
 http://bit.ly/gbg-group

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Recipe about mixing web2py, pydev, GoogleCode and others

2010-11-26 Thread Lorin Rivers
I'm all set up, but I can't debug in Eclipse. I put a breakpoint in my code and 
go to the page that should execute it and it doesn't break.

Got any ideas?

On Nov 17, 2010, at 20:17 , pierreth wrote:

 Hello,
 
 I just published a blog about mixing all this stuff in Eclipse for
 web2py development:
 
 # GC issue tracking with Mylyn;
 # GC versioning using Mercurial and the MercurialEclipse plug-in;
 # Pydev with code completion and code checking;
 # Aptana Studio plug-in for Eclipse for the edition of HTML and CSS
 files.
 
 http://pierreth.blogspot.com/2010/10/web2py-eclipse-pydev-recipe.html
 
 I hope you like. Comments are appreciated.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Debugging my app

2010-11-26 Thread Lorin Rivers
Getting pretty sick of using 'print' to debug.

I tried pydbgr, but that didn't seem to work (crashed python).

What other tools should I look at that will let me step through my web2py code?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Debugging my app

2010-11-26 Thread Lorin Rivers
So you just click (or whatever the gesture is) to the side of the line you want 
to break at and it just works?

To start a session, you right-click on web2py and start a debug session?

What platform are you on?

On Nov 26, 2010, at 10:32 , mr.freeze wrote:

 I use PyDev and Eclipse. It works like a champ. I can set breakpoints,
 inspect variables, create expressions at runtime. Very handy, not to
 mention that the mercurial eclipse plugin makes it very easy to
 update.
 
 On Nov 26, 10:25 am, Lorin Rivers lriv...@mosasaur.com wrote:
 Getting pretty sick of using 'print' to debug.
 
 I tried pydbgr, but that didn't seem to work (crashed python).
 
 What other tools should I look at that will let me step through my web2py 
 code?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Debugging my app

2010-11-26 Thread Lorin Rivers
I have python run, my web2py app is running, I can load it in the web browser 
in eclipse, the breakpoints are showing in the list of breakpoints and in the 
editor, my print statements are showing in the console, but it's NOT breaking.

Also, if I edit a file in an external editor, the changes don't appear in 
Eclipse. What's up with that?

On Nov 26, 2010, at 10:45 , mr.freeze wrote:

 I use both Ubuntu 10.10 and Windows 7.  The first time, you right
 click web2py.py in the file tree and choose Debug As / Python Run. If
 Python Run is not available, you need to verify your interpreter
 setup.
 
 On Nov 26, 10:37 am, Lorin Rivers lriv...@mosasaur.com wrote:
 So you just click (or whatever the gesture is) to the side of the line you 
 want to break at and it just works?
 
 To start a session, you right-click on web2py and start a debug session?
 
 What platform are you on?
 
 On Nov 26, 2010, at 10:32 , mr.freeze wrote:
 
 
 
 I use PyDev and Eclipse. It works like a champ. I can set breakpoints,
 inspect variables, create expressions at runtime. Very handy, not to
 mention that the mercurial eclipse plugin makes it very easy to
 update.
 
 On Nov 26, 10:25 am, Lorin Rivers lriv...@mosasaur.com wrote:
 Getting pretty sick of using 'print' to debug.
 
 I tried pydbgr, but that didn't seem to work (crashed python).
 
 What other tools should I look at that will let me step through my web2py 
 code?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Debugging my app

2010-11-26 Thread Lorin Rivers
Thanks, I ended up rebuilding my web2py project and now it works.

On Nov 26, 2010, at 11:13 , mr.freeze wrote:

 You have to right click on your project and choose Refresh to reflect
 external changes.  Do you see a green dot next to your breakpoint?
 Double click in the gray border to the left of the code and it should
 show a green dot.
 
 On Nov 26, 11:09 am, Lorin Rivers lriv...@mosasaur.com wrote:
 I have python run, my web2py app is running, I can load it in the web 
 browser in eclipse, the breakpoints are showing in the list of breakpoints 
 and in the editor, my print statements are showing in the console, but it's 
 NOT breaking.
 
 Also, if I edit a file in an external editor, the changes don't appear in 
 Eclipse. What's up with that?
 
 On Nov 26, 2010, at 10:45 , mr.freeze wrote:
 
 
 
 I use both Ubuntu 10.10 and Windows 7.  The first time, you right
 click web2py.py in the file tree and choose Debug As / Python Run. If
 Python Run is not available, you need to verify your interpreter
 setup.
 
 On Nov 26, 10:37 am, Lorin Rivers lriv...@mosasaur.com wrote:
 So you just click (or whatever the gesture is) to the side of the line you 
 want to break at and it just works?
 
 To start a session, you right-click on web2py and start a debug session?
 
 What platform are you on?
 
 On Nov 26, 2010, at 10:32 , mr.freeze wrote:
 
 I use PyDev and Eclipse. It works like a champ. I can set breakpoints,
 inspect variables, create expressions at runtime. Very handy, not to
 mention that the mercurial eclipse plugin makes it very easy to
 update.
 
 On Nov 26, 10:25 am, Lorin Rivers lriv...@mosasaur.com wrote:
 Getting pretty sick of using 'print' to debug.
 
 I tried pydbgr, but that didn't seem to work (crashed python).
 
 What other tools should I look at that will let me step through my 
 web2py code?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Development Questions

2010-11-26 Thread Lorin Rivers

On Nov 26, 2010, at 16:35 , Steve Shepherd wrote:

 IF someone could help with some examples of answers would be great.

snip
Someone less ignorant than I should answer that.

 2. How do I trace through code. line by line and then inspect values in 
 variables or objects

This I just solved for myself.

The short answer for #2 is Eclipse with PyDev  Aptana.

There are some good instructions here (plus a script that will do much of the 
setup):
http://pierreth.blogspot.com/2010/10/web2py-eclipse-pydev-recipe.html

It took me 2 tries to get it working, one of the options is to copy all the 
files from your project into your workspace, which caused me problems.

That option is unclearly worded, so avoid all the copying option in the Eclipse 
UI.

Hope that helps!

If you are on the Mac I could probably provide some more tips.
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] 'this or that' request with a url

2010-11-23 Thread Lorin Rivers
How can I perform an 'OR' request with a url? Or pass a list using a url?

I have 'AND' figured out…
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] 'this or that' request with a url

2010-11-23 Thread Lorin Rivers
Jonathan,

Sweet! That set me on the right path!

../?foo=somethingbar=something_elseother=thisother=that gives me 
what I want, which is:
request.var['foo']: something
request.var['bar']: something_else
request.var['bar']: [this, that]




On Nov 23, 2010, at 9:34 , Jonathan Lundell wrote:

 On Nov 23, 2010, at 6:28 AM, Lorin Rivers wrote:
 
 How can I perform an 'OR' request with a url? Or pass a list using a url?
 
 I have 'AND' figured out…
 
 I'm not quite sure what you're asking here, but I'm guessing that you're 
 interpreting the '' in a query string as 'and'. But it's not; it's just a 
 separator, punctuation. What you want the handler to do with the arguments is 
 a matter of convention and agreement.
 
 A somewhat limited way to do it would be to put your operator in args:
 
 http://domain.com/app/ctlr/fcn/or?item1item2item3
 http://domain.com/app/ctlr/fcn/and?item1item2item3
 http://domain.com/app/ctlr/fcn/list?item1item2item3

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] How do I capture the IDs from an 'insert'

2010-11-22 Thread Lorin Rivers
I have a set that represents the records within a minute time span, upon insert 
of the calculated summary into another table, I'd like to update the source set 
with the ID of the inserted record.

How do I do that?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: How do I capture the IDs from an 'insert'

2010-11-22 Thread Lorin Rivers
Do I need to set up my model so that the source set will accept the id?

I'm getting a KeyError on RollupID:
myset.update(RollupID=db4.array_mins.insert(..)

On Nov 22, 2010, at 10:18 , mdipierro wrote:

 id = db.table.insert()
 
 
 or
 
 form=SQLFORM(...)
 if form.accepts()
id=form.vars.id
 
 On Nov 22, 10:12 am, Lorin Rivers lriv...@mosasaur.com wrote:
 I have a set that represents the records within a minute time span, upon 
 insert of the calculated summary into another table, I'd like to update the 
 source set with the ID of the inserted record.
 
 How do I do that?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: How do I capture the IDs from an 'insert'

2010-11-22 Thread Lorin Rivers
Both tables have an int field RollupID.

The first table 'raw_data' is where I want to store the id of the insert into 
'minute_table' (which will in turn store the id of the insert of the 
'5minute_table').

There's no reference set up in the model.

On Nov 22, 2010, at 10:51 , mdipierro wrote:

 I do not underatnd the question. What is you current model?
 
 On Nov 22, 10:45 am, Lorin Rivers lriv...@mosasaur.com wrote:
 Do I need to set up my model so that the source set will accept the id?
 
 I'm getting a KeyError on RollupID:
 myset.update(RollupID=db4.array_mins.insert(..)
 
 On Nov 22, 2010, at 10:18 , mdipierro wrote:
 
 
 
 id = db.table.insert()
 
 or
 
 form=SQLFORM(...)
 if form.accepts()
id=form.vars.id
 
 On Nov 22, 10:12 am, Lorin Rivers lriv...@mosasaur.com wrote:
 I have a set that represents the records within a minute time span, upon 
 insert of the calculated summary into another table, I'd like to update 
 the source set with the ID of the inserted record.
 
 How do I do that?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Creating vars in a URL

2010-11-22 Thread Lorin Rivers
I've got the starttime and endtime portions figured out, how do I represent the 
Strings portion in a url?

Storage {'EndTime': '2010-11-08 22:00:00', 'String': ['S1', 'S2'], 
'StartTime': '2010-11-08 21:00:00', '_formname': 'no_table_create'}

Without the string bits, the url looks something like this:

http://localhost:8000/Debug/reports/export_array_records.csv/?starttime=%222010-11-08%2021:45:00%22endtime=%222010-11-08%2022:00:00%22

How should I construct a URL that includes the String bits?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: How do I capture the IDs from an 'insert' [solved]

2010-11-22 Thread Lorin Rivers
I did have to create a variable to store the returned ID  then update the set 
using the variable. In other words:

myRollUpID = db.table.insert(..)
mySet.update(RollUpID=myRollUpID)



On Nov 22, 2010, at 10:51 , mdipierro wrote:

 I do not underatnd the question. What is you current model?
 
 On Nov 22, 10:45 am, Lorin Rivers lriv...@mosasaur.com wrote:
 Do I need to set up my model so that the source set will accept the id?
 
 I'm getting a KeyError on RollupID:
 myset.update(RollupID=db4.array_mins.insert(..)
 
 On Nov 22, 2010, at 10:18 , mdipierro wrote:
 
 
 
 id = db.table.insert()
 
 or
 
 form=SQLFORM(...)
 if form.accepts()
id=form.vars.id
 
 On Nov 22, 10:12 am, Lorin Rivers lriv...@mosasaur.com wrote:
 I have a set that represents the records within a minute time span, upon 
 insert of the calculated summary into another table, I'd like to update 
 the source set with the ID of the inserted record.
 
 How do I do that?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Creating vars in a URL

2010-11-22 Thread Lorin Rivers
Phyko,

Can you provide a simple example?

On Nov 22, 2010, at 17:47 , Phyo Arkar wrote:

 You better use JSON via Post , dont pass from URL.
 
 On Tue, Nov 23, 2010 at 3:48 AM, Lorin Rivers lriv...@mosasaur.com wrote:
 
 I've got the starttime and endtime portions figured out, how do I represent
 the Strings portion in a url?
 
 Storage {'EndTime': '2010-11-08 22:00:00', 'String': ['S1', 'S2'],
 'StartTime': '2010-11-08 21:00:00', '_formname': 'no_table_create'}
 
 Without the string bits, the url looks something like this:
 
 
 http://localhost:8000/Debug/reports/export_array_records.csv/?starttime=%222010-11-08%2021:45:00%22endtime=%222010-11-08%2022:00:00%22
 
 
 How should I construct a URL that includes the String bits?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 
 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Model scope

2010-11-20 Thread Lorin Rivers
For some reason, a model in default/db.py wasn't loading, but after I copied 
over to another file in the models directory, it worked fine.

If I have a reports controller, a reports view, and a reports model, /reports/ 
is the only place that model will be available, right?

A model in defaults SHOULD be available globally, correct?

Also, what is the procedure for debugging a problem where a model won't load 
and the migrations don't take effect?

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: DAL to Qurey Multiple defined IDs?

2010-11-20 Thread Lorin Rivers
It is in the book:
http://web2py.com/book/default/chapter/06#Logical-Operators

On Nov 19, 2010, at 20:00 , Bruno Rocha wrote:

 Not mentioned in the book that you can get the NOT IN SQL expression
 
 my_list = [1,2,3,4]
 
 NOT IN LIST: db(~(db.product.id.belongs(my_list))).select()
 
 IN LIST: db(db.product.id.belongs(my_list)).select()
 
 
 2010/11/19 Bruno Rocha rochacbr...@gmail.com
 
 http://web2py.com/book/default/chapter/06#belongs
 
 
 
 2010/11/19 Phyo Arkar phyo.arkarl...@gmail.com
 
 GOT IT
 
 db.table.key.belongs
 
 
 I cant find it in web2py book is there is?
 
 
 On Sat, Nov 20, 2010 at 8:11 AM, Phyo Arkar phyo.arkarl...@gmail.comwrote:
 
 This can be done in Query easily as
 
 SELECT * FROM table WHERE table.id IN (1,2,4,5)
 
 Theres no DAL equvlient ?  i have to execute SQL?
 
 
 On Sat, Nov 20, 2010 at 8:00 AM, Phyo Arkar 
 phyo.arkarl...@gmail.comwrote:
 
 Eratta :
 
 
 
 
 to_get=[1,2,4,5]
 
 q= db.casedb.id in to_get # Guess this wont work?
 
 db(q).select(db.casedb.ALL)
 
 On Sat, Nov 20, 2010 at 7:54 AM, Phyo Arkar 
 phyo.arkarl...@gmail.comwrote:
 
 
 to_get=[1,2,4,5]
 
 q= db.casedb.id in toget
 db(q).select(db.casedb.ALL)
 
 
 
 
 
 
 
 --
 
 Bruno Rocha
 http://about.me/rochacbruno/bio
 
 
 
 
 -- 
 
 Bruno Rocha
 http://about.me/rochacbruno/bio

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] edit the book, get a free book

2010-11-20 Thread Lorin Rivers
You know, a comment feature would be really awesome for the online version of 
the book, like the PHP online docs have.

One thing (as I mentioned earlier) that I think would be super helpful would be 
more examples of SQL translated to DAL. I know SQL pretty well and often test 
what I want to achieve in web2py with SQL.

On Nov 18, 2010, at 20:32 , mdipierro wrote:

 If you have time to go over the last 1-2 months of emails and
 suggested book corrections and implement them in the book, I will send
 you a free printed version of the book.
 
 Please if you can do it, let us know in this thread to avoid
 duplication of work.
 
 The first responder gets the job.
 
 Massimo

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Questions about sets

2010-11-20 Thread Lorin Rivers
Are delete,  update the only the only database modification methods in set?

Can I do something like compute a value from information in a record in a set 
and update a field in that set with that info?

For example, my records include a string field which stores a date string and I 
want to update a field with the datetime calculated from that string.

Set operations are so fast and rows, not nearly as. It would be awesome if I 
could do some of this stuff in the set.

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Questions about sets

2010-11-20 Thread Lorin Rivers
What about using a function? I need run db.table.field through split (the time 
part has too many decimal places) and then convert from string to time

Here's what I tried:
db4((db4.data_table.ReqTime =2010-11-08T22:09:00)  (db4.data_table.ReqTime 
 2010-11-08T22:09:10)  (db4.data_table.MacAddr == 
00DF)).update(db4.data_table.FreezeTime=datetime.strptime(db4.data_table.ReqTime.split(.)[0],
 %Y-%m-%dT%H:%M:%S))

and got:
AttributeError: 'Field' object has no attribute 'split'

On Nov 20, 2010, at 11:40 , mdipierro wrote:

 something like this?
 
 db(query).update(field1=db.table.field2+db.table.field3)
 
 Massimo
 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Questions about sets

2010-11-20 Thread Lorin Rivers
What do you mean? The field ReqTime is defined as a string:

 db4.data_table[78978]
Row {'MacAddr': '00D1', 'update_record': function lambda at 
0x101cc9a28, 'Vi': 34.88671875, 'StringID': 'S0003', 'Vstring': 24.0, 
'Vo': 36.41015625, 'Ii': 1.61328125, 'Io': 1.4921875, 'RollupId': None, 'Po': 
54.330780029296903, 'ResTime': '2010-11-08T22:09:00.382999897', 'Pi': 
56.282089233398402, 'ReqTime': '2010-11-08T22:09:00.28292', 'id': 78978, 
'delete_record': function lambda at 0x101cc9b90, 'FreezeTime': None}
 type(row.ReqTime)
type 'str'


On Nov 20, 2010, at 13:36 , CesarBustios wrote:

 Did you try converting the Field to string?
 
 str(db4.data_table.ReqTime).split(.)[0]
 
 Lorin Rivers ha escrito:
 What about using a function? I need run db.table.field through split (the 
 time part has too many decimal places) and then convert from string to time
 
 Here's what I tried:
 db4((db4.data_table.ReqTime =2010-11-08T22:09:00)  
 (db4.data_table.ReqTime  2010-11-08T22:09:10)  (db4.data_table.MacAddr 
 == 
 00DF)).update(db4.data_table.FreezeTime=datetime.strptime(db4.data_table.ReqTime.split(.)[0],
  %Y-%m-%dT%H:%M:%S))
 
 and got:
 AttributeError: 'Field' object has no attribute 'split'
 
 On Nov 20, 2010, at 11:40 , mdipierro wrote:
 
 something like this?
 
 db(query).update(field1=db.table.field2+db.table.field3)
 
 Massimo
 
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Questions about sets

2010-11-20 Thread Lorin Rivers
I figured out what i was doing wrong. I should have been updating the datetime 
field with a string.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Migrations questions (help!)

2010-11-18 Thread Lorin Rivers
My database is PostgreSQL

I have tables defined in my ../models/db.py

Now I want to add some fields to one of the tables defined there. The table has 
data in it already.

I tried modifying the original table definition but that didn't actually change 
the table's structure.

Where should I make these changes? I have a model (rounding.py) that creates a 
new table in the database defined in db.py. That worked after some finagling (I 
think I had to drop the table and have the model recreate it, but it didn't 
have data yet).

So what is the best method for making incremental changes to databases?

I'm stuck and need some help.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Migrations questions (help!)

2010-11-18 Thread Lorin Rivers
They are not set to false.

I'm coming from a slight rails perspective (some experience with it). In rails, 
migrations are sequential. If you want to add a field to a table, you create a 
new migration that only does that.

Regarding my question, then, do most people just edit the model (i.e., add a 
field, change a field's type, and so on)?

On Nov 18, 2010, at 14:29 , VP wrote:

 Unless you have migration set to False, these things should be
 automatic.
 
 
 
 On Nov 18, 1:53 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 My database is PostgreSQL
 
 I have tables defined in my ../models/db.py
 
 Now I want to add some fields to one of the tables defined there. The table 
 has data in it already.
 
 I tried modifying the original table definition but that didn't actually 
 change the table's structure.
 
 Where should I make these changes? I have a model (rounding.py) that creates 
 a new table in the database defined in db.py. That worked after some 
 finagling (I think I had to drop the table and have the model recreate it, 
 but it didn't have data yet).
 
 So what is the best method for making incremental changes to databases?
 
 I'm stuck and need some help.
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Migrations questions (help!)

2010-11-18 Thread Lorin Rivers
I self-taught hacker (I would never describe myself as a programmer), I found 
rails to be less clear, it seem to be unnecessarily terse. I hate how ruby 
loops, I can never remember the syntax.

I find that DHH's personality flavors the framework (in a bad way) as your 
personality flavors web2py in a positive way.

It's hard to get used to blocks defined by indentation.

I wish there were more examples of simple things like the one I mentioned 
previously.

I find the migrations to not work that well and fail silently.

Overall, I'm loving web2py and growing to appreciate Python.


On Nov 18, 2010, at 15:12 , mdipierro wrote:

 As a rails user, would you share your experience with web2py so far?
 What you like, what you do not, what you think rails is better at?
 We'll defend ourselves but not take any offense. This can help us
 improve.
 
 Massimo
 
 On Nov 18, 2:47 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 They are not set to false.
 
 I'm coming from a slight rails perspective (some experience with it). In 
 rails, migrations are sequential. If you want to add a field to a table, you 
 create a new migration that only does that.
 
 Regarding my question, then, do most people just edit the model (i.e., add a 
 field, change a field's type, and so on)?
 
 On Nov 18, 2010, at 14:29 , VP wrote:
 
 
 
 Unless you have migration set to False, these things should be
 automatic.
 
 On Nov 18, 1:53 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 My database is PostgreSQL
 
 I have tables defined in my ../models/db.py
 
 Now I want to add some fields to one of the tables defined there. The 
 table has data in it already.
 
 I tried modifying the original table definition but that didn't actually 
 change the table's structure.
 
 Where should I make these changes? I have a model (rounding.py) that 
 creates a new table in the database defined in db.py. That worked after 
 some finagling (I think I had to drop the table and have the model 
 recreate it, but it didn't have data yet).
 
 So what is the best method for making incremental changes to databases?
 
 I'm stuck and need some help.
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)
 
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Easy to do using executesql, how to achieve with DAL?

2010-11-17 Thread Lorin Rivers
executesql('select min(reqtime) from data_table;')
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Easy to do using executesql, how to achieve with DAL?

2010-11-17 Thread Lorin Rivers
Massimo,

That pegs my CPU for a bit and then errors:
  File 
/Users/lrivers/Documents/CurrentProjects/SPTI/spowertech_webappserver1/gluon/sql.py,
 line 734, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'MIN(data_table.ReqTime)'

Here's my code:
m=db4.data_table.ReqTime.min()
firsttime = db4(db4.data_table).select().first()[m]


On Nov 17, 2010, at 13:30 , mdipierro wrote:

 m=db.data_table.reqtime.min()
 value = db(db.date_table).select().first()[m]
 
 On Nov 17, 11:43 am, Lorin Rivers lriv...@mosasaur.com wrote:
 executesql('select min(reqtime) from data_table;')
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Easy to do using executesql, how to achieve with DAL?

2010-11-17 Thread Lorin Rivers
I think this would make a good thing to have in the examples.

On Nov 17, 2010, at 13:45 , Massimo Di Pierro wrote:

 my mistake
 
 m=db4.data_table.ReqTime.min()
 firsttime = db4(db4.data_table).select(m).first()[m]
 
 On Nov 17, 2010, at 1:44 PM, Lorin Rivers wrote:
 
 m=db4.data_table.ReqTime.min()
 firsttime = db4(db4.data_table).select().first()[m]
 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] ajax push

2010-11-16 Thread Lorin Rivers
Thanks for mentioning this, looks interesting.

On Nov 15, 2010, at 15:24 , Michele Comitini wrote:

 Does anyone use this with web2py?
 
 http://www.ape-project.org/ajax-push.html
 
 seems interesting!
 
 mic

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Validate dynamically generated select SQLFORM.factory

2010-11-16 Thread Lorin Rivers
Actually, that block prevents the query from running when the page loads.


On Nov 16, 2010, at 8:58 , Kostas M wrote:

 It seems I don't understand what is the problem. Isn't the intended
 action the form to have errors if nothing is selected?
 This is checked with the: if form.accepts(request.vars, session): ...
 
 My app throws an error if you click the submit button without selecting an 
 item from the list in the form.
 
 I have tried adding 'zero=T('Choose one')', both with and without adding the 
 string 'Choose one' to the list 'options'. What would the best way to 
 validate this be?

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Passing values to another action/view

2010-11-16 Thread Lorin Rivers
I have a form where the user builds a query and on submit, displays the results.

I wanted to also have a link on that page to export the results as CSV, but I 
couldn't get the export action to use the values that the first action (display 
the results) does. To get it to work, I ended up duplicating the view and the 
action and changing it to save the csv file instead of displaying the results. 
This seems like more work than should be necessary and is also not a good 
coding practice.

How can I provide both pieces of functionality in one view?


controller:
def display_optimizer_form():
  # Loops through the MAC Addresses and puts them in a list
  options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
  
  #creates the form for choosing which Optimizers, from which time frame
  
form=SQLFORM.factory(Field('Optimizers',requires=IS_IN_SET(options,zero=T('Choose
 one or 
more'),multiple='multiple')),Field('StartTime',requires=[IS_NOT_EMPTY(),IS_DATETIME(format=T('%Y-%m-%dT%H:%M:%S'),
 error_message=T('must be 
-MM-DDTHH:MM:SS!'))]),Field('EndTime',requires=[IS_NOT_EMPTY(),IS_DATETIME(format=T('%Y-%m-%dT%H:%M:%S'),
 error_message=T('must be -MM-DDTHH:MM:SS!'))]))
  records=[]
  if form.accepts(request):

dbset=db4((db4.data_table.ReqTime=form.vars.StartTime.strftime('%Y-%m-%dT%H:%M:%S'))(db4.data_table.ReqTime=form.vars.EndTime.strftime('%Y-%m-%dT%H:%M:%S')))
if form.vars.Optimizers:
  query = reduce(lambda a,b:a|b,[db4.data_table.MacAddr==x for x in 
form.vars.Optimizers])
dbset=dbset(query)
records = 
dbset.select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po, 
orderby=db4.data_table.MacAddr|db4.data_table.ReqTime)
# print records
return dict(form=form,records=records,results=SQLTABLE(records, 
truncate=100,_class='results'),vars=form.vars,vars2=request.vars)
  else: results=[]
  
  return 
dict(form=form,records=records,results=results,vars=form.vars,vars2=request.vars)
  

def export_optimizer_form():
  import cStringIO
  stream=cStringIO.StringIO()
  # Loops through the MAC Addresses and puts them in a list
  options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
  
  #creates the form for choosing which Optimizers, from which time frame
  
form=SQLFORM.factory(Field('Optimizers',requires=IS_IN_SET(options,zero=T('Choose
 one or 
more'),multiple='multiple')),Field('StartTime',requires=[IS_NOT_EMPTY(),IS_DATETIME(format=T('%Y-%m-%dT%H:%M:%S'),
 error_message=T('must be 
-MM-DDTHH:MM:SS!'))]),Field('EndTime',requires=[IS_NOT_EMPTY(),IS_DATETIME(format=T('%Y-%m-%dT%H:%M:%S'),
 error_message=T('must be -MM-DDTHH:MM:SS!'))]))
  records=[]
  if form.accepts(request):

dbset=db4((db4.data_table.ReqTime=form.vars.StartTime.strftime('%Y-%m-%dT%H:%M:%S'))(db4.data_table.ReqTime=form.vars.EndTime.strftime('%Y-%m-%dT%H:%M:%S')))
if form.vars.Optimizers:
  query = reduce(lambda a,b:a|b,[db4.data_table.MacAddr==x for x in 
form.vars.Optimizers])
  print query
  print query
dbset=dbset(query)
records = 
dbset.select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po, 
orderby=db4.data_table.MacAddr|db4.data_table.ReqTime)
records.export_to_csv_file(stream)
response.headers['Content-Type']='application/vnd.ms-excel'
response.write(stream.getvalue(), escape=False)

return dict(form=form,records=records,results=SQLTABLE(records, 
truncate=100,_class='results'),vars=form.vars,vars2=request.vars)
  else: results=[]
  
  return 
dict(form=form,records=records,results=results,vars=form.vars,vars2=request.vars)

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] How can get max min of a field in a rows object

2010-11-16 Thread Lorin Rivers
I've got data with many, many rows, one record for each device that's being 
sampled every 6 seconds. I'm trying to roll up some of this data by getting the 
max, min, and average in a time span (for example, a minute).

Is there a way to do that with the rows object? Or do I have to craft queries 
for each time span to get the max, min, and count?

I tried using find on rows but couldn't get max to work with that.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Documentation/Examples Max

2010-11-16 Thread Lorin Rivers
I was going crazy when I was trying to figure out my max() question because of 
the frequent use of the person's name Max in the documentation and examples.
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Validate dynamically generated select SQLFORM.factory

2010-11-15 Thread Lorin Rivers
Thanks for all the help so far. I have made tons of progress on my app, and now 
I'm trying to add a little polish.

I have this code:

  # Loops through the MAC Addresses and puts them in a list
  # MAC Addresses is from a prior query
  options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
  
  #creates the form for choosing which Optimizers, from which time frame
  
form=SQLFORM.factory(Field('Optimizers',requires=IS_IN_SET(options,multiple='multiple')))
  
My app throws an error if you click the submit button without selecting an item 
from the list in the form.

I have tried adding 'zero=T('Choose one')', both with and without adding the 
string 'Choose one' to the list 'options'. What would the best way to validate 
this be?



-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: How do I construct my query to handle a multiple select?

2010-11-12 Thread Lorin Rivers
Sorry I wasn't clear. 

I'm using a select multiple element in my form. When more than one (in my 
example, it's a MAC address) item is chosen, I need to return a result set for 
each choice and display them together.  

I could do it with a query like: choice 1 OR choice 2 or I could do it  by 
combining the results of separate queries without the OR (there's also a date 
range but that's from a separate field and is hard-coded while I figure this 
other bit out).

I'm having trouble constructing the code to handle the multiple selections. The 
form returns the request.vars just fine, so that part of my code is working. I 
think I need to loop through the request.vars in my controller to build my 
query or queries but I can't figure out how. I tried using a loop from i to 
len(request.vars) but that didn't work.

On Nov 11, 2010, at 21:01, mdipierro mdipie...@cs.depaul.edu wrote:

 sorry I do not understand the question.
 
 On Nov 11, 6:12 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 I have a form using this:
   options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
   form=FORM(SELECT(*options,_name='MacAddrSelect',_multiple='multiple'),INPUT
   (_type='submit'))
 
   records = db4((db4.data_table.MacAddr==request.vars.MacAddrSelect)  
 (db4.data_table.ReqTime='2010-11-08T21:00')  
 (db4.data_table.ReqTime='2010-11-08T22:00')).select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po)
 
 How do I create a loop that will return records using more than one 
 selection in my form?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)


Re: [web2py] Re: How do I construct my query to handle a multiple select?

2010-11-12 Thread Lorin Rivers
Massimo,

Thanks, that works great!

What do I do to get it to only run on submit instead of load?

BTW, one of the things that's most awesome about web2py is your activity on the 
list and how helpful you are. I for one really appreciate that!

On Nov 12, 2010, at 10:12 , mdipierro wrote:

  options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
 
 form=SQLFORM.factory(Field('macs',requires=IS_IN_SET(options,multiple='multiple')))
 
 dbset=db4((db4.data_table.ReqTime='2010-11-08T21:00')(db4.data_table.ReqTime='2010-11-08T22:00'))
  if form.accepts(request) and form.vars.macs:
 query = reduce(lambda a,b:a|b,[db4.data_table.MacAddr==x for x in
 form.vars.macs])
 dbset=dbset(query)
  records =
 dbset.select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po)
 

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] How do I construct my query to handle a multiple select?

2010-11-11 Thread Lorin Rivers
I have a form using this:
  options=[str(my_macaddr[i].MacAddr) for i in range(len(my_macaddr))]
  form=FORM(SELECT(*options,_name='MacAddrSelect',_multiple='multiple'),INPUT
  (_type='submit'))

  records = db4((db4.data_table.MacAddr==request.vars.MacAddrSelect)  
(db4.data_table.ReqTime='2010-11-08T21:00')  
(db4.data_table.ReqTime='2010-11-08T22:00')).select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po)


How do I create a loop that will return records using more than one selection 
in my form?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




Re: [web2py] Re: Not getting a result from query

2010-11-10 Thread Lorin Rivers
Alex,

You put me on the right track! Thanks.

-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Using the results of a select/option in a query

2010-11-09 Thread Lorin Rivers
OK, I answered my own question from before.

I now have in my controller:
my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)

def display_form():
  form = FORM(TR(Select a MAC Address :, 
  SELECT(_name='MacAddrSelect', 
  *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
range(len(my_macaddr))])), 
  TR(INPUT(_type='submit')))
  return dict(form=form)

Which gives me the form I want. How do I turn the result of the submit into a 
query?

I want to generate something along the lines of this:

db4((db4.data_table.MacAddr=='00AF')  
(db4.data_table.ReqTime='2010-11-08T21:00')  
(db4.data_table.ReqTime='2010-11-08T22:00'))

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Not getting a result from query

2010-11-09 Thread Lorin Rivers
I think I'm close:
given this controller

my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)

def display_form():
  form = FORM(TR(Select a MAC Address :, 
  SELECT(_name='MacAddrSelect', 
  *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
range(len(my_macaddr))])), 
  TR(INPUT(_type='submit')))

  records = db4((db4.data_table.MacAddr==form.vars.MacAddrSelect)  
(db4.data_table.ReqTime='2010-11-08T21:00')
 
(db4.data_table.ReqTime='2010-11-08T22:00')).select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po)
  
  return 
dict(form=form,records=SQLTABLE(records),vars=form.vars,vars2=request.vars)


and this in my view:
{{extend 'layout.html'}}
h2Input form/h2
{{=form}}
h2Results/h2
p{{=records}}/p
h2Submitted variables/h2
{{=BEAUTIFY(request.vars)}}
h2Accepted variables/h2
{{=BEAUTIFY(form.vars)}}
h2Errors in form/h2
{{=BEAUTIFY(form.errors)}}


My form is displaying the request.vars and the three elements in the select(), 
but no results.

What am I missing/doing wrong?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)




[web2py] Select/Option using a query distinct=True

2010-11-08 Thread Lorin Rivers
Hi there,

I'm new to Web2Py and Python as well and I'm having trouble creating a form 
that does a search using a select/option, itself built with a query.

I can get the result I want from the web2py shell:
 for row in db4().select(db4.data_table.MacAddr, distinct=True):
...   print row.MacAddr
... 
00E0
00DF
00BB
00D1
00BD
00C0
00B1
00E5
00B3
00B4
00D2
00DA
00C1
00D8
00AF
00BE
00D9
00DC
00BA
00B5
00B9

but what I want is a popup in a form that will allow the user to choose which 
MacAddr to pull the data for (as well as a time span, the database contains 
data for each MacAddr every 6 seconds, the sample data set I have contains over 
2.5M records).

I did some googling and found this: 
http://wiki.web2py.com/Form_Select_Options_from_DB, but my version was giving 
me line continuation errors.

I could use some hand-holding, can someone walk me through the parts (i.e., 
controller and view code to achieve this)? 
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing http://www.mosasaur.com
mailto:lriv...@mosasaur.com
512/203.3198 (m)