[web2py] validator for valid SQL table name

2012-02-03 Thread Manuele Pesenti

Hi!
Can you suggest me how can I write a validator for sql table names?

I mean... I have a plugin that let me define tables and fields through 
the web interface saving their name and parameters in the db itself. So 
I have a meta table for the tables I want to define. I'm looking for a 
good validator for the meta field that contains table names.


They have to be unique and respect all SQL conventions. At the moment I 
solved in this way:


Field('tab_name', label=T('Table name'), unique=True, required=True,
requires=IS_MATCH('^[a-z0-9_]*$', error_message=T('Not 
a valid table name!')))


Thank you very mutch

Manuele


[web2py] disable a/a when not logged in.

2012-02-03 Thread Annet
I am working on the cms part of an app. In the view I have a/a
elements:

div id=addressbook class=ez-box admin
  a href={{=URL('addressbook','admin')}}
img src={{=URL('static','init/images/icons/ABIcon.png')}}
alt=some_text width=78px height=78px/
h4Adresboek/h4
p class=fs12Uw adresboek card beheren./p
  /a
/div !-- ez-box --

When the user isn't logged in I want the a/a elements to be
disabled, i.e not click able and set their opacity to .50

This is what I tried:

{{if not auth.is_logged_in():}}
  script type=text/javascript
$(document).ready(function(){
  $('#addressbook a').attr('disabled','');
  $('#calendar a').attr('disabled','');
  $('#hub a').attr('disabled','');
});
  /script
  style type=text/css
.admin {opacity: 0.5; filter:Alpha(opacity=50);}
  /style
{{pass}}

The opacity bit works, the jQuery bit doesn't work, I hope one of you
could provide me with the correct code to make this work.


Kind regards,

Annet


Re: [web2py] Re: Minify (compress) response HTML

2012-02-03 Thread Michele Comitini
Massimo,

About gzipping.  It is not true that the webserver does the gzipping
at least not every combination of frontend/backend.

1) Rocket does gzipping?
2) Apache + wsgi does gzipping?
3) server + fcgi does gzipping?

What I know for sure is server + SCGI does gzipping:  I wrote it so
that uses wsgitools wsgi gzip application.
I also think UWSGI does the gzip.

The server usually gzips only static files.  Anyway I think that
gzipping can be implemented in python with little overhead since it
uses the underlying C implementation.

mic

2012/2/3 Massimo Di Pierro massimo.dipie...@gmail.com:
 OK, let's add a minifier in contrib.

 On Feb 2, 8:16 pm, Kernc kernc...@gmail.com wrote:
 Sorry for late reply, didn't get any notification by email due to my
 list preferences. It could send me a follow-up on the thread I
 posted... Oh, well...

 Minification before gzipping still does make a difference:
 this is my index.html:

 $ wc -c minified.html
 4827 minified.html
 $ wc -c nonminified.html
 74910 nonminified.html
 $ gzip minified.html  wc -c minified.html.gz
 2134 minified.html.gz
 $ gzip nonminified.html  wc -c nonminified.html.gz
 8247 nonminified.html.gz

 Nearly 4-fold difference of minifiedgzipped over non-
 minifiedgzipped. Not to mention minified HTML is faster and easier
 for a browser to parse. And the minified-rendered views take up less
 RAM when cache.ram'd (which is what one should do on nearly all
 pages)

 I would like the feature for its obfuscating nature. It hides the
 implementation more, what is a loop, what is static html, how deep an
 indentation goes...

 It must be worth something, Google does it 
 (view-source:https://www.google.com/).

 The implementation quoted in comment #2 (http://code.google.com/p/
 web2py/issues/detail?id=369#c2) solves the issue quite well for me. I
 haven't found any new bugs. It even minifies inline JS. It works. :-)
 I renounce all rights to this code, which likely belong more to the
 original inventor of 
 this:http://packages.python.org/web2py_utils/output.html#compress-output
 (As far as I am concerned, you can just use it.)

 I agree a separate htmlminify module is an acceptable solution. :-)


Re: [web2py] validator for valid SQL table name

2012-02-03 Thread Bruno Rocha
look the code in dal.py referencing check_reserved, you can copy patterns
and dicts from there in to your validator.

