[web2py] ticket uncoverable while login on 2.2.1 ?

2012-11-01 Thread vince
i am getting ticket unrecoverable error while using the auth login on 2.2.1 
once in a while.

restarting apache will fix it. any idea what's the problem? how do i trace 
it out?

-- 





[web2py] Problem in deploying ssl certificates to Rocket server.

2012-11-01 Thread Amit
 

Hi ,

I generated CA certificates, private key, server certificate and client 
certificate using “Simpatica” application developed in web2py. 

But when I tried to deploy the certificates to rocket server using below 
command on windows XP machine:

 

D:\web2py2.1.1\web2py>web2py.py 
--ssl_certificate=D:\certificates\server\cert.pe

m --ssl_private_key=D:\certificates\private_key\cacert.key 
--ca-cert=D:\certific

ates\CA_certificate\cacrt.pem

 

It starts web2py server dialog asking about password and after giving 
password, it displays below information on the command prompt:

 

No handlers could be found for logger "web2py"

web2py Web Framework

Created by Massimo Di Pierro, Copyright 2007-2012

Version 2.1.1 (2012-10-15 12:44:40) stable

Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000),

 IMAP(imaplib)

please visit:

https://127.0.0.1:8000

starting browser...

Enter PEM pass phrase:

Enter PEM pass phrase:

Enter PEM pass phrase:

 

As per the sequence of certificates on command line, I gave password for 
e.g. for cert.pem(server certificate file) , I have given Server@123, and 
for cacert.key(CA private key) and cacert.pem(CA certificate) , I have 
given test123.

NOTE: These passwords are used while generating the respective certificates 
means for generating cert.pem , I used Server@123 and so on.

So on above scenario , I have given password Server@123,test123 and test123 
on command prompt but it is giving following error on browser:

 

*Secure Connection Failed
   
 An error occurred during a connection to 127.0.0.1:8000.

Cannot communicate securely with peer: no common encryption algorithm(s).

(Error code: ssl_error_no_cypher_overlap)

  The page you are trying to view cannot be shown because the authenticity 
of the received data could not be verified.
  Please contact the website owners to inform them of this problem. 
Alternatively, use the command found in the help menu to report this broken 
site.*

 

 

Could anyone please help me out to resolve this issue?

 

Regards,

Amit

-- 





[web2py] Re: Formatter and values=None problem

2012-11-01 Thread Joe Barnhart
Please see my proposal about changing Field to map None 
values

On Tuesday, October 30, 2012 3:44:03 PM UTC-7, Joe Barnhart wrote:
>
> OK.  I will come up with a plan to extend the custom validators and not 
> break backward compatibility.  It seems like we could pass a keyword 
> variable to be used instead of None should the value be empty for the 
> formatter.  Maybe a separate "empty" value for the parser (input to 
> database) and formatter (output from database).
>
> Looks like I'll be getting into those "diff" tools for proper patch 
> submission after all...  ;-)
>
> -- Joe B.
>
>
> On Monday, October 29, 2012 8:25:19 PM UTC-7, Massimo Di Pierro wrote:
>>
>> I am reverting this. sorry.
>>
>> On Monday, 29 October 2012 10:09:35 UTC-5, Massimo Di Pierro wrote:
>>>
>>> This is what was talking about. I have fixed all the validators but 
>>> think may break third party custom validators this change is not 
>>> backward compatible.
>>>
>>>
>>>

-- 





Re: [web2py] Re: delete on GAE

2012-11-01 Thread howesc
so it turns out that GAE itself fails when i pass an iterator over a large 
list to gae.delete().  so i've tweaked the implementation to not call 
count, but to still count the number of entries deleted and it seems to be 
working.

suggested patch included 
in http://code.google.com/p/web2py/issues/detail?id=1134

thanks!

cfh

On Saturday, October 20, 2012 6:18:23 PM UTC-7, howesc wrote:
>
> sure.  i'll make a patch soon... 
>
> thanks for the input! 
>
> cfh 
>
> On 10/20/12 13:29 , Massimo Di Pierro wrote: 
> > I meant to skip count. 
> > 
> > On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote: 
> >> 
> >> How about adding a gae only parameter to the gae adapter_args that 
> tells 
> >> it to skip fetch? 
> >> 
> >> On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote: 
> >>> 
> >>> It appears that the most efficient way to delete on app engine is to: 
> >>>   - build a query object, like we are doing now 
> >>>   - call run with keys_only=True ( 
> >>> 
> https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
>  
>
> >>> which returns an iterator. 
> >>>   - pass that iterator to the datastore delete method ( 
> >>> 
> https://developers.google.com/appengine/docs/python/datastore/functions#delete
>  
> >>> ) 
> >>> 
> >>> this avoids the cost of loading the rows into memory, decreases the 
> >>> likelihood of timeout, and has the cost of 1 datastore small operation 
> per 
> >>> row.  but it does prevent us from getting a count of rows deleted. 
> >>> 
> >>> the way we do it now: 
> >>>   - run count() on the query.  this has a cost (time and money) of 
> >>> iterating over all the rows that match the query on GAE (1 datastore 
> small 
> >>> operation per row) 
> >>>   - run fetch(limit=1000) and call delete() successively until no more 
> >>> rows.  this has the cost of running a full query (at least 1 datastore 
> read 
> >>> operation per row) and loading the result set into memory and then 
> deleting 
> >>> the results. 
> >>> 
> >>> in my case i'm timing out on the count() call so i don't even start 
> the 
> >>> delete.  from an efficiency standpoint i'd rather have more rows 
> deleted 
> >>> for less cost then get a countbut this may not be acceptable for 
> all. 
> >>>   at a minimum i think we should switch to use keys_only=True for the 
> fetch, 
> >>> and skip the leading count() call and just sum the number of times we 
> call 
> >>> fetch.  we may also consider catching the datastore timeout error and 
> >>> trying to handle a partial delete more gracefully (or continue to let 
> the 
> >>> user catch the error). 
> >>> 
> >>> what is the "right" approach for web2py?  if the approach with count 
> is 
> >>> correct, could i propose a gae bulk_delete method that does not return 
> >>> count but uses my first method? 
> >>> 
> >>> thanks for the input! 
> >>> 
> >>> cfh 
> >>> 
> >>> On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro 
> wrote: 
>  
>  Delete should return the number of deleted records. What is your 
>  proposal? 
>  
>  On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote: 
> > 
> > Hi all, 
> > 
> > I'm trying to clean up old expired sessions.but i waited a long 
> > time to get to this and now my GAE delete is just timing out. 
>  Reading the 
> > GAE docs, there appears to be some improvements that we can make to 
> the 
> > query delete method on GAE that will make it faster and cheaper. 
>  what we 
> > lose then is the count of the number of rows deleted. 
> > 
> > my question is, does having a db(db.table.something==True).delete() 
> > that does not return a count break the web2py API contract, or break 
> > anyone's applications? 
> > 
> > thanks, 
> > 
> > christian 
> > 
>  
> > 
>

-- 





Re: [web2py] bootstrap modal and web2py LOAD()

2012-11-01 Thread LightDot
By "the whole page", do you mean the page from where the modal is called or 
just the contents of the modal itself..?

Anyway, I'm using LOAD() to display a form in a Bootstrap modal, the form 
submits data, data is processed by a function and a result is displayed in 
the same modal. I'd have to look at the code but if remember correctly, it 
was quite straightforward - just needs ajax trap set to true in the LOAD().

I'm using a custom html form in the view, FORM.factory in the controller, 
the function is called on form.process(...).accepted.

Regards,
Ales


On Thursday, November 1, 2012 10:24:35 PM UTC+1, Richard wrote:
>
> Hello,
>
> Anyone get work bootstrap modal with web2py LOAD() without having the 
> whole page reloaded on embedded form (load component contain a form) 
> submit??
>
> Thanks
>
> Richard
>

-- 





[web2py] Re: how to remove an install plug -- wiki

2012-11-01 Thread Massimo Di Pierro
Unless you use it (auth.wiki()) it is disabled.

On Thursday, 1 November 2012 18:55:54 UTC-5, patrick moon wrote:
>
> i'm having a problem with just trying to get web2py to with mssql on the 
> latest version and the welcome comes with the wiki pluggin insdtalled as a 
> default.  Is there a way to delete this?  there seem to be no delete button.
>
> 127.0.0.1.2012-11-01.16-48-29.12584d3d-101f-4883-a762-2a9ed0f109d4
>  ('42000', "[42000] [Microsoft][ODBC SQL 
> Server Driver][SQL Server]Introducing FOREIGN KEY constraint 
> 'plugin_wiki_page_modified_by__constraint' on table 'plugin_wiki_page' may 
> cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON 
> UPDATE NO ACTION, or modify other FOREIGN KEY constraints. (1785) 
> (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
> Server]Could not create constraint. See previous errors. (1750)") Version 
> web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')  
> Python Python 2.5.4: C:\_dev\Python25\python.exe
>

-- 





[web2py] how to remove an install plug -- wiki

2012-11-01 Thread patrick moon
i'm having a problem with just trying to get web2py to with mssql on the 
latest version and the welcome comes with the wiki pluggin insdtalled as a 
default.  Is there a way to delete this?  there seem to be no delete button.

127.0.0.1.2012-11-01.16-48-29.12584d3d-101f-4883-a762-2a9ed0f109d4
 ('42000', "[42000] [Microsoft][ODBC SQL 
Server Driver][SQL Server]Introducing FOREIGN KEY constraint 
'plugin_wiki_page_modified_by__constraint' on table 'plugin_wiki_page' may 
cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON 
UPDATE NO ACTION, or modify other FOREIGN KEY constraints. (1785) 
(SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
Server]Could not create constraint. See previous errors. (1750)") Version 
web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')  
Python Python 2.5.4: C:\_dev\Python25\python.exe

-- 





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

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

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

-Lamps


On Thursday, November 1, 2012 3:57:42 PM UTC-4, Niphlod wrote:
>
> only on the db part. select(distinct=...) sends a different query to the 
> db than select(). It's not web2py that "uniquify" the sets of the record 
> returned to make it distinct.
> Then.
> It's true that doing a distinct on a million rows table forces the db to 
> scan through a million of rows but doing distinct
> a) the db doesn't need to return one million of rows to your program 
> ("wire transfer" from db to app is less bulky)
> b) your program doesn't need to load it into memory and transform it in a 
> SELECT widget
>
> Last but not least.web2py hasn't an API to create indexes on the db, 
> but indexes on a db are a powerful/somewhat required thing to do/think 
> about when designing large applications. If you put an index in the table 
> column you're requesting that distinct, the db scans only the index and not 
> the million rows table
>
> On Thursday, November 1, 2012 8:18:50 PM UTC+1, Lamps902 wrote:
>>
>> Regarding the first point, the concern is not that the selector (as 
>> defined in the DB model) is instantiated with a huge variety of fields. If 
>> I'm not mistaken, if the "distinct" keyword in the select() function is 
>> left out, the program literally goes through every entry in the DB that 
>> matches the search criteria. I suspect that it does the same thing when 
>> "distinct" is used, and adds the additional step of filtering them down to 
>> the unique entries. I'm guessing this process may be quite resource 
>> intensive for a large DB. If there were a way to get the list of possible 
>> selector options straight from the model definition, that would seem to be 
>> much more efficient way of doing it (with the minor downside that there may 
>> not yet be any DB entries that match a given selector option), but I 
>> haven't found a way to do this.
>>
>> I guess I may need to start a new thread for the second point - might 
>> bring up some good tips on how to customize the grid. Thanks for the 
>> suggestion about the widget; I'll check it out. And thanks again for all 
>> the help - saved a tremendous amount of time on this task, and I'm sure 
>> others will find it useful as well!
>>
>> -Lamps
>>
>>
>> On Thursday, November 1, 2012 12:44:26 PM UTC-4, Jim S wrote:
>>>
>>> Lamps
>>>
>>> Wish I could be more help with your questions.  Here is my take.
>>>
>>> 1.  If you are thinking about having a large list, I would try to avoid 
>>> that.  Maybe your DISTINCT keyword will keep the list small.  My thoughts 
>>> are that a long list (25 entries or more) is not very user friendly and if 
>>> I had that situation, I'd just use the search box and filter on the fields 
>>> base on the text entered.
>>>
>>> 2.  I don't see how you'd be able to do this very easily.  Can probably 
>>> be done, but you'd have to get into /gluon/sqlhtml.py and make some changes 
>>> there to implement.
>>>
>>> 3.  I think you could probably do this.  If it were me doing it I'd look 
>>> into the suggest_widget plugin available from 
>>> http://dev.s-cubism.com/plugin_suggest_widget.
>>>
>>> Best of luck!  Sorry I couldn't be more helpful.
>>>
>>> -Jim
>>>
>>> On Thu, Nov 1, 2012 at 11:35 AM, Lamps902  wrote:
>>>
 I've followed Jim's model in creating my search filter, and it appears 
 to be working beautifully! Just have some questions that I would like to 
 ask. First - I slightly modified the selector code so that entries show up 
 as unique, by adding the "distinct" clause and ordering alphabetically by 
 category, by doing the following:


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

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

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

 Finally, if you wanted to redesign the filters to update after a 
 certain number of characters have been modified