http://zerp.ly/rochacbruno
Em 03/02/2012 06:41, Manuele Pesenti manuele.pese...@gmail.com escreveu:

 Hi!
 Can you suggest me how can I write a validator for sql table names?

 I mean... I have a plugin that let me define tables and fields through the
 web interface saving their name and parameters in the db itself. So I have
 a meta table for the tables I want to define. I'm looking for a good
 validator for the meta field that contains table names.

 They have to be unique and respect all SQL conventions. At the moment I
 solved in this way:

 Field('tab_name', label=T('Table name'), unique=True, required=True,
requires=IS_MATCH('^[a-z0-9_]***$', error_message=T('Not a
 valid table name!')))

 Thank you very mutch

Manuele



Re: [web2py] validator for valid SQL table name

2012-02-03 Thread Manuele Pesenti

Il 03/02/2012 11:03, Bruno Rocha ha scritto:
look the code in dal.py referencing check_reserved, you can copy 
patterns and dicts from there in to your validator.


Hi Bruno,
thanks for the replay... I've already tryed to look inside dal.py but it 
was not so clear how to translate it's behaviour in a validator... if no 
other suggestion will come I'll try again :)


regards

Manuele



Re: [web2py] Re: Debugging in web2py

2012-02-03 Thread Mariano Reingart
Also, look at this new integrated online debugger for web2py:

http://reingart.blogspot.com/2012/02/new-web2py-online-python-debugger.html

I've finished it recently, so let me know if you try it and have any issue.

if you are using apache (prefork, and to a lesser extent mpm worker) you
would have to adapt the configuration or use modwsgi in daemon mode:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Browser_Based_Debugger

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Thu, Feb 2, 2012 at 9:06 PM, pbreit pbreitenb...@gmail.com wrote:

 Logging is helpful.

 https://groups.google.com/d/msg/web2py/CI5JGc8yZw8/K3v9nSWi2dYJ



[web2py] Book v4.0 translate to spanish

2012-02-03 Thread Martín Mulone
I want to start the translation to spanish of the book, 4th edition.
 What's are the way to be syncronize with english version?. Any help?.


[web2py] Re: Too many redirects when trying to use interactive demo

2012-02-03 Thread Wikus van de Merwe
The problem seems to be a redirection loop between this two addresses:
1) http://web2py.com/demo_admin/default/site 
2) 
http://web2py.com/demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite

Both return 303 and redirect 1 - 2, and 2 - 1 until the browser gives up 
with a message:
Firefox has detected that the server is redirecting the request for this 
address in a way that will never complete.
See attached headers log for details.
http://web2py.com/demo_admin

GET /demo_admin HTTP/1.1
Host: web2py.com
User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 
Firefox/9.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.7,pl;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: UTF-8,*
DNT: 1
Proxy-Connection: keep-alive
Cookie: __utma_a2a=1688569230.1329956564.1298399638.1298400133.1298400137.10; 
session_id_books=123.123.123.123-411d0ab0-e05f-402d-aad5-32a0fc3c745d; 
session_id_poweredby=123.123.123.123-6f3c9acc-0ebf-4fe1-aaff-e1e3244f7364; 
session_id_pdfbuy=123.123.123.123-d28a483d-e1a5-4978-86bc-032867d3846b

HTTP/1.0 303 See Other
Date: Fri, 03 Feb 2012 13:39:05 GMT
Server: Apache/2.2.8 (Ubuntu) mod_wsgi/3.2-BRANCH Python/2.5.2 mod_ssl/2.2.8 
OpenSSL/0.9.8g
Set-Cookie: 
session_id_demo_admin=123.123.123.123-9e14f731-c4c8-4cd8-856f-c1c8fc08b313; 
Path=/; secure
Location: /demo_admin/default/site
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from proxy.example.com
X-Cache-Lookup: MISS from proxy.example.com:3128
Via: 1.0 proxy.example.com:3128 (squid/2.6.STABLE6)
Proxy-Connection: close
--
http://web2py.com/demo_admin/default/site

GET /demo_admin/default/site HTTP/1.1
Host: web2py.com
User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 
Firefox/9.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.7,pl;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: UTF-8,*
DNT: 1
Proxy-Connection: keep-alive
Cookie: __utma_a2a=1688569230.1329956564.1298399638.1298400133.1298400137.10; 
session_id_books=123.123.123.123-411d0ab0-e05f-402d-aad5-32a0fc3c745d; 
session_id_poweredby=123.123.123.123-6f3c9acc-0ebf-4fe1-aaff-e1e3244f7364; 
session_id_pdfbuy=123.123.123.123-d28a483d-e1a5-4978-86bc-032867d3846b

HTTP/1.0 303 See Other
Date: Fri, 03 Feb 2012 13:39:06 GMT
Server: Apache/2.2.8 (Ubuntu) mod_wsgi/3.2-BRANCH Python/2.5.2 mod_ssl/2.2.8 
OpenSSL/0.9.8g
Set-Cookie: 
session_id_demo_admin=123.123.123.123-21eeb408-fd78-48f0-90d1-2a3039698189; 
Path=/; secure
Location: /demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite
Content-Length: 105
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from proxy.example.com
X-Cache-Lookup: MISS from proxy.example.com:3128
Via: 1.0 proxy.example.com:3128 (squid/2.6.STABLE6)
Proxy-Connection: keep-alive
--
http://web2py.com/demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite

GET /demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite HTTP/1.1
Host: web2py.com
User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 
Firefox/9.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.7,pl;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: UTF-8,*
DNT: 1
Proxy-Connection: keep-alive
Cookie: __utma_a2a=1688569230.1329956564.1298399638.1298400133.1298400137.10; 
session_id_books=123.123.123.123-411d0ab0-e05f-402d-aad5-32a0fc3c745d; 
session_id_poweredby=123.123.123.123-6f3c9acc-0ebf-4fe1-aaff-e1e3244f7364; 
session_id_pdfbuy=123.123.123.123-d28a483d-e1a5-4978-86bc-032867d3846b

HTTP/1.0 303 See Other
Date: Fri, 03 Feb 2012 13:39:06 GMT
Server: Apache/2.2.8 (Ubuntu) mod_wsgi/3.2-BRANCH Python/2.5.2 mod_ssl/2.2.8 
OpenSSL/0.9.8g
Set-Cookie: 
session_id_demo_admin=123.123.123.123-5c8046bd-8d1b-49cb-bef8-2ec581ddd334; 
Path=/; secure
Location: /demo_admin/default/site
Content-Length: 68
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from proxy.example.com
X-Cache-Lookup: MISS from proxy.example.com:3128
Via: 1.0 proxy.example.com:3128 (squid/2.6.STABLE6)
Proxy-Connection: keep-alive
--
http://web2py.com/demo_admin/default/site

GET /demo_admin/default/site HTTP/1.1
Host: web2py.com
User-Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 
Firefox/9.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.7,pl;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: UTF-8,*
DNT: 1
Proxy-Connection: keep-alive
Cookie: __utma_a2a=1688569230.1329956564.1298399638.1298400133.1298400137.10; 
session_id_books=123.123.123.123-411d0ab0-e05f-402d-aad5-32a0fc3c745d; 
session_id_poweredby=123.123.123.123-6f3c9acc-0ebf-4fe1-aaff-e1e3244f7364; 

[web2py] Re: disable a/a when not logged in.

2012-02-03 Thread Anthony
I don't think the disabled attribute works with anchor tags (except in 
IE) (it works with buttons, but in that case, it's supposed to be 
disabled=disabled). Instead, you could remove the href, add an 
onclick=return false; attribute, or do something like:

$('#addressbook a').click(function(e) {e.preventDefault();});

Anthony


On Friday, February 3, 2012 3:57:54 AM UTC-5, Annet wrote:

 I am working on the cms part of an app. In the view I have a/a 
 elements: 

 div id=addressbook class=ez-box admin 
   a href={{=URL('addressbook','admin')}} 
 img src={{=URL('static','init/images/icons/ABIcon.png')}} 
 alt=some_text width=78px height=78px/ 
 h4Adresboek/h4 
 p class=fs12Uw adresboek card beheren./p 
   /a 
 /div !-- ez-box -- 

 When the user isn't logged in I want the a/a elements to be 
 disabled, i.e not click able and set their opacity to .50 

 This is what I tried: 

 {{if not auth.is_logged_in():}} 
   script type=text/javascript 
 $(document).ready(function(){ 
   $('#addressbook a').attr('disabled',''); 
   $('#calendar a').attr('disabled',''); 
   $('#hub a').attr('disabled',''); 
 }); 
   /script 
   style type=text/css 
 .admin {opacity: 0.5; filter:Alpha(opacity=50);} 
   /style 
 {{pass}} 

 The opacity bit works, the jQuery bit doesn't work, I hope one of you 
 could provide me with the correct code to make this work. 


 Kind regards, 

 Annet



Re: [web2py] Any bored developers want to help?

2012-02-03 Thread Sebastian E. Ovide
nice !

On Thu, Feb 2, 2012 at 1:15 PM, Bruce Wade bruce.w...@gmail.com wrote:

 No, used cakephp for ethicaldeal, and used pyramid for youadworld, however
 for the last month I have been porting youadworld.com to web2py and the
 new version is much much much better then the current live one. I will
 update the development version of the site later today and provide a link
 to see the new youadworld.com (not complete yet, but getting close)


 On Thu, Feb 2, 2012 at 1:19 AM, Sebastian E. Ovide 
 sebastian.ov...@gmail.com wrote:

 did you use web2py for ethicaldeal.com and youadworld.com  ?


 On Thu, Feb 2, 2012 at 3:32 AM, Bruce Wade bruce.w...@gmail.com wrote:

 Hi,

 I am currently using web2py to build a fitness portal, that allows
 members to:

1. track their food consumption
2. calculate the calories/fat/protein etc..,
3. build and track their workout programs
4. track fitness progress IE: Weight changes, muscle gained etc...
5. trainers can track their clients, find new clients
6. companies can track their trainers, find new trainers, and track
their clients or find new clients.


 Currently their are 2 designers and 2 developers on the team (including
 myself).

 This is a challenging project and I am willing to payout a good % to any
 developers who become core developers of the application.

 A little about me:
 I have developed the very successful ethicaldeal.com group-on clone
 website. (Making over $800 a day in revenue)
 Developed the so far very successful youadworld.com advertising
 website. (Very successful means, it launched November 18th, 2011 and has
 already generated over $5 million in revenue)

 Unfortunately I am not the owner of either of these two projects, so I
 don't get to benefit all that much from their success even though I spent
 lots of sleepless nights on the development :(. However I have learned a
 lot from working on these and other projects and want to now make one I own
 that is very successful.

 Anyway enough of the rant if anyone is interested in potentially wasting
 a lot of their time to help build something that will benefit a lot of
 people let me know.

 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.warplydesigned.com
 http://www.fitnessfriendsfinder.com




 --
 Sebastian E. Ovide






 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.warplydesigned.com
 http://www.fitnessfriendsfinder.com




-- 
Sebastian E. Ovide


[web2py] web2py long term projects: experiences ?

2012-02-03 Thread Sebastian E. Ovide
Hi All,

just wondering... do you know any blog/page with some long term (at least 2
years) web2py projects experiences ?

It could be interesting to see how those projects have done so far in terms
of testing (unit/integration), scaling, upgrades (web2py upgrade),
refactoring etc

thanks

-- 
Sebastian E. Ovide


Re: [web2py] web2py long term projects: experiences ?

2012-02-03 Thread Bruce Wade
I am also interested in knowing this.

On Fri, Feb 3, 2012 at 6:14 AM, Sebastian E. Ovide 
sebastian.ov...@gmail.com wrote:

 Hi All,

 just wondering... do you know any blog/page with some long term (at least
 2 years) web2py projects experiences ?

 It could be interesting to see how those projects have done so far in
 terms of testing (unit/integration), scaling, upgrades (web2py upgrade),
 refactoring etc

 thanks

 --
 Sebastian E. Ovide






-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] URL parsing problems (request.args)