[web2py] Re: Import error with 2.2.1

2012-11-01 Thread Massimo Di Pierro
Where is matplotlib installed?

On Thursday, 1 November 2012 15:51:14 UTC-5, Neil wrote:
>
> I just upgraded from 2.1 to 2.2.1, and I can no longer import matplotlib. 
> I get the following error:
>
> ImportError: Cannot import module 'matplotlib'
>
>
> Is this related to the custom import? Perhaps it is the same as issue 1125?
>
>

-- 





[web2py] Re: Geolocation

2012-11-01 Thread Jacinto Parga
I think I have a silly misunderstood with  jQuery.post

I'm trying to store the latitude and longitude in a db.events table. I 
haven't found the right way to do this simple thing,

This is my view: 

{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
{{extend 'layout.html'}}
View events/entry_event.html

  
jQuery.post({'url':'{{=URL('events','entry_event')}}','data':'a='+position.coords.latitude
 
+ "&b" + position.coords.longitude)});

{{=form}}

{{block right_sidebar}}
{{=A(T("Review events"), _href=URL('events'), _class='button', 
_style='margin-top: 1em;')}}
{{end}}

And this is the controller that does'nt work, of course

@auth.requires_login()
def entry_event():
"""returns a form where we can entry an event"""
form = crud.create(db.events)
db.events.latitude=request.post_vars('a')
db.events.longitude=request.post_vars('b')
return dict(form=form)

The thing is the event has got several fields you have to fill in the form, 
but the latitude and the longitude are suposed to be parameters we get from 
the browser.

The other way I have tried, but I don't like is, in the model:

Field('client_ip', default=current.request.client), # then I can use 
GeoIP

Would it be fine to set a default value to the latitude and longitude? How 
could it be? Would it be better than catching it from the browser?

Can you help me please,

Thanks in advance.


El domingo, 21 de octubre de 2012 00:42:15 UTC+2, Michael Gheith escribió:
>
> Hello web2py community!
>
> I have a question:
>
> I know how to get the user's geolocation:
>
> 
> if(navigator.geolocation) 
> {
> navigator.geolocation.getCurrentPosition(printLocation);
>
> function printLocation(position) 
> {
> alert("lat: " +position.coords.latitude + " lon: " + 
> position.coords.longitude);
> }
> }
> 
>
>
> So my question is this:  what's the BEST way to get position.coords.latitude, 
> and position.coords.longitude to a controller function?
>
>

-- 





Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables
The code is very simple.

@auth.requires_login() 
def searchtalab():
 "an ajax wiki search page"
 return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
  _onkeyup="ajax('callbacktalab', ['keyword'], 'target');")),
  target_div=DIV(_id='target'))

@auth.requires_login() 
def callbacktalab():
 "an ajax callback that returns a  of links to wiki pages"
* query = db.talab.body.contains(request.vars.keyword) | 
db.talab.title.contains(request.vars.keyword) *
 talabs = db(query).select( orderby=db.talab.on_date )
 links = [A(n.on_date,'  ..  ',( str(n.title)  ) ,'  ',( 
str(n.body)  ) ,'  ' , _href=URL('talab_r_search',args=n.id)) for n in 
talabs]
 return UL(*links)

and it is working perfect.

the highlighted query is using one tableno problem.

when I try to update the query to make it reference more than one table, I 
get the error?

the new query is

  query = ( ((db.talab.id == db.talab_comment.talab_id) & (db.talab.id == 
db.talab_document.id)) &
(   (db.talab.body.contains(request.vars.keyword)) | 
(db.talab.title.contains(request.vars.keyword))
|(db.talab_comment.body.contains(request.vars.keyword)) | 
(db.talab_document.doc_title.contains(request.vars.keyword))
)
 )


I hope everything is clear.

Regards,

Ashraf

-- 





[web2py] bootstrap modal and web2py LOAD()

2012-11-01 Thread Richard
Hello,

Anyone get work bootstrap modal with web2py LOAD() without having the whole 
page reloaded on embedded form (load component contain a form) submit??

Thanks

Richard

-- 





[web2py] Proposal: Explicit mapping of None values in Field object

2012-11-01 Thread Joe Barnhart
This proposal solves a problem I have when formatting Field values.  I 
created a custom Validator class which maps the value None into a string 
(such as "N/A" or "NT"), but the mapping was ignored because the current 
Field processing provides an early exit if the value of the Field is None, 
i.e. it never reaches the Validator object for formatting.

Proposal:

I propose creating a new keyword variable for Field objects, called 
"map_none" which is initialized to None for backwards compatibility:

 
   map_none = None,

. . .

   self.map_none = map_none



Next, we use the value of map_none as the return value for None from the 
formatter function:


def formatter(self, value):
requires = self.requires
if value is None or not self.requires:
return value or self.map_none


Last, for symmetry, we alter the validator to replace any occurrence of 
map_none with None when processing items to go back into the database.  In 
my case it will accept any entered value of "NT" and map it back into None 
when storing row data in the database.  I would also use it to replace 
empty strings with None (which I prefer over empty strings in the database 
when values are not entered).


def validate(self, value):
if not self.requires:
return ((value if value!=self.map_none else None), None)
requires = self.requires
if not isinstance(requires, (list, tuple)):
requires = [requires]
for validator in requires:
(value, error) = validator(value)
if error:
return (value, error)
return ((value if value!=self.map_none else None), None)

This approach allows any mapping of None into an object of the user's 
choosing, and provides the mapping in a consistent and bi-directional 
manner.  It preserves all existing behavior of Validators.  The only cost 
is an additional variable carried in Field objects and the time expended on 
the trivial "if" tests to map the value.

Any thoughts?

-- Joe B.

-- 





[web2py] Import error with 2.2.1

2012-11-01 Thread Neil
I just upgraded from 2.1 to 2.2.1, and I can no longer import matplotlib. I 
get the following error:

ImportError: Cannot import module 'matplotlib'


Is this related to the custom import? Perhaps it is the same as issue 1125?

-- 





Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread Richard Vézina
Try to isolate a dummy query the one that pass and the one that not pass...
I don't have much time to read all your code...

Richard

On Thu, Nov 1, 2012 at 4:13 PM, apps in tables wrote:

> Hi,
>
> why is 'contains()' working fine for one table query? and not working for
> more than one table query?
>
> Any ideas.
>
> Regards,
>
> Ashraf
>
> --
>
>
>
>

-- 





Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables
Hi,

why is 'contains()' working fine for one table query? and not working for 
more than one table query?

Any ideas.

Regards,

Ashraf

-- 





[web2py] Re: session[id]=Storage(id=id) between controllers

2012-11-01 Thread Niphlod


>
> Because there are exceptions, at the moment your solution solves the 
> problem, in a next iteration I'll probably solve it differently.
>
 
What exceptions ?

request.args(0, default=0, cast=int, otherwise=something)

does exactly the same thing I described

try:
  int(request.args(0))
except:
   something
 
It's just a nicer shortcut to use

-- 





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

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

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

On Thursday, November 1, 2012 8:18:50 PM UTC+1, Lamps902 wrote:
>
> Regarding the first point, the concern is not that the selector (as 
> defined in the DB model) is instantiated with a huge variety of fields. If 
> I'm not mistaken, if the "distinct" keyword in the select() function is 
> left out, the program literally goes through every entry in the DB that 
> matches the search criteria. I suspect that it does the same thing when 
> "distinct" is used, and adds the additional step of filtering them down to 
> the unique entries. I'm guessing this process may be quite resource 
> intensive for a large DB. If there were a way to get the list of possible 
> selector options straight from the model definition, that would seem to be 
> much more efficient way of doing it (with the minor downside that there may 
> not yet be any DB entries that match a given selector option), but I 
> haven't found a way to do this.
>
> I guess I may need to start a new thread for the second point - might 
> bring up some good tips on how to customize the grid. Thanks for the 
> suggestion about the widget; I'll check it out. And thanks again for all 
> the help - saved a tremendous amount of time on this task, and I'm sure 
> others will find it useful as well!
>
> -Lamps
>
>
> On Thursday, November 1, 2012 12:44:26 PM UTC-4, Jim S wrote:
>>
>> Lamps
>>
>> Wish I could be more help with your questions.  Here is my take.
>>
>> 1.  If you are thinking about having a large list, I would try to avoid 
>> that.  Maybe your DISTINCT keyword will keep the list small.  My thoughts 
>> are that a long list (25 entries or more) is not very user friendly and if 
>> I had that situation, I'd just use the search box and filter on the fields 
>> base on the text entered.
>>
>> 2.  I don't see how you'd be able to do this very easily.  Can probably 
>> be done, but you'd have to get into /gluon/sqlhtml.py and make some changes 
>> there to implement.
>>
>> 3.  I think you could probably do this.  If it were me doing it I'd look 
>> into the suggest_widget plugin available from 
>> http://dev.s-cubism.com/plugin_suggest_widget.
>>
>> Best of luck!  Sorry I couldn't be more helpful.
>>
>> -Jim
>>
>> On Thu, Nov 1, 2012 at 11:35 AM, Lamps902  wrote:
>>
>>> I've followed Jim's model in creating my search filter, and it appears 
>>> to be working beautifully! Just have some questions that I would like to 
>>> ask. First - I slightly modified the selector code so that entries show up 
>>> as unique, by adding the "distinct" clause and ordering alphabetically by 
>>> category, by doing the following:
>>>
>>>
>>> category_list = db().select(db.t_files.f_category, distinct=True, 
>>> orderby=db.t_files.f_category)
>>> options = [OPTION(category_list[i].f_category, 
>>>   _value=str(category_list[i].f_category)) for i inrange
>>> (len(category_list))]
>>>
>>> Will this become extremely inefficient and slow, and grind the system to 
>>> a halt as the database become large?
>>>
>>> The second question concerns an important cosmetic change  - is there a 
>>> good way to put the filter input fields (no labels) under the column 
>>> headers/labels in the grid?
>>>
>>> Finally, if you wanted to redesign the filters to update after a certain 
>>> number of characters have been modified in an input field (i.e. without 
>>> having to click search), how would you go about doing that?
>>>
>>> Thanks again!
>>>
>>> -Lamps
>>>
>>> On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:
>>>
 I'm attaching a quick-n-dirty search example.  You'll have to provide 
 your own data to get it running.  It worked with my test data.  Let me 
 know 
 if you have troubles and I'll be glad to work through them with you.

 -Jim


 On Wed, Oct 31, 2012 at 8:53 AM, Lamps902  wrote:

> Hi, Jim. It would be great if you could provide more details and some 
> code illustrating how you went about doing it. Thanks!
>
> -Lamps
>
>
> On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:
>>
>> Using .smartgrid, I override the default filtering

Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables
Hi Richard,

yes, the search is working perfect for query based on one table.

I am trying to include the details tables in the search. 

Any special format for the query that is based on more than one table?

Regards,

Ashraf


On Thursday, November 1, 2012 10:28:50 PM UTC+3, Richard wrote:
>
>
> Does it works if you remove one table from you query?
>
> Richard
>
> On Thu, Nov 1, 2012 at 3:21 PM, apps in tables 
> 
> > wrote:
>
>>
>>
>> I only made the query based on more than one table, and that caused the 
>> problem. 
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] jQuery UI Bootstrap

2012-11-01 Thread Richard
I was starting to notice some conflict using bootstrap.js and jQueyr UI at 
the same time and fall on this doing little research...

http://addyosmani.github.com/jquery-ui-bootstrap/

Richard

-- 





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

2012-11-01 Thread Lamps902
In a previous 
thread,
 
we discussed how to implement multiple search filter fields for a grid. 
That being done, I'm curious if there's a reasonable way to put the filters 
(all currently part of a single FORM) under their corresponding column 
headers in the grid. This 
linkis an 
example of the look that I was going for. Thanks.

-- 





Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread Richard Vézina
Does it works if you remove one table from you query?

Richard

On Thu, Nov 1, 2012 at 3:21 PM, apps in tables wrote:

>
>
> I only made the query based on more than one table, and that caused the
> problem.
>
> --
>
>
>
>

-- 