2012-02-03 Thread VP
We have got inconsistent behaviors of web2py on 2 different servers
(same latest version 1.99.4).

Give this URL, app/controller/function/13/1///

On my personal computer, request.args is [13,1,'',''].   This is what
I expected.

On my server, request.args is [13,1].

This messes up my controller logic.   What causes this?

Thanks
VP


[web2py] processing upload field.

2012-02-03 Thread VP
I have the following situation.

There is a field A of type upload (image).

There is another field B of type compute, which depends on A.

I want to be able to process the image uploaded in field A and save
it, but before the compute in field B is executed.  In other words,
field B will be computed after the image in field A is processed.

What is the best way to do this?

Thanks.


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
Furthermore, on the server, this URL app/controller/function/13/1//5/
results in request.args to be ['13','1','5'], which is seriously
wrong.  The right answer of course should be ['13','1','','5'].

Can someone help?

Thanks.


On Feb 3, 8:55 am, VP vtp2...@gmail.com wrote:
 We have got inconsistent behaviors of web2py on 2 different servers
 (same latest version 1.99.4).

 Give this URL, app/controller/function/13/1///

 On my personal computer, request.args is [13,1,'',''].   This is what
 I expected.

 On my server, request.args is [13,1].

 This messes up my controller logic.   What causes this?

 Thanks
 VP


Re: [web2py] URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 6:55 AM, VP wrote:

 We have got inconsistent behaviors of web2py on 2 different servers
 (same latest version 1.99.4).
 
 Give this URL, app/controller/function/13/1///
 
 On my personal computer, request.args is [13,1,'',''].   This is what
 I expected.
 
 On my server, request.args is [13,1].
 
 This messes up my controller logic.   What causes this?

Is it possible that you're invoking different routers on the two systems? Or 
enabling routes on one and not the other?

[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP

 Is it possible that you're invoking different routers on the two systems? Or 
 enabling routes on one and not the other?

Jonathan,

One configuration difference between  the server and the personal
computer is that  on the server, I use routes.py, which routes www.mysite.com
and mysite.com to the appropriate app.

Could this be the problem?  If so, how to fix it?

Thanks,

VP


Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 7:20 AM, VP wrote:

 Is it possible that you're invoking different routers on the two systems? Or 
 enabling routes on one and not the other?
 
 Jonathan,
 
 One configuration difference between  the server and the personal
 computer is that  on the server, I use routes.py, which routes www.mysite.com
 and mysite.com to the appropriate app.
 
 Could this be the problem?  If so, how to fix it?

Please post (or send me privately) your routes.py.

[web2py] Re: Form in component submits (blank) when component first loads

2012-02-03 Thread monotasker
I suppose I could! But I'd like to understand the underlying issue -- why 
the form seems to submit blank when the component loads (hence the else 
condition firing).


[web2py] Is the undocumented ListWidget in sqlhtml safe?

2012-02-03 Thread monotasker
I'm continuing to work in fits and starts on my ajaxselect plugin (I'll 
post an update and bugfix soon, hopefully with a proper demo). In the 
process, I came across the ListWidget method in sqlhtml. It's quite a nice 
way to implement multi-reference field. But it's not documented in the 4th 
edition book. Is there some problem with using it? Is it unfinished? Will 
it be dropped? Or could I use it safely in my plugin?

Ian


[web2py] Re: Form in component submits (blank) when component first loads

2012-02-03 Thread Anthony
The form isn't submitting anything when it is first loaded. In post(), the 
form is created and then processed (via form.process()). When the page is 
first loaded (i.e., no form submission), form.process(...).accepted is 
false (since no data have been posted), which is why it reaches the else 
logic. web2py uses self-submitting forms -- the same action handles form 
creation and form submission. The fact that the post() action is called 
does not mean the form has been submitted -- it is also called for the 
initial form creation as well.

Anthony

On Friday, February 3, 2012 10:30:32 AM UTC-5, monotasker wrote:

 I suppose I could! But I'd like to understand the underlying issue -- why 
 the form seems to submit blank when the component loads (hence the else 
 condition firing).



[web2py] Re: Is the undocumented ListWidget in sqlhtml safe?

2012-02-03 Thread Anthony
It is actually exposed via SQLFORM.widgets.list.widget, and it is used 
automatically in SQLFORMs for list:type fields, so I assume it is safe to 
use and here to stay.

Anthony

On Friday, February 3, 2012 10:35:42 AM UTC-5, monotasker wrote:

 I'm continuing to work in fits and starts on my ajaxselect plugin (I'll 
 post an update and bugfix soon, hopefully with a proper demo). In the 
 process, I came across the ListWidget method in sqlhtml. It's quite a nice 
 way to implement multi-reference field. But it's not documented in the 4th 
 edition book. Is there some problem with using it? Is it unfinished? Will 
 it be dropped? Or could I use it safely in my plugin?

 Ian