[web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables


I only made the query based on more than one table, and that caused the 
problem.

-- 





[web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables


I only made the query based on more than one table, and that caused the 
problem.

-- 





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

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

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

-Lamps


On Thursday, November 1, 2012 12:44:26 PM UTC-4, Jim S wrote:
>
> Lamps
>
> Wish I could be more help with your questions.  Here is my take.
>
> 1.  If you are thinking about having a large list, I would try to avoid 
> that.  Maybe your DISTINCT keyword will keep the list small.  My thoughts 
> are that a long list (25 entries or more) is not very user friendly and if 
> I had that situation, I'd just use the search box and filter on the fields 
> base on the text entered.
>
> 2.  I don't see how you'd be able to do this very easily.  Can probably be 
> done, but you'd have to get into /gluon/sqlhtml.py and make some changes 
> there to implement.
>
> 3.  I think you could probably do this.  If it were me doing it I'd look 
> into the suggest_widget plugin available from 
> http://dev.s-cubism.com/plugin_suggest_widget.
>
> Best of luck!  Sorry I couldn't be more helpful.
>
> -Jim
>
> On Thu, Nov 1, 2012 at 11:35 AM, Lamps902 
> > wrote:
>
>> I've followed Jim's model in creating my search filter, and it appears to 
>> be working beautifully! Just have some questions that I would like to ask. 
>> First - I slightly modified the selector code so that entries show up as 
>> unique, by adding the "distinct" clause and ordering alphabetically by 
>> category, by doing the following:
>>
>>
>> category_list = db().select(db.t_files.f_category, distinct=True, 
>> orderby=db.t_files.f_category)
>> options = [OPTION(category_list[i].f_category, 
>>   _value=str(category_list[i].f_category)) for i inrange
>> (len(category_list))]
>>
>> Will this become extremely inefficient and slow, and grind the system to 
>> a halt as the database become large?
>>
>> The second question concerns an important cosmetic change  - is there a 
>> good way to put the filter input fields (no labels) under the column 
>> headers/labels in the grid?
>>
>> Finally, if you wanted to redesign the filters to update after a certain 
>> number of characters have been modified in an input field (i.e. without 
>> having to click search), how would you go about doing that?
>>
>> Thanks again!
>>
>> -Lamps
>>
>> On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:
>>
>>> I'm attaching a quick-n-dirty search example.  You'll have to provide 
>>> your own data to get it running.  It worked with my test data.  Let me know 
>>> if you have troubles and I'll be glad to work through them with you.
>>>
>>> -Jim
>>>
>>>
>>> On Wed, Oct 31, 2012 at 8:53 AM, Lamps902  wrote:
>>>
 Hi, Jim. It would be great if you could provide more details and some 
 code illustrating how you went about doing it. Thanks!

 -Lamps


 On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:
>
> Using .smartgrid, I override the default filtering capabilities and 
> provide my own.  See attached screenshot.  Let me know if you want more 
> details.  I think I uploaded a small example app to the list some time 
> ago 
> and should be able to find it or recreate it if you like.
>
> -Jim
>
> On Wednesday, October 31, 2012 8:33:52 AM UTC-5, Lamps902 wrote:
>>
>> Hi, Johann - I know you can build a complex query using the search 
>> box, but that is far from intuitive for most users. I'd like to 
>> implement 
>> the same look/feel/usability as was available in webgrid, and as is 
>> shown 
>> in the image. Is there a reasonable way to do this? Thanks.
>>
>> -Lamps
>>
>> On Wednesday, October 31, 2012 2:40:05 AM UTC-4, Johann Spies wrote:
>>>
>>> You can do that by building a complex query using the search box.
>>>
>>> Regards
>>> Johann
>>>
>>>
>>> -- 
>>> Because experiencing your loyal love is better than life itself, 
>>> my lips will pr

Re: [web2py] emmet

2012-11-01 Thread Richard Vézina
It nice, but the shortcut are not well choosed I think... They seems to
conflict will Linux desktop shortcut.

Richard

On Thu, Nov 1, 2012 at 2:38 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> http://docs.emmet.io/
>
> in case you do not know. This has been in admin stable for a while
>
> --
>
>
>
>

-- 





[web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables

I got the same error with version 2.2.1
 

> Ashraf
>>
>

-- 





[web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread Massimo Di Pierro
I do not know. Anyway, you are using 2.0.9. Can you upgrade to 2.2.1?

On Thursday, 1 November 2012 12:07:41 UTC-5, apps in tables wrote:
>
> Hi,
>
> I did small changes to the example in the book (ajax search),
>
> @auth.requires_login() 
> def searchtalab():
>  "an ajax wiki search page"
>  return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
>   _onkeyup="ajax('callbacktalab', ['keyword'], 'target');")),
>   target_div=DIV(_id='target'))
>
> @auth.requires_login() 
> def callbacktalab():
>  "an ajax callback that returns a  of links to wiki pages"
>  query = db.talab.body.contains(request.vars.keyword) | 
> db.talab.title.contains(request.vars.keyword) 
>  talabs = db(query).select( orderby=db.talab.on_date )
>  links = [A(n.on_date,'  ..  ',( str(n.title)  ) ,'  ',( 
> str(n.body)  ) ,'  ' , _href=URL('talab_r_search',args=n.id)) for n 
> in talabs]
>  return UL(*links)
>
> and  it is working perfect.
>
> then I am trying to do the search, not only in one table , but to include 
> the details tables, So, I wrote it as :
>
> @auth.requires_login() 
> def searchtalabdetails():
>  "an ajax wiki search page"
>  return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
>   _onkeyup="ajax('searchtalabdetails', ['keyword'], 
> 'target');")),
>   target_div=DIV(_id='target'))
>
> @auth.requires_login() 
> def searchtalabdetails():
>  "an ajax callback that returns a  of links to wiki pages"
>  query = ( ((db.talab.id == db.talab_comment.talab_id) & (db.talab.id== 
> db.talab_document.id)) &
> (   (db.talab.body.contains(request.vars.keyword)) | 
> (db.talab.title.contains(request.vars.keyword))
> |(db.talab_comment.body.contains(request.vars.keyword)) | 
> (db.talab_document.doc_title.contains(request.vars.keyword))
> )
>  )
>  talabs = db(query).select( orderby=db.talab.on_date )
>  links = [A(n.talab.on_date,'  ..  ',( str(n.talab.title)  ) ,' 
>  ',( str(n.talab.body)  ) ,'  ' , _href=URL('talab_r_search',args=
> n.talab.id)) for n in talabs]
>  return UL(*links)
>
>
> but it gave me the error:
>
>  CONTAINS() takes exactly 3 arguments (2 
> given)VERSIONweb2py™(2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51, 30), 
> 'stable')TRACEBACK
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 209, in restricted
>   File 
> "C:/Users/Toshiba/Desktop/web2py_209/web2py/applications/e_galya/controllers/default.py"
>  , 
> line 1190, in 
>   File "gluon/globals.py", line 186, in 
>   File "gluon/tools.py", line 2809, in f
>   File 
> "C:/Users/Toshiba/Desktop/web2py_209/web2py/applications/e_galya/controllers/default.py"
>  , 
> line 74, in searchtalabdetails
>   File "gluon/dal.py", line 8766, in select
>   File "gluon/dal.py", line 2094, in select
>   File "gluon/dal.py", line 1581, in select
>   File "gluon/dal.py", line 1444, in _select
>   File "gluon/dal.py", line 1277, in expand
>   File "gluon/dal.py", line 1160, in AND
>   File "gluon/dal.py", line 1277, in expand
>   File "gluon/dal.py", line 1163, in OR
>   File "gluon/dal.py", line 1277, in expand
>   File "gluon/dal.py", line 1163, in OR
>   File "gluon/dal.py", line 1277, in expand
>   File "gluon/dal.py", line 1163, in OR
>   File "gluon/dal.py", line 1279, in expand
> TypeError: CONTAINS() takes exactly 3 arguments (2 given)
>
>
> What did i do wrong?
>
> Regards,
>
> Ashraf
>

-- 





[web2py] Re: long load time for scipy package

2012-11-01 Thread Massimo Di Pierro
I believe the session problem is solved. I cannot completely exclude 
problems with retrieving sessions created with early/different web2py 
versions.

On Thursday, 1 November 2012 12:03:19 UTC-5, lucas wrote:
>
> On Thursday, November 1, 2012 8:43:12 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Unless you enabled track_changes(True) this should not be the case. The 
>> package should only be loaded once. Where did you put the package?
>>
>
> hey massimo,
>
> i didn't have track_changes(True) anywhere, but your last question got me 
> thinking because i had the scipy package and code embedded within the 
> default/main controller.  so i created a new module and put that import and 
> respective code under that new module.  then i put a new import in the 
> default/main module and i think it is better.  i will have to test it more 
> rigorously.  if i have problems, i will let you know.
>
> btw, did you fix that pickle.load problem that threw back the 
> unrecoverable error when my users were trying to login because it seemed to 
> have disappeared when i upgraded web2py to 2.2.1?  if so that is great that 
> was totally haunting me so badly.  now that is real professor talk.
>
> thanx massimo, have a great weekend.  lucas
>

-- 





[web2py] Re: zero='select a value' no longer shows

2012-11-01 Thread Massimo Di Pierro
This code would have never triggered a dropbox. 

requires = IS_IN_DB(...) # dropbox

requires = [IS_IN_DB(...)...] # no dropbox

this has been the rule since web2py 1.0.