[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
Thanks. I just emailed you my routes.py.

But routes.py might not be the cause, because I have just removed it
(without using routes.py), the problem still existed.



On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:20 AM, VP wrote:

  Is it possible that you're invoking different routers on the two systems? 
  Or enabling routes on one and not the other?

  Jonathan,

  One configuration difference between  the server and the personal
  computer is that  on the server, I use routes.py, which routeswww.mysite.com
  and mysite.com to the appropriate app.

  Could this be the problem?  If so, how to fix it?

 Please post (or send me privately) your routes.py.


Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 7:46 AM, VP wrote:

 Thanks. I just emailed you my routes.py.
 
 But routes.py might not be the cause, because I have just removed it
 (without using routes.py), the problem still existed.

Did you restart web2py? Until you do, it won't recognize the change.

I added unit tests for the kind of thing you're seeing to both router tests 
(pattern  parametric) and they seem to be working OK.

There was a (possibly minor) problem with your routes.py. I suggest that you 
fix it, using router.example.py as the basis, update the routes.py doctest to 
work with your changes, and then add a doctest for the failing conditions.

(FWIW, I'm doing my testing in the trunk, but I don't think there's a relevant 
change from 1.99.4.)

 
 
 
 On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:20 AM, VP wrote:
 
 Is it possible that you're invoking different routers on the two systems? 
 Or enabling routes on one and not the other?
 
 Jonathan,
 
 One configuration difference between  the server and the personal
 computer is that  on the server, I use routes.py, which routeswww.mysite.com
 and mysite.com to the appropriate app.
 
 Could this be the problem?  If so, how to fix it?
 
 Please post (or send me privately) your routes.py.




[web2py] Re: Cannot get janrain to work

2012-02-03 Thread jc


 Glad it's working! I've been having the same exact problem you described, but
 this fix didn't work for me. What are you using as your token URL?
 This concept is foggy to me. It's not mentioned in the web2py book, but is
 described on 
 thejanrainsitehttps://rpxnow.com/relying_parties/resource-pool/setup_tokenurl#steps

For me the private/janrain.key file contains a9test:... (no
quotes). The a9test is my janrain domain i.e. on their dashboard it
lists my Application Domain as https://a9test.rpxnow.com/. The 'x's
are the janrain API Key (Secret).

The janrain Application Settings page has localhost listed under
Domain Whitelist.

The url I try to visit is http://localhost:8000/test/default/index.
The test/default/index function has the @auth.requires_login() set.


[web2py] Re: Is the undocumented ListWidget in sqlhtml safe?

2012-02-03 Thread monotasker
That's good news. I'm a bit confused, though, since it doesn't seem to be 
the default widget for list:reference fields, which are presented by 
default in a multiple select widget (or does list:reference not fall under 
list:type?).

Also, the list widget isn't included in the list of available widgets on 
pp. 372-373 of the 4th edition book. So maybe that Massimo could update 
that section to include it.


[web2py] login next doesn't work Version 1.99.4 (2011-12-14 14:46:14) stable

2012-02-03 Thread Tito Garrido
Hi Folks,

I'm using login with ldap and login_next doesn't work...

from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods=[ldap_auth(mode='company',server='mycompany',base_dn='ou=myou,o=
mycompany.com')]
auth.settings.actions_disabled=['register','change_password','request_reset_password','profile']
auth.settings.remember_me_form = False
auth.settings.login_next = URL('default','get_ldapgroups')

Is it expected? It just goes to index and doesn't care about my
redirection...

Regards,

Tito


-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Re: Form in component submits (blank) when component first loads

2012-02-03 Thread monotasker
Ah. Now I understand. Thanks a lot for explaining. Sometimes it's the 
basic structural things I miss!


[web2py] Re: Is the undocumented ListWidget in sqlhtml safe?

2012-02-03 Thread Anthony
If a list:type field has an IS_IN_SET or IS_IN_DB validator, by default 
it will get the MultipleOptionsWidget -- otherwise it will get the 
ListWidget. By default, list:reference fields get an IS_IN_DB validator, 
which is why you see the MultipleOptionsWidget by default for those fields 
(list:integer and list:string fields don't get any default validators, so 
they get the ListWidget by default). If you want to use the ListWidget, you 
either have to set requires=None for the list:reference field or explicitly 
set widget=SQLFORM.widgets.list.widget. However, you'll then have to enter 
record IDs into the list widget fields, which is probably not what you want 
to do.

Anthony

On Friday, February 3, 2012 11:06:40 AM UTC-5, monotasker wrote:

 That's good news. I'm a bit confused, though, since it doesn't seem to be 
 the default widget for list:reference fields, which are presented by 
 default in a multiple select widget (or does list:reference not fall under 
 list:type?).

 Also, the list widget isn't included in the list of available widgets on 
 pp. 372-373 of the 4th edition book. So maybe that Massimo could update 
 that section to include it.



[web2py] Re: Book v4.0 translate to spanish

2012-02-03 Thread Massimo Di Pierro
We have the spanish translation. The problem is in reST not markmin. I
will send it to you and you can help with conversion. ;-)

Then it would be easy to post it.

On Feb 3, 7:35 am, Martín Mulone mulone.mar...@gmail.com wrote:
 I want to start the translation to spanish of the book, 4th edition.
  What's are the way to be syncronize with english version?. Any help?.


[web2py] lungo.js

2012-02-03 Thread Massimo Di Pierro
http://www.lungojs.com/


[web2py] Import CSV

2012-02-03 Thread Omi Chiba
I want to provide import/export CSV file from a specific table for
users. All I want is just like appadmin works. I'm referencing
appadmin code trying to write the code below but I get error
messages.  Does anyone can point out what's the problem ?

Example for auth_user table.

Model
-
dba = DAL('sqlite://storage.sqlite')
auth = Auth(dba, hmac_key=Auth.get_or_create_key())

Controller
--
def import_csv(table, file):
table.import_from_csv_file(file)

def index():
if request.vars.csvfile != None:
import_csv(db[request.vars.table],request.vars.csvfile.file)
response.flash = T('data uploaded')
return dict()

View - default/index

{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

{{=FORM(str(T('or import from csv file'))+
,INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='dba.auth_user',_name='table'),INPUT(_type='submit',_value='import'))}}

Traceback
---
Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 204, in restricted
exec ccode in environment
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 73, in module
  File C:\web2py\gluon\globals.py, line 172, in lambda
self._caller = lambda f: f()
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 69, in index
import_csv(db[request.vars.table],request.vars.csvfile.file)
  File C:\web2py\gluon\dal.py, line 5113, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'dba.auth_user'




[web2py] Re: Is the undocumented ListWidget in sqlhtml safe?

2012-02-03 Thread monotasker
Great. Thanks again. I really appreciate your help.


[web2py] Re: Import CSV

2012-02-03 Thread Anthony


 Model 
 - 
 dba = DAL('sqlite://storage.sqlite') 
 auth = Auth(dba, hmac_key=Auth.get_or_create_key()) 

 Controller 
 -- 
 def import_csv(table, file): 
 table.import_from_csv_file(file) 

 def index(): 
 if request.vars.csvfile != None: 
 import_csv(db[request.vars.table],request.vars.csvfile.file) 


Since your database object is dba, the above line should be 
dba[request.vars.table].

{{=FORM(str(T('or import from csv file'))+ 
 ,INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='dba.auth_user',_name='table'),INPUT(_type='submit',_value='import'))}}
  



request.vars.table should just be the table name, without the dba. -- so, 
_value='auth_user'.

Anthony



[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
Yes, I did restart and incorporated your fix.  It still doesn't work.

I don't think it has to do with routes.py

On Feb 3, 9:52 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:46 AM, VP wrote:

  Thanks. I just emailed you my routes.py.

  But routes.py might not be the cause, because I have just removed it
  (without using routes.py), the problem still existed.

 Did you restart web2py? Until you do, it won't recognize the change.

 I added unit tests for the kind of thing you're seeing to both router tests 
 (pattern  parametric) and they seem to be working OK.

 There was a (possibly minor) problem with your routes.py. I suggest that you 
 fix it, using router.example.py as the basis, update the routes.py doctest to 
 work with your changes, and then add a doctest for the failing conditions.

 (FWIW, I'm doing my testing in the trunk, but I don't think there's a 
 relevant change from 1.99.4.)









  On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Feb 3, 2012, at 7:20 AM, VP wrote:

  Is it possible that you're invoking different routers on the two 
  systems? Or enabling routes on one and not the other?

  Jonathan,

  One configuration difference between  the server and the personal
  computer is that  on the server, I use routes.py, which 
  routeswww.mysite.com
  and mysite.com to the appropriate app.

  Could this be the problem?  If so, how to fix it?

  Please post (or send me privately) your routes.py.


Re: [web2py] Re: Book v4.0 translate to spanish

2012-02-03 Thread Albert Abril
Hi Massimo and Martin,

where is planned to release the book: web2py Application Development
Cookbook?
(
http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book?utm_source=web2py.comutm_medium=linkutm_content=podutm_campaign=mdb_009617
 )
i bought an ebook copy, and it's expected in this month.

Regards.


2012/2/3 Massimo Di Pierro massimo.dipie...@gmail.com

 We have the spanish translation. The problem is in reST not markmin. I
 will send it to you and you can help with conversion. ;-)

 Then it would be easy to post it.

 On Feb 3, 7:35 am, Martín Mulone mulone.mar...@gmail.com wrote:
  I want to start the translation to spanish of the book, 4th edition.
   What's are the way to be syncronize with english version?. Any help?.



Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 9:46 AM, VP wrote:

 Yes, I did restart and incorporated your fix.  It still doesn't work.
 
 I don't think it has to do with routes.py

Curious. What are the operating systems and Python versions on the working and 
non-working systems? I think the most productive course right now is to see 
what's different.

Another thing that might help is to put =BEAUTIFY(request) into a template 
somewhere and compare the two when given URLs of the form you're having trouble 
with.

 
 On Feb 3, 9:52 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:46 AM, VP wrote:
 
 Thanks. I just emailed you my routes.py.
 
 But routes.py might not be the cause, because I have just removed it
 (without using routes.py), the problem still existed.
 
 Did you restart web2py? Until you do, it won't recognize the change.
 
 I added unit tests for the kind of thing you're seeing to both router tests 
 (pattern  parametric) and they seem to be working OK.
 
 There was a (possibly minor) problem with your routes.py. I suggest that you 
 fix it, using router.example.py as the basis, update the routes.py doctest 
 to work with your changes, and then add a doctest for the failing conditions.
 
 (FWIW, I'm doing my testing in the trunk, but I don't think there's a 
 relevant change from 1.99.4.)
 
 
 
 
 
 
 
 
 
 On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:20 AM, VP wrote:
 
 Is it possible that you're invoking different routers on the two 
 systems? Or enabling routes on one and not the other?
 
 Jonathan,
 
 One configuration difference between  the server and the personal
 computer is that  on the server, I use routes.py, which 
 routeswww.mysite.com
 and mysite.com to the appropriate app.
 
 Could this be the problem?  If so, how to fix it?
 
 Please post (or send me privately) your routes.py.




Re: [web2py] web2py long term projects: experiences ?

2012-02-03 Thread howesc
i don't know of any blogs that discuss the experiences of users over the 
long term.  i suspect this group history might be an indication.  heck, 
check my posts over the past couple of years - whenever i hit bumps in the 
road i tend to ask questions here.

are there specific things we can help answer?  i have used web2py for 4 
live production projects (and a few toys along the way), 3 of the 4 are on 
google app engine, and one of the 4 sees a sustained 60 requests a second 
average, so i've been using it all heavily (though not always the most up 
to date, i'm slow at incorporating new features).

cfh


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
My personal pc is Mac Leopard Python 2.7.2.   The parsing works as
expected on this pc.

The server is Debian squeeze, ngnix, uwsgi, Python 2.6.6.  The parsing
messed up as described above.



On Feb 3, 12:00 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 9:46 AM, VP wrote:

  Yes, I did restart and incorporated your fix.  It still doesn't work.

  I don't think it has to do with routes.py

 Curious. What are the operating systems and Python versions on the working 
 and non-working systems? I think the most productive course right now is to 
 see what's different.

 Another thing that might help is to put =BEAUTIFY(request) into a template 
 somewhere and compare the two when given URLs of the form you're having 
 trouble with.









  On Feb 3, 9:52 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Feb 3, 2012, at 7:46 AM, VP wrote:

  Thanks. I just emailed you my routes.py.

  But routes.py might not be the cause, because I have just removed it
  (without using routes.py), the problem still existed.

  Did you restart web2py? Until you do, it won't recognize the change.

  I added unit tests for the kind of thing you're seeing to both router 
  tests (pattern  parametric) and they seem to be working OK.

  There was a (possibly minor) problem with your routes.py. I suggest that 
  you fix it, using router.example.py as the basis, update the routes.py 
  doctest to work with your changes, and then add a doctest for the failing 
  conditions.

  (FWIW, I'm doing my testing in the trunk, but I don't think there's a 
  relevant change from 1.99.4.)

  On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Feb 3, 2012, at 7:20 AM, VP wrote:

  Is it possible that you're invoking different routers on the two 
  systems? Or enabling routes on one and not the other?

  Jonathan,

  One configuration difference between  the server and the personal
  computer is that  on the server, I use routes.py, which 
  routeswww.mysite.com
  and mysite.com to the appropriate app.

  Could this be the problem?  If so, how to fix it?

  Please post (or send me privately) your routes.py.


Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 10:38 AM, VP wrote:

 My personal pc is Mac Leopard Python 2.7.2.   The parsing works as
 expected on this pc.
 
 The server is Debian squeeze, ngnix, uwsgi, Python 2.6.6.  The parsing
 messed up as described above.

Looking at the parametric router code, I don't see any logic that could cause 
what you're seeing (it basically does a split('/') on the args portion of the 
URL); I  believe that the default and pattern-based router handlers do 
essentially the same thing. The BEAUTIFY trick below is intended to tell us 
whether nginx or something else might be doing something with the URL before 
web2py gets it.

 
 
 
 On Feb 3, 12:00 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 9:46 AM, VP wrote:
 
 Yes, I did restart and incorporated your fix.  It still doesn't work.
 
 I don't think it has to do with routes.py
 
 Curious. What are the operating systems and Python versions on the working 
 and non-working systems? I think the most productive course right now is to 
 see what's different.
 
 Another thing that might help is to put =BEAUTIFY(request) into a template 
 somewhere and compare the two when given URLs of the form you're having 
 trouble with.
 
 
 
 
 
 
 
 
 
 On Feb 3, 9:52 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:46 AM, VP wrote:
 
 Thanks. I just emailed you my routes.py.
 
 But routes.py might not be the cause, because I have just removed it
 (without using routes.py), the problem still existed.
 
 Did you restart web2py? Until you do, it won't recognize the change.
 
 I added unit tests for the kind of thing you're seeing to both router 
 tests (pattern  parametric) and they seem to be working OK.
 
 There was a (possibly minor) problem with your routes.py. I suggest that 
 you fix it, using router.example.py as the basis, update the routes.py 
 doctest to work with your changes, and then add a doctest for the failing 
 conditions.
 
 (FWIW, I'm doing my testing in the trunk, but I don't think there's a 
 relevant change from 1.99.4.)
 
 On Feb 3, 9:27 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Feb 3, 2012, at 7:20 AM, VP wrote:
 
 Is it possible that you're invoking different routers on the two 
 systems? Or enabling routes on one and not the other?
 
 Jonathan,
 
 One configuration difference between  the server and the personal
 computer is that  on the server, I use routes.py, which 
 routeswww.mysite.com
 and mysite.com to the appropriate app.
 
 Could this be the problem?  If so, how to fix it?
 
 Please post (or send me privately) your routes.py.