On Thursday, 1 November 2012 11:46:38 UTC-5, Annet wrote:
>
> I defined the following validator:
>
> nodeSocialMedia.nodeID.requires=[IS_IN_DB(db,'socialMedia.id','%(name)s',zero=T('select
>  
> a 
> value')),IS_NOT_IN_DB(db(db.nodeSocialMedia.nodeID==request.vars.nodeID),'nodeSocialMedia.socialMediaID',error_message=T('combination
>  
> node and social media already in database'))]
>
> In web2py 2.2.1 'select a value' no longer shows in the drop box, has 
> anything changed?
>
> Kind regards,
>
> Annet.
>

-- 





[web2py] emmet

2012-11-01 Thread Massimo Di Pierro
http://docs.emmet.io/

in case you do not know. This has been in admin stable for a while

-- 





Re: [web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread Richard Vézina
Not sure, but the request.vars.VAR is text type even if your value is
integer, so maybe there is a check to do there.

Richard

On Thu, Nov 1, 2012 at 1:25 PM, apps in tables wrote:

>
> I got the same error with
>
> VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4),
> 'stable')
>
>  --
>
>
>
>

-- 





[web2py] Re: CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables

I got the same error with

VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 
'stable')

-- 





[web2py] CONTAINS() takes exactly 3 arguments (2 given)

2012-11-01 Thread apps in tables
Hi,

I did small changes to the example in the book (ajax search),

@auth.requires_login() 
def searchtalab():
 "an ajax wiki search page"
 return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
  _onkeyup="ajax('callbacktalab', ['keyword'], 'target');")),
  target_div=DIV(_id='target'))

@auth.requires_login() 
def callbacktalab():
 "an ajax callback that returns a  of links to wiki pages"
 query = db.talab.body.contains(request.vars.keyword) | 
db.talab.title.contains(request.vars.keyword) 
 talabs = db(query).select( orderby=db.talab.on_date )
 links = [A(n.on_date,'  ..  ',( str(n.title)  ) ,'  ',( 
str(n.body)  ) ,'  ' , _href=URL('talab_r_search',args=n.id)) for n in 
talabs]
 return UL(*links)

and  it is working perfect.

then I am trying to do the search, not only in one table , but to include 
the details tables, So, I wrote it as :

@auth.requires_login() 
def searchtalabdetails():
 "an ajax wiki search page"
 return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
  _onkeyup="ajax('searchtalabdetails', ['keyword'], 
'target');")),
  target_div=DIV(_id='target'))

@auth.requires_login() 
def searchtalabdetails():
 "an ajax callback that returns a  of links to wiki pages"
 query = ( ((db.talab.id == db.talab_comment.talab_id) & (db.talab.id 
== db.talab_document.id)) &
(   (db.talab.body.contains(request.vars.keyword)) | 
(db.talab.title.contains(request.vars.keyword))
|(db.talab_comment.body.contains(request.vars.keyword)) | 
(db.talab_document.doc_title.contains(request.vars.keyword))
)
 )
 talabs = db(query).select( orderby=db.talab.on_date )
 links = [A(n.talab.on_date,'  ..  ',( str(n.talab.title)  ) ,' 
 ',( str(n.talab.body)  ) ,'  ' , 
_href=URL('talab_r_search',args=n.talab.id)) for n in talabs]
 return UL(*links)


but it gave me the error:

 CONTAINS() takes exactly 3 arguments (2 given)
VERSIONweb2py™(2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51, 30), 
'stable')TRACEBACK

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.

Traceback (most recent call last):
  File "gluon/restricted.py", line 209, in restricted
  File 
"C:/Users/Toshiba/Desktop/web2py_209/web2py/applications/e_galya/controllers/default.py"
 , 
line 1190, in 
  File "gluon/globals.py", line 186, in 
  File "gluon/tools.py", line 2809, in f
  File 
"C:/Users/Toshiba/Desktop/web2py_209/web2py/applications/e_galya/controllers/default.py"
 , 
line 74, in searchtalabdetails
  File "gluon/dal.py", line 8766, in select
  File "gluon/dal.py", line 2094, in select
  File "gluon/dal.py", line 1581, in select
  File "gluon/dal.py", line 1444, in _select
  File "gluon/dal.py", line 1277, in expand
  File "gluon/dal.py", line 1160, in AND
  File "gluon/dal.py", line 1277, in expand
  File "gluon/dal.py", line 1163, in OR
  File "gluon/dal.py", line 1277, in expand
  File "gluon/dal.py", line 1163, in OR
  File "gluon/dal.py", line 1277, in expand
  File "gluon/dal.py", line 1163, in OR
  File "gluon/dal.py", line 1279, in expand
TypeError: CONTAINS() takes exactly 3 arguments (2 given)


What did i do wrong?

Regards,

Ashraf

-- 





[web2py] Re: long load time for scipy package

2012-11-01 Thread lucas
On Thursday, November 1, 2012 8:43:12 AM UTC-4, Massimo Di Pierro wrote:
>
> Unless you enabled track_changes(True) this should not be the case. The 
> package should only be loaded once. Where did you put the package?
>

hey massimo,

i didn't have track_changes(True) anywhere, but your last question got me 
thinking because i had the scipy package and code embedded within the 
default/main controller.  so i created a new module and put that import and 
respective code under that new module.  then i put a new import in the 
default/main module and i think it is better.  i will have to test it more 
rigorously.  if i have problems, i will let you know.

btw, did you fix that pickle.load problem that threw back the unrecoverable 
error when my users were trying to login because it seemed to have 
disappeared when i upgraded web2py to 2.2.1?  if so that is great that was 
totally haunting me so badly.  now that is real professor talk.

thanx massimo, have a great weekend.  lucas

-- 





[web2py] Re: clean up session[id]=Storage(id=id)

2012-11-01 Thread Annet
Hi,

Thanks for providing me with this solution. 

save "update_time" on session[id] (or elsewhere) whenever session is "used" 
> and then check...
>
> if session[id].creation_time and session[id].creation_time > request.now 
> -datetime
> .timedelta(seconds=60):
>  ...do the cleanup
>
>
Kind regards,

Annet 

-- 





[web2py] Re: session[id]=Storage(id=id) between controllers

2012-11-01 Thread Annet
Hi,

Thanks for providing me with a solution. 
 
>
> request.args(0,default=0, cast=int, otherwise=URL(...))
>

 

> PS: if it's recurrent I wonder why you aren't normalizing it already as 
> with
> try:
>   arg0 = int(request.args(0))
> except:
>   redirect()
>

Because there are exceptions, at the moment your solution solves the 
problem, in a next iteration I'll probably solve it differently.


Kind regards,

Annet. 

-- 





[web2py] zero='select a value' no longer shows

2012-11-01 Thread Annet
I defined the following validator:

nodeSocialMedia.nodeID.requires=[IS_IN_DB(db,'socialMedia.id','%(name)s',zero=T('select
 
a 
value')),IS_NOT_IN_DB(db(db.nodeSocialMedia.nodeID==request.vars.nodeID),'nodeSocialMedia.socialMediaID',error_message=T('combination
 
node and social media already in database'))]

In web2py 2.2.1 'select a value' no longer shows in the drop box, has 
anything changed?

Kind regards,

Annet.

-- 





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

2012-11-01 Thread Jim Steil
Lamps

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

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

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

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

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

-Jim

On Thu, Nov 1, 2012 at 11:35 AM, Lamps902  wrote:

> I've followed Jim's model in creating my search filter, and it appears to
> be working beautifully! Just have some questions that I would like to ask.
> First - I slightly modified the selector code so that entries show up as
> unique, by adding the "distinct" clause and ordering alphabetically by
> category, by doing the following:
>
>
> category_list = db().select(db.t_files.f_category, distinct=True,
> orderby=db.t_files.f_category)
> options = [OPTION(category_list[i].f_category,
>   _value=str(category_list[i].f_category)) for i inrange
> (len(category_list))]
>
> Will this become extremely inefficient and slow, and grind the system to a
> halt as the database become large?
>
> The second question concerns an important cosmetic change  - is there a
> good way to put the filter input fields (no labels) under the column
> headers/labels in the grid?
>
> Finally, if you wanted to redesign the filters to update after a certain
> number of characters have been modified in an input field (i.e. without
> having to click search), how would you go about doing that?
>
> Thanks again!
>
> -Lamps
>
> On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:
>
>> I'm attaching a quick-n-dirty search example.  You'll have to provide
>> your own data to get it running.  It worked with my test data.  Let me know
>> if you have troubles and I'll be glad to work through them with you.
>>
>> -Jim
>>
>>
>> On Wed, Oct 31, 2012 at 8:53 AM, Lamps902  wrote:
>>
>>> Hi, Jim. It would be great if you could provide more details and some
>>> code illustrating how you went about doing it. Thanks!
>>>
>>> -Lamps
>>>
>>>
>>> On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:

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

 -Jim

 On Wednesday, October 31, 2012 8:33:52 AM UTC-5, Lamps902 wrote:
>
> Hi, Johann - I know you can build a complex query using the search
> box, but that is far from intuitive for most users. I'd like to implement
> the same look/feel/usability as was available in webgrid, and as is shown
> in the image. Is there a reasonable way to do this? Thanks.
>
> -Lamps
>
> On Wednesday, October 31, 2012 2:40:05 AM UTC-4, Johann Spies wrote:
>>
>> You can do that by building a complex query using the search box.
>>
>> Regards
>> Johann
>>
>>
>> --
>> Because experiencing your loyal love is better than life itself,
>> my lips will praise you.  (Psalm 63:3)
>>
>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





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

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


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

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

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

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

Thanks again!

-Lamps

On Wednesday, October 31, 2012 7:56:27 PM UTC-4, Jim S wrote:
>
> I'm attaching a quick-n-dirty search example.  You'll have to provide your 
> own data to get it running.  It worked with my test data.  Let me know if 
> you have troubles and I'll be glad to work through them with you.
>
> -Jim
>
> On Wed, Oct 31, 2012 at 8:53 AM, Lamps902 
> > wrote:
>
>> Hi, Jim. It would be great if you could provide more details and some 
>> code illustrating how you went about doing it. Thanks!
>>
>> -Lamps
>>
>>
>> On Wednesday, October 31, 2012 9:39:24 AM UTC-4, Jim S wrote:
>>>
>>> Using .smartgrid, I override the default filtering capabilities and 
>>> provide my own.  See attached screenshot.  Let me know if you want more 
>>> details.  I think I uploaded a small example app to the list some time ago 
>>> and should be able to find it or recreate it if you like.
>>>
>>> -Jim
>>>
>>> On Wednesday, October 31, 2012 8:33:52 AM UTC-5, Lamps902 wrote:

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

 -Lamps

 On Wednesday, October 31, 2012 2:40:05 AM UTC-4, Johann Spies wrote:
>
> You can do that by building a complex query using the search box.
>
> Regards
> Johann
>
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: How to create long running tasks?

2012-11-01 Thread Niphlod


> > I don't get the "it's not applicable in this case" part. The way you 
> start them on web2py is the same one you can use with the scheduler 
>
> Does not seem applicable because does not address the problem of 
> dependent child processes. 
>
 
Let's not get lost: you have something to start and it dies when the 
webserver dies. For long-running processes (instead of the webserver's) , 
the recommended way is the scheduler (conceptually you don't have to stop 
it, and when you'll deploy your app on apache your external process won't 
get reapead automatically by apache itself). 
Saying that you not address the issue of dependent child processes is true, 
but the scheduler suggestion was made to you because conceptually you don't 
kill it (and as an outband process, it's not managed by the webserver, so 
it can live forever)
 

> > If you just need to launch them and never communicate with 
> > those again, did you try with 
> > import subprocess 
> > subprocess.Popen([whatever], stdout=subprocess.PIPE, 
> stderr=subprocess.PIPE, 
> > stdin=subprocess.PIPE) 
>
> Unfortunately this is still a child process so faces original problem. 
>

import os
import subprocess

print 'my pid is ', os.getpid()

other = subprocess.Popen(['/bin/ping','127.0.0.1'], 
stdout=subprocess.PIPE,stderr
=subprocess.PIPE, stdin=subprocess.PIPE)

print 'just spawned ', other.pid

What is your platform ?
on linux that works fine. 
For Windows things can get a little complicated.
output of the previous on linux
niphlod@li-mostro7:~/Scrivania$ python script.py 
my pid is  4921
just spawned  4922
niphlod@li-mostro7:~/Scrivania$ ps 4921
  PID TTY  STAT   TIME COMMAND
niphlod@li-mostro7:~/Scrivania$ ps 4922
  PID TTY  STAT   TIME COMMAND
 4922 pts/1S  0:00 /bin/ping 127.0.0.1

4921 ended, 4922 continues to live (if I don't kill it)
 

> Using a separate service like at command is a good idea, however I 
> need to know the process ID. 
>
 
What prevents you to code your external process to save its pid when 
started so you can fetch it from another process ?

-- 





[web2py] Re: Are there known problems of SQL Server with the built in wiki

2012-11-01 Thread Massimo Di Pierro
Not a solution but for 
reference: 
http://stackoverflow.com/questions/851625/foreign-key-constraint-may-cause-cycles-or-multiple-cascade-paths

On Thursday, 1 November 2012 09:39:47 UTC-5, Patrick Büchler wrote:
>
> Dear All,
>
> I plan to use web2py for an internal wiki. I wanted to use SQL Server as 
> database, however, when I try to run my application I get:
>
> pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server 
>> Driver][SQL Server]Introducing FOREIGN KEY constraint 
>> 'wiki_page_modified_by__constraint' on table 'wiki_page' may cause cycles$
>
>
> What should I do? I could switch to my sql but maybe someone knows a quick 
> solution whic allows me to keep sql server?
>
> Thanks for the efforts
>
> Patrick 
>

-- 





Re: [web2py] Re: Reading a text file after uploading in a form

2012-11-01 Thread Jim Steil
Whoops, sent that before completing:

Should have been...

Sorry, the reports module is my own. It is a directory under the modules
directory for that app. this is just my own special code. The important
thing to note is that you have to pass the directory name. The important
part is this:

'%s/%s' % (os.path.join(request.folder,'uploads'), fileName)

where I put the path and fileName together. Now you can reference that file
and do stuff with it. In my reports/brillToDalex method, It looks kinda
like this:

def process(inputFile, userId):
f = open(inputFile, 'r')
for line in f.readlines():




On Thu, Nov 1, 2012 at 9:45 AM, Jim Steil  wrote:

> Sorry, the reports module is my own.  It is a directory under the modules
> directory for that app.  this is just my own special code.  The important
> thing to note is that you have to pass the directory name.  The important
> part is this:
>
> '%s/%s' % (os.path.join(request.folder,'uploads'), fileName)
>
> where I put the path and fileName together.  Now you can reference that
> file and do stuff with it.  In my reports/brillToDalex method, I issue the
> following:
>
> def process(inputFile, userId):
>
> btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName),
> 1)
>
> On Thu, Nov 1, 2012 at 9:11 AM, Paolo Caruccio  > wrote:
>
>> a simple skeleton code (please check for errors):
>>
>> def page_controller():
>> form = FORM( TABLE (
>>  TR(
>> TD(LABEL('Upload File:')),
>> TD(INPUT(_type='file', name='myfile', id='myfile',
>> requires=IS_NOT_EMPTY()))
>>  ),
>> TR(
>> TD(INPUT(_type='submit',_value='Submit'))
>>  )
>> )
>> )
>>
>> txt_content[]
>>  if form.process().accepted:
>> txt_content = request.vars.myfile.file.readlines()
>> msg = process_file(txt_content)
>>  response.flash = T(msg)
>> elif form.errors:
>> response.flash = T('some errors occurred')
>>  else:
>> pass
>>
>> return dict(form=form)
>>
>> def process_file(txt_content):
>> all_lines = txt_content
>> msg = 'txt not processed'
>> for line in all_lines:
>>  try:
>> . your processing code .
>> msg = 'txt processed succesfully'
>>  except:
>> . your processing code .
>> msg = 'error processing txt'
>>  return msg
>>
>> Il giorno mercoledì 31 ottobre 2012 16:45:19 UTC+1, praveen krishna ha
>> scritto:
>>
>>> Hi,
>>>For my task I have to upload a text file in form with out zipping it
>>> ,I have prepared the form as:
>>> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file',
>>> name='myfile', id='myfile',
>>> requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')
>>>
>>> But I unable to read the file how could it be possible without using
>>> ZipFile.
>>>
>> --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: Reading a text file after uploading in a form

2012-11-01 Thread Jim Steil
Sorry, the reports module is my own.  It is a directory under the modules
directory for that app.  this is just my own special code.  The important
thing to note is that you have to pass the directory name.  The important
part is this:

'%s/%s' % (os.path.join(request.folder,'uploads'), fileName)

where I put the path and fileName together.  Now you can reference that
file and do stuff with it.  In my reports/brillToDalex method, I issue the
following:

def process(inputFile, userId):

btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName), 1)

On Thu, Nov 1, 2012 at 9:11 AM, Paolo Caruccio
wrote:

> a simple skeleton code (please check for errors):
>
> def page_controller():
> form = FORM( TABLE (
> TR(
> TD(LABEL('Upload File:')),
> TD(INPUT(_type='file', name='myfile', id='myfile',
> requires=IS_NOT_EMPTY()))
> ),
> TR(
> TD(INPUT(_type='submit',_value='Submit'))
> )
> )
> )
>
> txt_content[]
> if form.process().accepted:
> txt_content = request.vars.myfile.file.readlines()
> msg = process_file(txt_content)
> response.flash = T(msg)
> elif form.errors:
> response.flash = T('some errors occurred')
> else:
> pass
>
> return dict(form=form)
>
> def process_file(txt_content):
> all_lines = txt_content
> msg = 'txt not processed'
> for line in all_lines:
> try:
> . your processing code .
> msg = 'txt processed succesfully'
> except:
> . your processing code .
> msg = 'error processing txt'
> return msg
>
> Il giorno mercoledì 31 ottobre 2012 16:45:19 UTC+1, praveen krishna ha
> scritto:
>
>> Hi,
>>For my task I have to upload a text file in form with out zipping it
>> ,I have prepared the form as:
>> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file',
>> name='myfile', id='myfile',
>> requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')
>>
>> But I unable to read the file how could it be possible without using
>> ZipFile.
>>
> --
>
>
>
>

-- 





[web2py] Re: mail.send transposing "to" and "subject" ; can anybody explain this?

2012-11-01 Thread Gustavo Pereira
Guys I figured out how to solve this bug ...
in my version of web2py 1.99.2 changed in the file "db.py" line:
email = auth.settings.mailer

to:
mail = Mail ()

Em sexta-feira, 17 de agosto de 2012 18h25min44s UTC-3, Cliff Kachinske 
escreveu:
>
> The simple controller says this:
>
> record = get_email_record()
> approved_suppliers = get_approved_suppliers(record.products.id)
> mail.settings.server = 'logging'
> mail.settings.sender = 'fooba...@gmail.com '
> mail.settings.login = False
> mail.send(
> to =['jrand...@example.com '],
> subject='Requisition Number %s for %s' %(
> record.requisitions.id,
> record.products.name,
> ),
> message = build_message(record, approved_suppliers)
> )
>
>
>
> The email in the console as the "to" and "subject" fields transposed, like 
> this.
>
> WARNING:web2py:email not sent
> 
> From: foobar@gmail.com
> To: Requisition Number 5 for Product_0
> Subject: jrandomu...@example.com
>
> This is happening on 1.99.2.  I'm downloading a fresh zipball of 1.99.7 
> even as I type this, so I'm going to try the code on the latest stable.
>
> Still, this is strange.  Does anybody know what's going on?
>
> Thanks,
> Cliff Kachinske
>
>

-- 





[web2py] Are there known problems of SQL Server with the built in wiki

2012-11-01 Thread Patrick Büchler
Dear All,

I plan to use web2py for an internal wiki. I wanted to use SQL Server as 
database, however, when I try to run my application I get:

pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server 
> Driver][SQL Server]Introducing FOREIGN KEY constraint 
> 'wiki_page_modified_by__constraint' on table 'wiki_page' may cause cycles$


What should I do? I could switch to my sql but maybe someone knows a quick 
solution whic allows me to keep sql server?

Thanks for the efforts

Patrick 

-- 





Re: [web2py] Re: How to create long running tasks?

2012-11-01 Thread Richard Baron Penman
> I don't get the "it's not applicable in this case" part. The way you start 
> them on web2py is the same one you can use with the scheduler

Does not seem applicable because does not address the problem of
dependent child processes.


> Starting child processes from webserver main process is never safe because
> of the problem you're facing. The second you kill the webserver process (or,
> in more advanced webserver, when it realizes it's a process lasting too
> long) the child process is killed too (a webserver is "made" for responding
> quickly, so advanced ones try to free up "hanging" resources).

Exactly, so am trying to figure out how the process can be detached.


> However, this is not a problem on web2py per se, but on how python handles
> processes spawned. If you can't get a normal python script to launch a
> process that is not killed when the main python program is killed, then
> web2py can't really help with that.

I'm after a python solution, not web2py specific. Sorry should have
clarified that.
I thought someone else may have faced the same problem here.


> If you just need to launch them and never communicate with
> those again, did you try with
> import subprocess
> subprocess.Popen([whatever], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> stdin=subprocess.PIPE)

Unfortunately this is still a child process so faces original problem.

Using a separate service like at command is a good idea, however I
need to know the process ID.

-- 





[web2py] Re: Reading a text file after uploading in a form

2012-11-01 Thread Paolo Caruccio
a simple skeleton code (please check for errors):

def page_controller():
form = FORM( TABLE (
TR(
TD(LABEL('Upload File:')),
TD(INPUT(_type='file', name='myfile', id='myfile', requires=IS_NOT_EMPTY()))
),
TR(
TD(INPUT(_type='submit',_value='Submit'))
)
)
)

txt_content[]
if form.process().accepted:
txt_content = request.vars.myfile.file.readlines()
msg = process_file(txt_content)
response.flash = T(msg)
elif form.errors:
response.flash = T('some errors occurred')
else:
pass

return dict(form=form)

def process_file(txt_content):
all_lines = txt_content
msg = 'txt not processed'
for line in all_lines:
try:
. your processing code .
msg = 'txt processed succesfully'
except:
. your processing code .
msg = 'error processing txt'
return msg

Il giorno mercoledì 31 ottobre 2012 16:45:19 UTC+1, praveen krishna ha 
scritto:
>
> Hi,
>For my task I have to upload a text file in form with out zipping it ,I 
> have prepared the form as: 
> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file', name='myfile', 
> id='myfile', 
> requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')
>
> But I unable to read the file how could it be possible without using 
> ZipFile.
>

-- 





Re: [web2py] page min height

2012-11-01 Thread Richard Vézina
hmm, interresting...

I will have a look, thanks.

Richard

On Thu, Nov 1, 2012 at 8:31 AM, villas  wrote:

> Hi Richard,  I presume you already saw this?
>
> http://twitter.github.com/bootstrap/examples/sticky-footer.html
>
> --
>
>
>
>

-- 





[web2py] Re: How to create long running tasks?

2012-11-01 Thread Niphlod
I don't get the "it's not applicable in this case" part. The way you start 
them on web2py is the same one you can use with the scheduler

Starting child processes from webserver main process is never safe because 
of the problem you're facing. The second you kill the webserver process 
(or, in more advanced webserver, when it realizes it's a process lasting 
too long) the child process is killed too (a webserver is "made" for 
responding quickly, so advanced ones try to free up "hanging" resources). 
However, this is not a problem on web2py per se, but on how python handles 
processes spawned. If you can't get a normal python script to launch a 
process that is not killed when the main python program is killed, then 
web2py can't really help with that.

Two tricks: instead of launching processes directly, you can use *start*program 
on Windows or the 
*at* program on Linux. Then the process is child of start or at, not your 
app, and it shouldn't be killed.

Another trick: If you just need to launch them and never communicate with 
those again, did you try with
import subprocess
subprocess.Popen([whatever], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, stdin=subprocess.PIPE)

?

On Thursday, November 1, 2012 1:50:16 PM UTC+1, Richard Penman wrote:
>
> Would be great to use the new scheduler but doesn't seem applicable in 
> this case. I have no difficulty starting these processes.
>
> As described in OP, the problem is these are child processes which makes 
> them dependent on the main web2py process. So I was wanting these to 
> be independent processes - or is there a better way?
>
>
>
> On Thursday, November 1, 2012 3:45:28 PM UTC+11, Massimo Di Pierro wrote:
>>
>> Please use the scheduler.
>>
>> On Wednesday, 31 October 2012 21:56:47 UTC-5, Richard Penman wrote:
>>>
>>> Hello,
>>>
>>> I create a new process after each form submission to parse some data:
>>> subprocess.Popen(['python', parser_script], 
>>> cwd=os.path.dirname(parser_script))
>>> (The parser_script is independent of web2py)
>>>
>>> This parsing can take days and multiple parsers need to be executed at 
>>> once.
>>> However if the web2py process is ended these child processes are also 
>>> killed. 
>>> How can I run these as independent orphan processes?
>>>
>>> A Linux only solution is fine or cross platform if practical.
>>>
>>> Richard
>>>
>>

-- 





[web2py] Re: How to create long running tasks?

2012-11-01 Thread Richard Penman
Would be great to use the new scheduler but doesn't seem applicable in this 
case. I have no difficulty starting these processes.

As described in OP, the problem is these are child processes which makes 
them dependent on the main web2py process. So I was wanting these to 
be independent processes - or is there a better way?



On Thursday, November 1, 2012 3:45:28 PM UTC+11, Massimo Di Pierro wrote:
>
> Please use the scheduler.
>
> On Wednesday, 31 October 2012 21:56:47 UTC-5, Richard Penman wrote:
>>
>> Hello,
>>
>> I create a new process after each form submission to parse some data:
>> subprocess.Popen(['python', parser_script], 
>> cwd=os.path.dirname(parser_script))
>> (The parser_script is independent of web2py)
>>
>> This parsing can take days and multiple parsers need to be executed at 
>> once.
>> However if the web2py process is ended these child processes are also 
>> killed. 
>> How can I run these as independent orphan processes?
>>
>> A Linux only solution is fine or cross platform if practical.
>>
>> Richard
>>
>

-- 





[web2py] Re: long load time for scipy package