[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP

 Another thing that might help is to put =BEAUTIFY(request) into a template 
 somewhere and compare the two when given URLs of the form you're having 
 trouble with.


This is interesting.  On the server, path_info and web2py_original_uri
got it wrong.

If say, the url is app/controller/function/a/b//c.

Then the correct path_info on the server is this: app/controller/
function/a/b/c
The slash between b and c was wrongly removed.

Whereas on my pc, it is correct: app/controller/function/a/b//c


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
To clarify, given URL controller/function/a/b//c,

on the server, path info is:

controller/function/a/b/c

This is wrong.  The correct is shown on my pc as

controller/function/a/b//c


Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 10:49 AM, VP wrote:

 Another thing that might help is to put =BEAUTIFY(request) into a template 
 somewhere and compare the two when given URLs of the form you're having 
 trouble with.
 
 
 This is interesting.  On the server, path_info and web2py_original_uri
 got it wrong.
 
 If say, the url is app/controller/function/a/b//c.
 
 Then the correct path_info on the server is this: app/controller/
 function/a/b/c
 The slash between b and c was wrongly removed.
 
 Whereas on my pc, it is correct: app/controller/function/a/b//c

That *is* interesting. I'll double-check the incoming-URL logic, but what 
you're seeing is I think what web2py is given. I think that both nginx and 
uwsgi maintain their own logs; you might take a look there and see what they 
have to say.

[web2py] Re: Import CSV

2012-02-03 Thread Omi Chiba
It works great. Thanks a lot !!

On Feb 3, 11:23 am, Anthony abasta...@gmail.com wrote:
  Model
  -
  dba = DAL('sqlite://storage.sqlite')
  auth = Auth(dba, hmac_key=Auth.get_or_create_key())

  Controller
  --
  def import_csv(table, file):
      table.import_from_csv_file(file)

  def index():
      if request.vars.csvfile != None:
          import_csv(db[request.vars.table],request.vars.csvfile.file)

 Since your database object is dba, the above line should be
 dba[request.vars.table].

 {{=FORM(str(T('or import from csv file'))+

  ,INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='dba.auth 
  _user',_name='table'),INPUT(_type='submit',_value='import'))}}

 request.vars.table should just be the table name, without the dba. -- so,
 _value='auth_user'.

 Anthony


[web2py] Make all migrations explicit, and know when they are needed?

2012-02-03 Thread nick name
I run my app with migrate=migrate_enabled=False, because when migrations 
_are_ needed, they are nontrivial, and the default logic is never what I 
want.

I would like to have some migration needed response from the database, so 
that when a user of the app runs a new version of the app on an old databse 
(that needs migration), they'll get an error message like migration 
needed; please run migrate_now.py, rather than a random failure somewhere 
because the in-memory web2py schema and the database schema do not match.

Is there a way to do that now? Should I start a new ticket on googlecode?


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
For some reason my nginx does not keep log, but I think it's unlikely
that nginx will remove slashes in the middle of a URL (e.g.  app/con/
func/a/b//c).



[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread pbreit
It's probably a problem at the server level since web servers generally 
ignore empty path segments (are they even valid?).

Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 11:29 AM, VP wrote:

 For some reason my nginx does not keep log, but I think it's unlikely
 that nginx will remove slashes in the middle of a URL (e.g.  app/con/
 func/a/b//c).

Unlikely, but *somebody* is doing it. How about a uwsgi log?

If you want to nail down conclusively whether web2py is involved, try logging 
the content of the environ argument to gluon.main.wsgibase.

What I'm suspecting is that you might have some boilerplace URL rewriting going 
on that's doing it before web2py sees the URL. Something along these lines:

http://www.mydigitallife.info/redirect-or-rewrite-to-remove-double-or-multiple-slashes-in-url/
http://rosslawley.co.uk/2010/01/nginx-how-to-url-cleaning-removing.html



[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread pbreit
empty path segments are normally ignored
http://docs.python.org/library/wsgiref.html

they can decide to ignore empty path segments. Both IIS and Apache work 
this way
http://davescoolblog.blogspot.com/2011/11/uri-empty-path-segments-matter.html


[web2py] Re: Make all migrations explicit, and know when they are needed?

2012-02-03 Thread pbreit
Yeah, I'd like to see more explicit migrating and more visibility into 
what's happening. Auto migrations are great in development but scary in 
production.

Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 11:46 AM, pbreit wrote:

 they can decide to ignore empty path segments. Both IIS and Apache work this 
 way
 http://davescoolblog.blogspot.com/2011/11/uri-empty-path-segments-matter.html

Apache might when mapping a URL to a filesystem path, but it does normally pass 
the URL string through intact to (eg) web2py.

[web2py] ember.js and conflict with template {{ }} marks ...

2012-02-03 Thread David Marko
Hello, it was discussed earlier but with no result. I would like to use 
ember.js  http://emberjs.com/documentation/  which uses {{}} for its 
template language. This conflicts with web2py template and causes errors. I 
there a way how to incorporate some special web2py tag, that will allow 
web2py to skip its content as is without evaluating it as web2py template? 
Or is there anyone who found good solution for this?

thank you ...


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP
Im using nginx, but can someone with ngnix, apache, see if this is
indeed the case?

I am not sure which config files of nginx to look for these rewrite
rules. /opt/nginx/conf/nginx.conf has not rewrite rules.

On Feb 3, 1:46 pm, pbreit pbreitenb...@gmail.com wrote:
 empty path segments are normally 
 ignoredhttp://docs.python.org/library/wsgiref.html

 they can decide to ignore empty path segments. Both IIS and Apache work
 this 
 wayhttp://davescoolblog.blogspot.com/2011/11/uri-empty-path-segments-mat...


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread VP

 they can decide to ignore empty path segments. Both IIS and Apache work
 this 
 wayhttp://davescoolblog.blogspot.com/2011/11/uri-empty-path-segments-mat...


If this is true, it'll be a bummer for web2py, as its default behavior
differentiates empty and non-empty path segments.


[web2py] Export CSV

2012-02-03 Thread Omi Chiba
I want to export the specific table data to csv. I tried the code
after appadmin but I got a TypeError: 'str' object is not callable
error. Can you guys help ?

I also want to export the csv file with   for characters.


Model
--
db.define_table('IQWAGFTY',
Field('TYPRCD', length=15),
Field('TYPRKJ', length=50),
Field('TYTYPE', length=2),
primarykey=['TYPRCD'])


Controller
--
def export_csv():
import gluon.contenttype
response.headers['Content-Type'] = \
gluon.contenttype.contenttype('.csv')
db = request.args[0]
query = 'db.IQWAGFTY.TYPRCD!='
response.headers['Content-disposition'] = 'attachment;
filename=IQWAGFTY.csv'
return str(db(query,ignore_common_filters=True).select())

def index():
if request.vars.csvfile != None:
import_csv(db[request.vars.table],request.vars.csvfile.file)
response.flash = T('data uploaded')
return dict()

View  - default/index
--
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

h3Step 1. Download file/h3
[ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as
csv file}}/a ]

Traceback
--
Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 204, in restricted
exec ccode in environment
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 82, in module
  File C:\web2py\gluon\globals.py, line 172, in lambda
self._caller = lambda f: f()
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 22, in export_csv
return str(db(query,ignore_common_filters=True).select())
TypeError: 'str' object is not callable


[web2py] Re: ember.js and conflict with template {{ }} marks ...

2012-02-03 Thread Anthony
You could do 
this: https://groups.google.com/d/topic/web2py/4IFFE-7vq1I/discussion. The 
only downside is you have to call the special render() function in each 
controller instead of relying on web2py's default handling of the rendering.

Another option is to create a special helper for your ember markup:

In a model or imported from a module:
class em(DIV):
tag = ''
def xml(self):
return '{{%s}}' % super(em, self).xml()

In web2py view:
{{=em('stuff that goes in ember markup')}}
{{=em('stuff that goes in ember markup, ', A('including nested web2py 
helpers', _href='#'))}}
{{=A(em('ember markup nested in a web2py helper'), _href='#')}}

Produces:
{{stuff that goes in ember markup}}
{{more stuff, a href=#including nested web2py helpers/a}}
a href=#{{ember markup embedded in a web2py helper}}/a

Ultimately, it would be nice if the web2py markup tags were more easily 
configurable. I was thinking it might be nice to do so in routes.py -- that 
way you could specify custom tags on a per view basis (though if the views 
extend a layout, the layout would have to have the same custom tags as the 
view).

Anthony

On Friday, February 3, 2012 3:00:12 PM UTC-5, David Marko wrote:

 Hello, it was discussed earlier but with no result. I would like to use 
 ember.js  http://emberjs.com/documentation/  which uses {{}} for its 
 template language. This conflicts with web2py template and causes errors. I 
 there a way how to incorporate some special web2py tag, that will allow 
 web2py to skip its content as is without evaluating it as web2py template? 
 Or is there anyone who found good solution for this?

 thank you ...



[web2py] Re: Export CSV

2012-02-03 Thread Anthony
Take your query out of quotes -- a query has to be a DAL Query object, but 
you have simply passed in a string.

Anthony

On Friday, February 3, 2012 3:31:23 PM UTC-5, Omi Chiba wrote:

 I want to export the specific table data to csv. I tried the code 
 after appadmin but I got a TypeError: 'str' object is not callable 
 error. Can you guys help ? 

 I also want to export the csv file with   for characters. 


 Model 
 -- 
 db.define_table('IQWAGFTY', 
 Field('TYPRCD', length=15), 
 Field('TYPRKJ', length=50), 
 Field('TYTYPE', length=2), 
 primarykey=['TYPRCD']) 


 Controller 
 -- 
 def export_csv(): 
 import gluon.contenttype 
 response.headers['Content-Type'] = \ 
 gluon.contenttype.contenttype('.csv') 
 db = request.args[0] 
 query = 'db.IQWAGFTY.TYPRCD!=' 
 response.headers['Content-disposition'] = 'attachment; 
 filename=IQWAGFTY.csv' 
 return str(db(query,ignore_common_filters=True).select()) 

 def index(): 
 if request.vars.csvfile != None: 
 import_csv(db[request.vars.table],request.vars.csvfile.file) 
 response.flash = T('data uploaded') 
 return dict() 

 View  - default/index 
 -- 
 {{left_sidebar_enabled=right_sidebar_enabled=False}} 
 {{extend 'layout.html'}} 

 h3Step 1. Download file/h3 
 [ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as 
 csv file}}/a ] 

 Traceback 
 -- 
 Traceback (most recent call last): 
   File C:\web2py\gluon\restricted.py, line 204, in restricted 
 exec ccode in environment 
   File C:/web2py/applications/Inventory_Reserve_Admin/controllers/ 
 default.py, line 82, in module 
   File C:\web2py\gluon\globals.py, line 172, in lambda 
 self._caller = lambda f: f() 
   File C:/web2py/applications/Inventory_Reserve_Admin/controllers/ 
 default.py, line 22, in export_csv 
 return str(db(query,ignore_common_filters=True).select()) 
 TypeError: 'str' object is not callable 



[web2py] Re: Export CSV

2012-02-03 Thread Omi Chiba
Oh my god, it worked again!!

I also want to export the csv file with   for characters.
Do you know if we can do this ? I want do quotechar='' just like the
following link.

http://www.web2py.com/books/default/chapter/29/6?search=csv#Data-representation




On Feb 3, 2:54 pm, Anthony abasta...@gmail.com wrote:
 Take your query out of quotes -- a query has to be a DAL Query object, but
 you have simply passed in a string.

 Anthony







 On Friday, February 3, 2012 3:31:23 PM UTC-5, Omi Chiba wrote:

  I want to export the specific table data to csv. I tried the code
  after appadmin but I got a TypeError: 'str' object is not callable
  error. Can you guys help ?

  I also want to export the csv file with   for characters.

  Model
  --
  db.define_table('IQWAGFTY',
      Field('TYPRCD', length=15),
      Field('TYPRKJ', length=50),
      Field('TYTYPE', length=2),
      primarykey=['TYPRCD'])

  Controller
  --
  def export_csv():
      import gluon.contenttype
      response.headers['Content-Type'] = \
          gluon.contenttype.contenttype('.csv')
      db = request.args[0]
      query = 'db.IQWAGFTY.TYPRCD!='
      response.headers['Content-disposition'] = 'attachment;
  filename=IQWAGFTY.csv'
      return str(db(query,ignore_common_filters=True).select())

  def index():
      if request.vars.csvfile != None:
          import_csv(db[request.vars.table],request.vars.csvfile.file)
          response.flash = T('data uploaded')
      return dict()

  View  - default/index
  --
  {{left_sidebar_enabled=right_sidebar_enabled=False}}
  {{extend 'layout.html'}}

  h3Step 1. Download file/h3
  [ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as
  csv file}}/a ]

  Traceback
  --
  Traceback (most recent call last):
    File C:\web2py\gluon\restricted.py, line 204, in restricted
      exec ccode in environment
    File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
  default.py, line 82, in module
    File C:\web2py\gluon\globals.py, line 172, in lambda
      self._caller = lambda f: f()
    File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
  default.py, line 22, in export_csv
      return str(db(query,ignore_common_filters=True).select())
  TypeError: 'str' object is not callable


Re: [web2py] Re: Export CSV

2012-02-03 Thread Omi Chiba
OK. Can you send me the 4th ed markmin files ?

On Fri, Feb 3, 2012 at 3:03 PM, Omi Chiba ochib...@gmail.com wrote:

 Oh my god, it worked again!!

 I also want to export the csv file with   for characters.
 Do you know if we can do this ? I want do quotechar='' just like the
 following link.


 http://www.web2py.com/books/default/chapter/29/6?search=csv#Data-representation




 On Feb 3, 2:54 pm, Anthony abasta...@gmail.com wrote:
  Take your query out of quotes -- a query has to be a DAL Query object,
 but
  you have simply passed in a string.
 
  Anthony
 
 
 
 
 
 
 
  On Friday, February 3, 2012 3:31:23 PM UTC-5, Omi Chiba wrote:
 
   I want to export the specific table data to csv. I tried the code
   after appadmin but I got a TypeError: 'str' object is not callable
   error. Can you guys help ?
 
   I also want to export the csv file with   for characters.
 
   Model
   --
   db.define_table('IQWAGFTY',
   Field('TYPRCD', length=15),
   Field('TYPRKJ', length=50),
   Field('TYTYPE', length=2),
   primarykey=['TYPRCD'])
 
   Controller
   --
   def export_csv():
   import gluon.contenttype
   response.headers['Content-Type'] = \
   gluon.contenttype.contenttype('.csv')
   db = request.args[0]
   query = 'db.IQWAGFTY.TYPRCD!='
   response.headers['Content-disposition'] = 'attachment;
   filename=IQWAGFTY.csv'
   return str(db(query,ignore_common_filters=True).select())
 
   def index():
   if request.vars.csvfile != None:
   import_csv(db[request.vars.table],request.vars.csvfile.file)
   response.flash = T('data uploaded')
   return dict()
 
   View  - default/index
   --
   {{left_sidebar_enabled=right_sidebar_enabled=False}}
   {{extend 'layout.html'}}
 
   h3Step 1. Download file/h3
   [ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as
   csv file}}/a ]
 
   Traceback
   --
   Traceback (most recent call last):
 File C:\web2py\gluon\restricted.py, line 204, in restricted
   exec ccode in environment
 File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
   default.py, line 82, in module
 File C:\web2py\gluon\globals.py, line 172, in lambda
   self._caller = lambda f: f()
 File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
   default.py, line 22, in export_csv
   return str(db(query,ignore_common_filters=True).select())
   TypeError: 'str' object is not callable



[web2py] Re: Export CSV

2012-02-03 Thread Anthony
On Friday, February 3, 2012 4:03:47 PM UTC-5, Omi Chiba wrote:

 Oh my god, it worked again!! 

 I also want to export the csv file with   for characters. 
 Do you know if we can do this ? I want do quotechar='' just like the 
 following link. 


 http://www.web2py.com/books/default/chapter/29/6?search=csv#Data-representation
  


I think the default is to use double quotes, but you have to set the 
quoting arg to tell it what to quote -- 
see http://docs.python.org/release/3.1.3/library/csv.html#module-contents 
for details. It defaults to csv.QUOTE_MINIMAL, which only quotes values 
that require quoting because they contain special characters. If you want 
to quote everything, use quoting=csv.QUOTE_ALL (be sure to import csv 
first).

Anthony

 





 On Feb 3, 2:54 pm, Anthony abasta...@gmail.com wrote: 
  Take your query out of quotes -- a query has to be a DAL Query object, 
 but 
  you have simply passed in a string. 
  
  Anthony 
  
  
  
  
  
  
  
  On Friday, February 3, 2012 3:31:23 PM UTC-5, Omi Chiba wrote: 
  
   I want to export the specific table data to csv. I tried the code 
   after appadmin but I got a TypeError: 'str' object is not callable 
   error. Can you guys help ? 
  
   I also want to export the csv file with   for characters. 
  
   Model 
   -- 
   db.define_table('IQWAGFTY', 
   Field('TYPRCD', length=15), 
   Field('TYPRKJ', length=50), 
   Field('TYTYPE', length=2), 
   primarykey=['TYPRCD']) 
  
   Controller 
   -- 
   def export_csv(): 
   import gluon.contenttype 
   response.headers['Content-Type'] = \ 
   gluon.contenttype.contenttype('.csv') 
   db = request.args[0] 
   query = 'db.IQWAGFTY.TYPRCD!=' 
   response.headers['Content-disposition'] = 'attachment; 
   filename=IQWAGFTY.csv' 
   return str(db(query,ignore_common_filters=True).select()) 
  
   def index(): 
   if request.vars.csvfile != None: 
   import_csv(db[request.vars.table],request.vars.csvfile.file) 
   response.flash = T('data uploaded') 
   return dict() 
  
   View  - default/index 
   -- 
   {{left_sidebar_enabled=right_sidebar_enabled=False}} 
   {{extend 'layout.html'}} 
  
   h3Step 1. Download file/h3 
   [ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as 
   csv file}}/a ] 
  
   Traceback 
   -- 
   Traceback (most recent call last): 
 File C:\web2py\gluon\restricted.py, line 204, in restricted 
   exec ccode in environment 
 File C:/web2py/applications/Inventory_Reserve_Admin/controllers/ 
   default.py, line 82, in module 
 File C:\web2py\gluon\globals.py, line 172, in lambda 
   self._caller = lambda f: f() 
 File C:/web2py/applications/Inventory_Reserve_Admin/controllers/ 
   default.py, line 22, in export_csv 
   return str(db(query,ignore_common_filters=True).select()) 
   TypeError: 'str' object is not callable



[web2py] Valentina DB

2012-02-03 Thread mikech
Anyone come across this product in the wild?  Seems good, and it has a 
report writer, which is a missing piece I've been looking for. Has no 
Python binding, does support SQL.   http://www.valentina-db.com/

[web2py] Re: Export CSV

2012-02-03 Thread Omi Chiba
Do I need to rewrite this export_csv function completely ? or Can I
just add import csv and set QUOTE_ALL ?


Controller
--
def export_csv():
import gluon.contenttype
response.headers['Content-Type'] = \
gluon.contenttype.contenttype('.csv')
db = request.args[0]
query = 'db.IQWAGFTY.TYPRCD!='
response.headers['Content-disposition'] = 'attachment;
filename=IQWAGFTY.csv'
return str(db(query,ignore_common_filters=True).select())

On Feb 3, 4:36 pm, Anthony abasta...@gmail.com wrote:
 On Friday, February 3, 2012 4:03:47 PM UTC-5, Omi Chiba wrote:

  Oh my god, it worked again!!

  I also want to export the csv file with   for characters.
  Do you know if we can do this ? I want do quotechar='' just like the
  following link.

 http://www.web2py.com/books/default/chapter/29/6?search=csv#Data-repr...

 I think the default is to use double quotes, but you have to set the
 quoting arg to tell it what to quote --
 seehttp://docs.python.org/release/3.1.3/library/csv.html#module-contents
 for details. It defaults to csv.QUOTE_MINIMAL, which only quotes values
 that require quoting because they contain special characters. If you want
 to quote everything, use quoting=csv.QUOTE_ALL (be sure to import csv
 first).

 Anthony









  On Feb 3, 2:54 pm, Anthony abasta...@gmail.com wrote:
   Take your query out of quotes -- a query has to be a DAL Query object,
  but
   you have simply passed in a string.

   Anthony

   On Friday, February 3, 2012 3:31:23 PM UTC-5, Omi Chiba wrote:

I want to export the specific table data to csv. I tried the code
after appadmin but I got a TypeError: 'str' object is not callable
error. Can you guys help ?

I also want to export the csv file with   for characters.

Model
--
db.define_table('IQWAGFTY',
    Field('TYPRCD', length=15),
    Field('TYPRKJ', length=50),
    Field('TYTYPE', length=2),
    primarykey=['TYPRCD'])

Controller
--
def export_csv():
    import gluon.contenttype
    response.headers['Content-Type'] = \
        gluon.contenttype.contenttype('.csv')
    db = request.args[0]
    query = 'db.IQWAGFTY.TYPRCD!='
    response.headers['Content-disposition'] = 'attachment;
filename=IQWAGFTY.csv'
    return str(db(query,ignore_common_filters=True).select())

def index():
    if request.vars.csvfile != None:
        import_csv(db[request.vars.table],request.vars.csvfile.file)
        response.flash = T('data uploaded')
    return dict()

View  - default/index
--
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

h3Step 1. Download file/h3
[ a href={{=URL('export_csv',args='db.IQWAGFTY')}}{{=export as
csv file}}/a ]

Traceback
--
Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 204, in restricted
    exec ccode in environment
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 82, in module
  File C:\web2py\gluon\globals.py, line 172, in lambda
    self._caller = lambda f: f()
  File C:/web2py/applications/Inventory_Reserve_Admin/controllers/
default.py, line 22, in export_csv
    return str(db(query,ignore_common_filters=True).select())
TypeError: 'str' object is not callable


[web2py] Re: Export CSV

2012-02-03 Thread Anthony
On Friday, February 3, 2012 6:16:09 PM UTC-5, Omi Chiba wrote:

 Do I need to rewrite this export_csv function completely ? or Can I 
 just add import csv and set QUOTE_ALL ? 


 Controller 
 -- 
 def export_csv(): 
 import gluon.contenttype 
 response.headers['Content-Type'] = \ 
 gluon.contenttype.contenttype('.csv') 
 db = request.args[0] 
 query = 'db.IQWAGFTY.TYPRCD!=' 
 response.headers['Content-disposition'] = 'attachment; 
 filename=IQWAGFTY.csv' 
 return str(db(query,ignore_common_filters=True).select()) 


Instead of:

return str(db(query,ignore_common_filters=True).select())  

I think you could do something like:

import csv
import cStringIO
rows = db(query,ignore_common_filters=True).select()
s = cStringIO.StringIO()
rows.export_to_csv_file(s, quoting=csv.QUOTE_ALL)
return s.getvalue()

str(rows) actually does exactly the same as the above, but the above method 
allows you to pass additional arguments to export_to_csv_file().

Anthony


 


[web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread pbreit
Why would you ever have empty path segments?

Re: [web2py] Re: URL parsing problems (request.args)

2012-02-03 Thread Jonathan Lundell
On Feb 3, 2012, at 4:00 PM, pbreit wrote:

 Why would you ever have empty path segments?

Suppose that args is a list of strings and you have some empty string.


[web2py] Re: Book v4.0 translate to spanish

2012-02-03 Thread Massimo Di Pierro
I do not know. They are in the editing phase.

On Feb 3, 11:48 am, Albert Abril albert.ab...@gmail.com wrote:
 Hi Massimo and Martin,

 where is planned to release the book: web2py Application Development
 Cookbook?
 (http://www.packtpub.com/web2py-application-development-recipes-to-mas...
  )
 i bought an ebook copy, and it's expected in this month.

 Regards.

 2012/2/3 Massimo Di Pierro massimo.dipie...@gmail.com







  We have the spanish translation. The problem is in reST not markmin. I
  will send it to you and you can help with conversion. ;-)

  Then it would be easy to post it.

  On Feb 3, 7:35 am, Martín Mulone mulone.mar...@gmail.com wrote:
   I want to start the translation to spanish of the book, 4th edition.
    What's are the way to be syncronize with english version?. Any help?.