2012-11-01 Thread Massimo Di Pierro
Unless you enabled track_changes(True) this should not be the case. The 
package should only be loaded once. Where did you put the package?

On Thursday, 1 November 2012 06:32:28 UTC-5, lucas wrote:
>
> hello one and all,
>
> i am trying to load the scipy package into one of my apps under web2py 
> 2.2.1 on centos 6.3.  when i load it, like via "from scipy import 
> optimize", under pure python command line, it loads very quickly.  however, 
> when i try to load it under a web2py controller it takes a huge amount of 
> time.  web2py seems to need to load a new instance with each session 
> because when a new user tries to access the site, it takes that long again, 
> even after web2py has been running and the library is loaded.  most times 
> something times out before it is loaded and the whole thing comes crashing 
> down.  however, once it is loaded it all runs very smooth and very fast, 
> even the scipy functionality.
>
> any suggestions to make scipy load much quicker under web2py?
>
> thanx in advance, lucas
>

-- 





Re: [web2py] Reading a text file after uploading in a form

2012-11-01 Thread praveen krishna
where can I download the 'reports' module? I am getting error while calling
that module.

On Thu, Nov 1, 2012 at 1:12 PM, Jim S  wrote:

> This is working for me. I have a similar requirement. Select a text file
> to be processed and pass it to a separate routine to process the file:
>
>  form = SQLFORM.factory(
>  Field('brillXf1', 'upload',
>  uploadfolder=os.path.join(request.folder,'uploads'),
>  label='Brill XF1 File'))
>
>  if form.process().accepted:
>  fileName = form.vars.brillXf1
>  print fileName
>  from reports import brillToDalex as btd
>  btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName),
> 1)
>  redirect(URL('nutrientConversion'))
>  response.flash('File has been uploaded and email will be sent with
> results')
>
>
> The form field only returns the file name.  You have to specify the path
> to it if you are going to use it later as seen in this statement:
>
> btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName),
> 1)
>
> -Jim
>
>
> On Thursday, November 1, 2012 3:33:50 AM UTC-5, praveen krishna wrote:
>
>> Nol there is no such requirement.Actually I am able to upload and read a
>> text file by zipping it but for my task I have upload a text file .
>>
>> On Thu, Nov 1, 2012 at 7:24 AM, Johann Spies  wrote:
>>
>> On 31 October 2012 17:45, praveen krishna  wrote:
>>>
 Hi,
For my task I have to upload a text file in form with out zipping it
 ,I have prepared the form as:
 form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file',
 name='myfile', id='myfile',
 requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')

 But I unable to read the file how could it be possible without using
 ZipFile.

>>>
>>> You refer to 'zip'  twice.  Why?  Is there a requirement that it should
>>> be zipped somewhere?
>>>
>>> Regards
>>> Johann
>>> --
>>> Because experiencing your loyal love is better than life itself,
>>> my lips will praise you.  (Psalm 63:3)
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] page min height

2012-11-01 Thread villas
Hi Richard,  I presume you already saw this?

http://twitter.github.com/bootstrap/examples/sticky-footer.html

-- 





[web2py] Re: Unescaped single quotes break my json

2012-11-01 Thread villas
Hi dlypka,

Not sure I was clear.  I need to maintain the escaping.

My point was this:  my data was escaped OK in the controller,  but when it 
arrived in the view,  it was not escaped.
Something broke the escaping of single-quotes passing between the two.  
Double quotes are a bit of problem too.

We can work around the problem, but I thought there may be a proper 
solution.

Best regards,
D


On Thursday, November 1, 2012 12:05:44 PM UTC, dlypka wrote:
>
> I used this code in my controller:
> result = '{ "IsLoggedIn": "%s", "resmsg": "%s"}' % (retIsLoggedIn, resmsg) 
>   
> response.headers['Content-Type'] = 'application/jsonp'
> response.view = 'generic.jsonp' # Using python code in file 
> init/views/generic.jsonp to leave data unescaped
> return result
>
> On Wednesday, October 31, 2012 7:06:06 PM UTC-5, villas wrote:
>>
>> I have a problem with escaping single quotes when I need a JS list in my 
>> view.  I have a workaround below,  but is there a better way?  
>>
>> In controller:
>> lst = ["Andy's Barber Shop"]
>> jsonlst = json.dumps(lst)
>> '["Andy\'s Barber Shop"]'
>>
>> In view:
>> {{=XML(jsonlst)}}
>> '["Andy's Barber Shop"]'   --- Broken
>>
>> My Workaround:
>> {{=XML(jsonlst.replace("'", "\\'")}}
>> '["Andy\'s Barber Shop"]'   --- Works OK
>>
>>
>>

-- 





Re: [web2py] Reading a text file after uploading in a form

2012-11-01 Thread Jim S
This is working for me. I have a similar requirement. Select a text file to 
be processed and pass it to a separate routine to process the file:

 form = SQLFORM.factory(
 Field('brillXf1', 'upload', 
 uploadfolder=os.path.join(request.folder,'uploads'),
 label='Brill XF1 File'))

 if form.process().accepted:
 fileName = form.vars.brillXf1
 print fileName
 from reports import brillToDalex as btd
 btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName), 1
)
 redirect(URL('nutrientConversion'))
 response.flash('File has been uploaded and email will be sent with results'
)


The form field only returns the file name.  You have to specify the path to 
it if you are going to use it later as seen in this statement:

btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName), 1)

-Jim


On Thursday, November 1, 2012 3:33:50 AM UTC-5, praveen krishna wrote:
>
> Nol there is no such requirement.Actually I am able to upload and read a 
> text file by zipping it but for my task I have upload a text file .
>
> On Thu, Nov 1, 2012 at 7:24 AM, Johann Spies 
> > wrote:
>
>> On 31 October 2012 17:45, praveen krishna 
>> > wrote:
>>
>>> Hi,
>>>For my task I have to upload a text file in form with out zipping it 
>>> ,I have prepared the form as: 
>>> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file', 
>>> name='myfile', id='myfile', 
>>> requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')
>>>
>>> But I unable to read the file how could it be possible without using 
>>> ZipFile.
>>>
>>
>> You refer to 'zip'  twice.  Why?  Is there a requirement that it should 
>> be zipped somewhere?
>>
>> Regards
>> Johann
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: Unescaped single quotes break my json

2012-11-01 Thread dlypka
I used this code in my controller:
result = '{ "IsLoggedIn": "%s", "resmsg": "%s"}' % (retIsLoggedIn, resmsg) 
  
response.headers['Content-Type'] = 'application/jsonp'
response.view = 'generic.jsonp' # Using python code in file 
init/views/generic.jsonp to leave data unescaped
return result

On Wednesday, October 31, 2012 7:06:06 PM UTC-5, villas wrote:
>
> I have a problem with escaping single quotes when I need a JS list in my 
> view.  I have a workaround below,  but is there a better way?  
>
> In controller:
> lst = ["Andy's Barber Shop"]
> jsonlst = json.dumps(lst)
> '["Andy\'s Barber Shop"]'
>
> In view:
> {{=XML(jsonlst)}}
> '["Andy's Barber Shop"]'   --- Broken
>
> My Workaround:
> {{=XML(jsonlst.replace("'", "\\'")}}
> '["Andy\'s Barber Shop"]'   --- Works OK
>
>
>

-- 





[web2py] long load time for scipy package

2012-11-01 Thread lucas
hello one and all,

i am trying to load the scipy package into one of my apps under web2py 
2.2.1 on centos 6.3.  when i load it, like via "from scipy import 
optimize", under pure python command line, it loads very quickly.  however, 
when i try to load it under a web2py controller it takes a huge amount of 
time.  web2py seems to need to load a new instance with each session 
because when a new user tries to access the site, it takes that long again, 
even after web2py has been running and the library is loaded.  most times 
something times out before it is loaded and the whole thing comes crashing 
down.  however, once it is loaded it all runs very smooth and very fast, 
even the scipy functionality.

any suggestions to make scipy load much quicker under web2py?

thanx in advance, lucas

-- 





Re: [web2py] Reading a text file after uploading in a form

2012-11-01 Thread praveen krishna
Nol there is no such requirement.Actually I am able to upload and read a
text file by zipping it but for my task I have upload a text file .

On Thu, Nov 1, 2012 at 7:24 AM, Johann Spies  wrote:

> On 31 October 2012 17:45, praveen krishna wrote:
>
>> Hi,
>>For my task I have to upload a text file in form with out zipping it
>> ,I have prepared the form as:
>> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file',
>> name='myfile', id='myfile',
>> requires=IS_NOT_EMPTY(,TR(TD(INPUT(_type='submit',_value='Submit')
>>
>> But I unable to read the file how could it be possible without using
>> ZipFile.
>>
>
> You refer to 'zip'  twice.  Why?  Is there a requirement that it should be
> zipped somewhere?
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>  --
>
>
>
>

--