Re: [web2py] Re: Launch of Web2py 2

2012-06-28 Thread Niphlod
who said "from scratch" ?
you can as always start from the default look and finetune that ... not 
everyone is a designer but a few lines of css here and there can be changed 
around "just to see how it looks". 

Il giorno venerdì 29 giugno 2012 05:18:33 UTC+2, dundee ha scritto:
>
> I see your point, but I am not a designer and the integration of twitter 
> bootstrap and web2py is my answer. It has mostly been working out so far.
> It would take too much work for me to style my app from scratch.  :-) 
>
> On Thu, Jun 28, 2012 at 4:34 PM, Niphlod  wrote:
>
>> don't know if anyone "official" will pop up giving a timetable, but if 
>> your only concern is an app with twitter bootstrap I truly recommend to 
>> release it with your own template and css's rules
>>
>> Having to wait a 2.0 release just only for the styles of scaffolding app 
>> seems to me an overkill. I myself took that road... I'm waiting for a 2.0 
>> just to be able to exploit some new features that regards gluon libraries 
>> 
>>
>> Anyway, if you're fighting, I've seen particularly "gifted" members that 
>> are truly helpful with bootstrap's internals: if something come up with the 
>> standard template and it's unresolvable without hacking just css, a patch 
>> would be submitted :D
>>
>>
>>
>>
>> On Thursday, June 28, 2012 11:26:34 PM UTC+2, dundee wrote:
>>>
>>> Hi All,
>>>
>>> Anyone knows when web2py 2.0 will be released?
>>>
>>> I am fighting with the nightly build and having some trouble with 
>>> twitter bootstrap. 
>>>
>>> I have an app that I want to release but I don't want to release it 
>>> using the NIghtly build and I need to use twitter bootstrap.
>>>
>>> Would really love to have a release date so that I can know what to do.
>>>
>>>
>>> Thanks all.
>>>
>>>
>>>
>>>
>
>

Re: [web2py] Installing scheduler on linux

2012-06-28 Thread Michael Toomim
Maybe this should go into the docs somewhere. Maybe the scheduler docstring 
next to the upstart script? Maybe post an issue on google code to update the 
docs? http://code.google.com/p/web2py/issues/list

On Jun 28, 2012, at 5:41 AM, Tyrone wrote:

> Hi Guys,
> 
> Although this script works great when upstart is available, when upstart is 
> not available you can't do it like this. I struggled to find a solution on 
> here or anywhere online, so I have made an alternative script which will work 
> on sysvinit (/etc/init.d)
> 
> #!/bin/sh
> 
> DAEMON=/usr/local/bin/python
> PARAMETERS="/var/www/html/web2py/web2py.py -K init"
> LOGFILE=/var/log/web2py-scheduler.log
> 
> start() {
> echo -n "starting up $DAEMON"
> RUN=`$DAEMON $PARAMETERS > $LOGFILE 2>&1`
> if [ "$?" -eq 0 ]; then
> echo " Done."
> else
> echo " FAILED."
> fi
> }
> stop() {
> killall $DAEMON
> }
> status() {
> killall -0 $DAEMON
> if [ "$?" -eq 0 ]; then
> echo "Running."
> else
> echo "Not Running."
> fi
> }
> case "$1" in
> start)
> start
> ;;
> restart)
> stop
> sleep 2
> start
> ;;
> stop)
> stop
> ;;
> status)
> status
> ;;
> *)
> echo "usage : $0 start|restart|stop|status"
> ;;
> esac
> exit 0
> 
> I installed this on CentOS release 5.5, however I needed to follow these 
> instructions to install:
> 
> 1.) # vi web2py-scheduler
> 2.) Paste in the above
> 3.) Add in the following 2 lines in the web2py-scheduler file (required for 
> centos i believe):
> 
> # chkconfig: 2345 90 10
> # description: web2py-scheduler
> 
> 4.) make it executable # chmod 755 web2py-scheduler
> 5.) add it to startup # chkconfig --add web2py-scheduler



[web2py] Re: Form submission and "view page source"

2012-06-28 Thread Anthony

>
> The easiest way is to implement this is to replace self.formkey and 
> self.session.formkey in gluon/html.py so that it store not one key but the 
> last 10 keys.
>

The number should be configurable.
 

> I am still unsure about this. We can make it work but allowing the past 10 
> open forms to still be submitted can be considered a vulnerability.
>

How would that be exploited?

Anthony 


[web2py] Re: Best practice using scheduler as a task queue?

2012-06-28 Thread Michael Toomim
On Wednesday, June 27, 2012 5:02:26 PM UTC-7, ptressel wrote:
>
> This won't solve your installation / setup issue, but I wonder if it would 
> help with the overrun and timeout problems...  Instead of scheduling a 
> periodic task, what about having the task reschedule itself?  When it's 
> done with the queue, schedule itself for later.  Remove the time limit so 
> it can take whatever time it needs to finish the queue.  Or maybe launch a 
> process on startup outside of the scheduler -- when it exhausts the queue, 
> have it sleep and either wake periodically to check the queue, or have it 
> waked when something is inserted.
>

I don't see why we'd do this instead of just setting stop_time=infinity and 
repeats=0.
 

> Is the transaction processing issue you encountered with PostgreSQL 
> preventing you from setting up your queue as a real producer consumer 
> queue, where you could have multiple workers?
>

No, I only want one worker. The scheduler itself works great as a 
producer/consumer queue.

I may have mislead you with the title of this thread—I'm trying to set up a 
general repeating background process, not a task queue in particular. 
Processing a task queue was just one use of the repeating background 
process function.


Re: [web2py] Re: Launch of Web2py 2

2012-06-28 Thread Massimo Di Pierro
I feel very much the same. 

On Thursday, 28 June 2012 22:18:33 UTC-5, dundee wrote:
>
> I see your point, but I am not a designer and the integration of twitter 
> bootstrap and web2py is my answer. It has mostly been working out so far.
> It would take too much work for me to style my app from scratch.  :-) 
>
>

Re: [web2py] Re: Launch of Web2py 2

2012-06-28 Thread Kevin Miller
I see your point, but I am not a designer and the integration of twitter
bootstrap and web2py is my answer. It has mostly been working out so far.
It would take too much work for me to style my app from scratch.  :-)

On Thu, Jun 28, 2012 at 4:34 PM, Niphlod  wrote:

> don't know if anyone "official" will pop up giving a timetable, but if
> your only concern is an app with twitter bootstrap I truly recommend to
> release it with your own template and css's rules
>
> Having to wait a 2.0 release just only for the styles of scaffolding app
> seems to me an overkill. I myself took that road... I'm waiting for a 2.0
> just to be able to exploit some new features that regards gluon libraries
> 
>
> Anyway, if you're fighting, I've seen particularly "gifted" members that
> are truly helpful with bootstrap's internals: if something come up with the
> standard template and it's unresolvable without hacking just css, a patch
> would be submitted :D
>
>
>
>
> On Thursday, June 28, 2012 11:26:34 PM UTC+2, dundee wrote:
>>
>> Hi All,
>>
>> Anyone knows when web2py 2.0 will be released?
>>
>> I am fighting with the nightly build and having some trouble with twitter
>> bootstrap.
>>
>> I have an app that I want to release but I don't want to release it using
>> the NIghtly build and I need to use twitter bootstrap.
>>
>> Would really love to have a release date so that I can know what to do.
>>
>>
>> Thanks all.
>>
>>
>>
>>


[web2py] Re: Form submission and "view page source"

2012-06-28 Thread Massimo Di Pierro
The easiest way is to implement this is to replace self.formkey and 
self.session.formkey in gluon/html.py so that it store not one key but the 
last 10 keys. Mover, for security, when a key is used it must be discarded.

I am still unsure about this. We can make it work but allowing the past 10 
open forms to still be submitted can be considered a vulnerability. Any 
opinion?

Massimo


On Thursday, 28 June 2012 16:08:18 UTC-5, Anthony wrote:
>
> What is the recommended solution when this seems to happen randomly to 
>> some pages? Sounds like removing the session from the form opens up 
>> vulnerabilities.
>>
>
> It shouldn't happen "randomly". It should only happen when you open the 
> same page (or any page with a form that has the same formname) in the same 
> browser, and then go back to the original page and try to submit the 
> original form. We've talked about allowing multiple versions of the 
> _formkey for the same form to avoid this problem, but that hasn't been 
> implemented yet. Here's a possible way to achieve that (not tested):
>
> def myform():
> if '_formname' in request.post_vars:
> formname = request.post_vars._formname
> else:
> max_forms = 10
> if session.form_count and session.form_count < max_forms:
> session.form_count += 1
> else:
> session.form_count = 1
> formname = 'myform_%s' % session.form_count
> form = SQLFORM(db.mytable).process(formname=formname)
> return dict(form=form)
>
> That example will allow up to 10 distinct instances of the same form, each 
> with a unique _formname and matching _formkey. After 10, it starts 
> recycling formnames (and therefore overwriting old _formkeys).
>
> Anthony
>


[web2py] Re: Produce Invalid Input message rather than escape and add entry

2012-06-28 Thread Anthony
Maybe this would work:

if not XML(text).xml() == XML(text, sanitize=True).xml():
[send error message]

The idea is if there's nothing illegal, then the sanitized version should 
be the same as the non-sanitized (or look at some of these 
solutions).
 
You could make a custom 
validatorfor 
the text field and use something like this as the test. 

Anthony

On Thursday, June 28, 2012 9:01:30 PM UTC-4, cheer10s wrote:
>
> Hello I am using Santize=True with some HTML permitted. For any invalid 
> characters or HTML added such as  or , how can I produce a 
> response error message rather than escaping the code and adding it to the 
> database? So it just doesn't let you post it if there is any invalid markup
>
> Any ideas 
>
>
> *cheers
>
> Thank You :-)
>


[web2py] Produce Invalid Input message rather than escape and add entry

2012-06-28 Thread Andrew Evans
Hello I am using Santize=True with some HTML permitted. For any invalid
characters or HTML added such as  or , how can I produce a
response error message rather than escaping the code and adding it to the
database? So it just doesn't let you post it if there is any invalid markup

Any ideas


*cheers

Thank You :-)


[web2py] Re: Specify update column

2012-06-28 Thread Anthony
db(query).update(**{field_name: value})

Anthony

On Thursday, June 28, 2012 9:40:08 PM UTC-4, naveed wrote:
>
> I understand I can do an update in web2py like so:
>
> db(query).update(field=value)
>
> where field corresponds to a column in the table. 
>
> If I have the column name as a string, how can I use this string variable 
> to specify the column to do an update?
>


[web2py] Specify update column

2012-06-28 Thread naveed
I understand I can do an update in web2py like so:

db(query).update(field=value)

where field corresponds to a column in the table. 

If I have the column name as a string, how can I use this string variable 
to specify the column to do an update?


Re: [web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 5:51 PM, Anthony wrote:
> Although since the files are really not dynamic, they could be aggressively 
> cached.
> 
> Good point.
> 
> @cache(request.env.path_info, time_expire=60*60*24, cache_model=cache.ram)
> def css_js():
> response.view = '../static/%s' % '/'.join(request.args)
> return response.render()
> 
> caches for a day. Still won't be as fast as using the web server to serve a 
> static file, though. You could also set response.headers to tell the browser 
> to cache the files, which would probably be a bigger benefit.
> 

That's what I meant. 

I did that in an earlier project, where I used semi-dynamic CSS more 
aggressively, caching colors by name, stuff like that. CSS in a web2py template 
is a pretty nice way to write CSS.

ISTR that I sent Massimo a patch (applied) to make it easier to accomplish.

Re: [web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Anthony

>
> Although since the files are really not dynamic, they could be 
> aggressively cached.
>

Good point.

@cache(request.env.path_info, time_expire=60*60*24, cache_model=cache.ram)
def css_js():
response.view = '../static/%s' % '/'.join(request.args)
return response.render()

caches for a day. Still won't be as fast as using the web server to serve a 
static file, though. You could also set response.headers to tell the 
browser to cache the files, which would probably be a bigger benefit.

Anthony


Re: [web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 5:24 PM, Anthony wrote:
> Thanks very much Anthony. A small question before I mark this as complete.
> 
> Does your comment about web2py template not applying to the CSS file in the 
> static folder also apply to the js file in the static folder?
> 
> Does web2py template apply only to the Views?
> 
> Yes, though you could serve dynamically generated CSS and JS files. In a 
> controller (e.g., default.py):
> 
> def css_js():
> response.view = '../static/%s' % '/'.join(request.args)
> return dict()
> 
> and in a view:
> 
>  href="{{=URL('default','css_js',args=['css','mystyles.css'])}}">
> 
> Then you could have a /static/css/mystyles.css web2py template, which would 
> be dynamically served when requested through the css_js() function in 
> default.py. This is much less efficient than serving a pure static file, 
> though, so it's probably not worth doing just to dynamically generate a few 
> URLs.
> 

Although since the files are really not dynamic, they could be aggressively 
cached.

[web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread curiouslearn
Thanks very much Anthony. Really appreciate all your help.

On Thursday, June 28, 2012 8:24:53 PM UTC-4, Anthony wrote:
>
> Thanks very much Anthony. A small question before I mark this as complete.
>>
>> Does your comment about web2py template not applying to the CSS file in 
>> the static folder also apply to the js file in the static folder?
>>
>> Does web2py template apply only to the Views?
>>
>
> Yes, though you could serve dynamically generated CSS and JS files. In a 
> controller (e.g., default.py):
>
> def css_js():
> response.view = '../static/%s' % '/'.join(request.args)
> return dict()
>
> and in a view:
>
>  "{{=URL('default','css_js',args=['css','mystyles.css'])}}">
>
> Then you could have a /static/css/mystyles.css web2py template, which 
> would be dynamically served when requested through the css_js() function in 
> default.py. This is much less efficient than serving a pure static file, 
> though, so it's probably not worth doing just to dynamically generate a few 
> URLs.
>
> Anthony
>
>

Re: [web2py] Re: Multi_tenant

2012-06-28 Thread Ovidio Marinho
Well now after my DAL I have Instructions
db = DAL ('postgres :/ / postgres: passwd @ localhost: 5432/mybd')
db._common_fields=Field('request_tenant',default=request.env.http_host,writable=False,readable=False)]

What happened? in all my tables I have request_tenant the field, and
when I do a drive automatically writes the localhost: 8000. But now
how is that several users with different hosts with dhcp changing its
access each time with a different ip that can work?

this post from Massimo does exactly what I want with the school he has
provided for various and simultaneous access, I could spend the
Massimo setting this app?

http://www.mail-archive.com/web2py@googlegroups.com/msg64351.html

       Ovidio Marinho Falcao Neto
                Web Developer
             ovidio...@gmail.com
          ovidiomari...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil



2012/6/28 Massimo Di Pierro :
> Do me the issue is, should all data always be filtered by hospital.
> If there should only be filtered in some cases and not in other, use
> explicit queries
> If some tables are always filtered and some are not, you may want to use the
> tenant feature.
>
>
> On Thursday, 28 June 2012 05:45:13 UTC-5, Ovidio Marinho wrote:
>>
>> I can not split into separate database, as the management reports need
>> to filter all information. What I need is that the data are shown to
>> hosptal (1) is only seen by him. No problem if all hospitals being in
>> the same database, so is the question of security in view. When the
>> login Hospital (1) is made only data related to hospital (1) should
>> appear on the screen.
>>
>>
>>
>>
>>        Ovidio Marinho Falcao Neto
>>                 Web Developer
>>              ovidio...@gmail.com
>>           ovidiomari...@itjp.net.br
>>                  ITJP - itjp.net.br
>>                83   8826 9088 - Oi
>>                83   9334 0266 - Claro
>>                         Brasil
>>
>>
>>
>> 2012/6/27 Massimo Di Pierro :
>> > I would suggest you use a different database (a different connection
>> > string)
>> > for each hospital depending on the hostname.
>> >
>> > .domain.com
>> > import re; regex = re.compile('.*\://(.*?)/.*
>> > db = DAL('postgresq:///%s' %
>> > regex.match(request.env.http_host).group(1))
>> >
>> > In this way you keep your data separate (which is better for security)
>> > and
>> > will allow you scale horizontally by setting up multiple db server
>> > instances.
>> >
>> >
>> >
>> > On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote:
>> >>
>> >> I am making an application to control government medical appointments
>> >> in more than fifty hospitals all use a single postgres database, but
>> >> each hospital must have administrator access, Operator and User, and
>> >> each access must be made with the view of their unique data .
>> >>
>> >> is this.
>> >>
>> >>
>> >


[web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Anthony

>
> Thanks very much Anthony. A small question before I mark this as complete.
>
> Does your comment about web2py template not applying to the CSS file in 
> the static folder also apply to the js file in the static folder?
>
> Does web2py template apply only to the Views?
>

Yes, though you could serve dynamically generated CSS and JS files. In a 
controller (e.g., default.py):

def css_js():
response.view = '../static/%s' % '/'.join(request.args)
return dict()

and in a view:



Then you could have a /static/css/mystyles.css web2py template, which would 
be dynamically served when requested through the css_js() function in 
default.py. This is much less efficient than serving a pure static file, 
though, so it's probably not worth doing just to dynamically generate a few 
URLs.

Anthony



[web2py] image thumb

2012-06-28 Thread ctrlSoft
hi i would like to implement in my app a feature , create thumbs runtime 
like in picasa or imgur
original image 
http://i.imgur.com/E9az6.jpg 
thumb croped
http://i.imgur.com/E9az6*b*.jpg  

or in picasa
original image:
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/s634/SecureData-logo-design.gif
 
thumb croped
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
*s256-c*/SecureData-logo-design.gif
 
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
*s128-c*/SecureData-logo-design.gif
 


i want to save just original image and retrieve when i need different size 
of thumbnail, what is the best way?  any sugestions?


[web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread curiouslearn
Thanks very much Anthony. A small question before I mark this as complete.

Does your comment about web2py template not applying to the CSS file in the 
static folder also apply to the js file in the static folder?

Does web2py template apply only to the Views?

Thanks again.

On Thursday, June 28, 2012 7:09:36 PM UTC-4, curiouslearn wrote:
>
> Hello, 
>
> (1) After searching on the web I have see that the following are two 
> valid ways to link to an image in the static/images folder. However, 
> the first way is not working for me. Could this be because I deleted 
> all css files and js files (except jquery) that come with the Welcome 
> app? Please let me know if I should post more information. 
>
> background-image: url("{{=URL('static', 
> 'images/roughcloth.png')}}"); 
> /*This does not work*/ 
> /*background-image: 
> url('/microeconslides/static/images/roughcloth.png');*/  /*This works 
> for me*/ 
>
> For the option that does not work, Developer Tools in Chrome shows the 
> following error: 
>
> Failed to load resource: the server responded with a status of 400 
> (BAD REQUEST) 
> http://localhost:8000/microeconslides/static/css/%7B%7B=URL('static',%20'images/roughcloth.png')%7D%7D
>  
>
>
> (2) I use jquery to add some html images to the html file. The working 
> code is: 
>
> $("section").each(function(index){ 
> idtag = 's' + (index + 1) 
> $(this).attr('id', idtag); 
> $(this).append("\ 
>  class='prev' src='/microeconslides/static/images/left_arrow.png'/>\ 
>  class='next' 
> src='/microeconslides/static/images/right_arrow.png'/>\ 
> "); 
> $(this).css('display', 'none' ); 
> }); 
>
> Is there a way to use {{=URL(...)}} to add links to the images instead 
> of the way I have done. I am not sure how to deal with the inverted 
> commas if the URL method is used. It seems one cannot use triple 
> quotes here and other ones are already used and will conflict. 
>
> Thanks for your help. 
>


[web2py] Re: (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Anthony

>
> (1) After searching on the web I have see that the following are two 
> valid ways to link to an image in the static/images folder. However, 
> the first way is not working for me. Could this be because I deleted 
> all css files and js files (except jquery) that come with the Welcome 
> app? Please let me know if I should post more information. 
>
> background-image: url("{{=URL('static', 
> 'images/roughcloth.png')}}"); 
>

If this is a CSS file in your static folder, then it is not a web2py 
template, and you cannot use web2py template code in it. You could serve a 
CSS file dynamically based on a web2py template, but that's somewhat 
inefficient, so you're probably better off hard coding the URL. 
 

> (2) I use jquery to add some html images to the html file. The working 
> code is: 
>
> $("section").each(function(index){ 
> idtag = 's' + (index + 1) 
> $(this).attr('id', idtag); 
> $(this).append("\ 
>  class='prev' src='/microeconslides/static/images/left_arrow.png'/>\ 
>  class='next' 
> src='/microeconslides/static/images/right_arrow.png'/>\ 
> "); 
> $(this).css('display', 'none' ); 
> }); 
>
> Is there a way to use {{=URL(...)}} to add links to the images instead 
> of the way I have done. I am not sure how to deal with the inverted 
> commas if the URL method is used.
>

$(this).append("\ 
\ 
\ 
");

First, let's refer to the "inverted commas" as "single quotes". :-)

Note, the single quotes inside the {{...}} aren't a problem because the 
content inside the braces is Python and evaluated independently of the 
content outside the braces.

Anthony



[web2py] (1) Linking to image file in the CSS file. (2) Linking to image files in a js file.

2012-06-28 Thread Curiouslearn
Hello,

(1) After searching on the web I have see that the following are two
valid ways to link to an image in the static/images folder. However,
the first way is not working for me. Could this be because I deleted
all css files and js files (except jquery) that come with the Welcome
app? Please let me know if I should post more information.

background-image: url("{{=URL('static', 'images/roughcloth.png')}}");
/*This does not work*/
/*background-image:
url('/microeconslides/static/images/roughcloth.png');*/  /*This works
for me*/

For the option that does not work, Developer Tools in Chrome shows the
following error:

Failed to load resource: the server responded with a status of 400
(BAD REQUEST) 
http://localhost:8000/microeconslides/static/css/%7B%7B=URL('static',%20'images/roughcloth.png')%7D%7D

(2) I use jquery to add some html images to the html file. The working code is:

$("section").each(function(index){
idtag = 's' + (index + 1)
$(this).attr('id', idtag);
$(this).append("\
\
\
");
$(this).css('display', 'none' );
});

Is there a way to use {{=URL(...)}} to add links to the images instead
of the way I have done. I am not sure how to deal with the inverted
commas if the URL method is used. It seems one cannot use triple
quotes here and other ones are already used and will conflict.

Thanks for your help.


[web2py] Re: Can you bind a jquery function to web2py component refresh?

2012-06-28 Thread monotasker
Perfect. Thanks Anthony.

Ian

On Thursday, June 28, 2012 4:49:37 PM UTC-4, Anthony wrote:
>
> You can use the jQuery ajaxSuccess() 
> method. It can register a handler to fire 
> whenever an Ajax call completes 
> successfully. If your page makes multiple different Ajax calls, you can 
> determine which one it is via the url in the Ajax settings object, which 
> gets passed to the ajaxSuccess() callback. Maybe something like (not 
> tested):
>
> {{=LOAD('default', 'mycomponent.load', ajax=True, target='mycomponent')}}
> 
> jQuery(function() {
>   jQuery('#mycomponent').ajaxSuccess(function(e, xhr, settings) {
> if (settings.url == '/default/mycomponent.load') {
>   jQuery(this).doSomething();
> };
>   });
> });
> 
>
> Anthony
>
> On Thursday, June 28, 2012 3:53:14 PM UTC-4, monotasker wrote:
>>
>> I'd like to be able to bind a jquery function to a div that is the 
>> container for a web2py component, so that when the component content is 
>> updated by the controller the jquery function is triggered. But I'm not 
>> sure whether there is a stock event that would cover the component refresh 
>> (I don't know the internals of web2py_ajax.js). Does anyone have any 
>> suggestions?
>
>

[web2py] Re: Suggestion to add more mod_wsgi info to help new users -- WSGIPassAuthorization for instance

2012-06-28 Thread Larry Weinberg
Great!  Thanks Massimo.  I'm sure that will save some others some time!

[web2py] Re: Redirected https is returning HTML instead of JSON. Direct call works fine.

2012-06-28 Thread Larry Weinberg
Sorry.  Once again this had nothing to do with web2py.  I'll try and be 
more thorough next time I post.
It was the method of redirect that my redirect server was using that was 
causing the problem. urllib2 and pycurl both failed to handle meta redirect 
which is supposedly not preferred method these days.   When I switched it 
to use a simple location redirect  everything works great.


[web2py] Re: Launch of Web2py 2

2012-06-28 Thread Niphlod
don't know if anyone "official" will pop up giving a timetable, but if your 
only concern is an app with twitter bootstrap I truly recommend to release 
it with your own template and css's rules

Having to wait a 2.0 release just only for the styles of scaffolding app 
seems to me an overkill. I myself took that road... I'm waiting for a 2.0 
just to be able to exploit some new features that regards gluon libraries 


Anyway, if you're fighting, I've seen particularly "gifted" members that 
are truly helpful with bootstrap's internals: if something come up with the 
standard template and it's unresolvable without hacking just css, a patch 
would be submitted :D



On Thursday, June 28, 2012 11:26:34 PM UTC+2, dundee wrote:
>
> Hi All,
>
> Anyone knows when web2py 2.0 will be released?
>
> I am fighting with the nightly build and having some trouble with twitter 
> bootstrap. 
>
> I have an app that I want to release but I don't want to release it using 
> the NIghtly build and I need to use twitter bootstrap.
>
> Would really love to have a release date so that I can know what to do.
>
>
> Thanks all.
>
>
>
>

[web2py] Launch of Web2py 2

2012-06-28 Thread Kevin Miller
Hi All,

Anyone knows when web2py 2.0 will be released?

I am fighting with the nightly build and having some trouble with twitter
bootstrap.

I have an app that I want to release but I don't want to release it using
the NIghtly build and I need to use twitter bootstrap.

Would really love to have a release date so that I can know what to do.


Thanks all.


[web2py] Re: Form submission and "view page source"

2012-06-28 Thread Anthony

>
> What is the recommended solution when this seems to happen randomly to 
> some pages? Sounds like removing the session from the form opens up 
> vulnerabilities.
>

It shouldn't happen "randomly". It should only happen when you open the 
same page (or any page with a form that has the same formname) in the same 
browser, and then go back to the original page and try to submit the 
original form. We've talked about allowing multiple versions of the 
_formkey for the same form to avoid this problem, but that hasn't been 
implemented yet. Here's a possible way to achieve that (not tested):

def myform():
if '_formname' in request.post_vars:
formname = request.post_vars._formname
else:
max_forms = 10
if session.form_count and session.form_count < max_forms:
session.form_count += 1
else:
session.form_count = 1
formname = 'myform_%s' % session.form_count
form = SQLFORM(db.mytable).process(formname=formname)
return dict(form=form)

That example will allow up to 10 distinct instances of the same form, each 
with a unique _formname and matching _formkey. After 10, it starts 
recycling formnames (and therefore overwriting old _formkeys).

Anthony


[web2py] Re: Can you bind a jquery function to web2py component refresh?

2012-06-28 Thread Anthony
You can use the jQuery ajaxSuccess() 
method. It can register a handler to fire 
whenever an Ajax call completes 
successfully. If your page makes multiple different Ajax calls, you can 
determine which one it is via the url in the Ajax settings object, which 
gets passed to the ajaxSuccess() callback. Maybe something like (not 
tested):

{{=LOAD('default', 'mycomponent.load', ajax=True, target='mycomponent')}}

jQuery(function() {
  jQuery('#mycomponent').ajaxSuccess(function(e, xhr, settings) {
if (settings.url == '/default/mycomponent.load') {
  jQuery(this).doSomething();
};
  });
});


Anthony

On Thursday, June 28, 2012 3:53:14 PM UTC-4, monotasker wrote:
>
> I'd like to be able to bind a jquery function to a div that is the 
> container for a web2py component, so that when the component content is 
> updated by the controller the jquery function is triggered. But I'm not 
> sure whether there is a stock event that would cover the component refresh 
> (I don't know the internals of web2py_ajax.js). Does anyone have any 
> suggestions?



[web2py] Re: Form submission and "view page source"

2012-06-28 Thread Neil
Update: I have found a post of someone who is having the same problem:

http://stackoverflow.com/questions/7411269/web2py-form-works-as-expected-most-of-the-time-but-occasionally-it-simply-clears
 

With the "view page source", I guess Chrome is reloading the page, so the 
session key no longer matches. 

What is the recommended solution when this seems to happen randomly to some 
pages? Sounds like removing the session from the form opens up 
vulnerabilities.

Neil

On Thursday, June 28, 2012 8:01:42 PM UTC+1, Neil wrote:
>
> I have a page with a simple form on it, and sometimes when I click the 
> submit button, the page just reloads instead of performing correct action. 
> The only way I've found to consistently reproduce the problem is to click 
> "View page source" first (I'm using Chrome). I then noticed this happens in 
> other web2py applications as well. For example, if I fill out the form here:
>
> http://www.web2py.com/examples/form_examples/form 
>
> and click "view the page source" before submitting, the data isn't 
> submitted. Does anyone know why this is? It's not a problem in my case (I 
> don't expect my users to be viewing the page source), but my hope is that 
> if I understand what causes it, I may be able to figure out why it happens 
> randomly for me *without *viewing the source.
>
> Thanks,
> Neil
>


[web2py] Can you bind a jquery function to web2py component refresh?

2012-06-28 Thread monotasker
I'd like to be able to bind a jquery function to a div that is the 
container for a web2py component, so that when the component content is 
updated by the controller the jquery function is triggered. But I'm not 
sure whether there is a stock event that would cover the component refresh 
(I don't know the internals of web2py_ajax.js). Does anyone have any 
suggestions?

[web2py] Form submission and "view page source"

2012-06-28 Thread Neil
I have a page with a simple form on it, and sometimes when I click the 
submit button, the page just reloads instead of performing correct action. 
The only way I've found to consistently reproduce the problem is to click 
"View page source" first (I'm using Chrome). I then noticed this happens in 
other web2py applications as well. For example, if I fill out the form here:

http://www.web2py.com/examples/form_examples/form 

and click "view the page source" before submitting, the data isn't 
submitted. Does anyone know why this is? It's not a problem in my case (I 
don't expect my users to be viewing the page source), but my hope is that 
if I understand what causes it, I may be able to figure out why it happens 
randomly for me *without *viewing the source.

Thanks,
Neil


Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Richard Vézina
{{=form.custom.begin}}

head1head2head3

{{for a in session.field1_names_dict:}}


{{=form.custom.widget[session.field1_names_dict[a]['field1_name']+'_f1']}}

{{=form.custom.widget[session.field1_names_dict[a]['field1_name']+'_f2']}}

{{=form.custom.widget[session.field1_names_dict[a]['field1_name']+'_f3']}}

{{pass}}

{{=form.custom.submit}}

{{=form.custom.end}}


That's!

Thanks web2py and web2py community...

:)

Richard

On Thu, Jun 28, 2012 at 1:55 PM, Richard Vézina  wrote:

> Yes that what I am doing right now... I generate the form with
> SQLFORM.factory and then in the view as you and Anthony suggest I "refact"
> my form to get what I want.
>
> I am pretty impress by this new feature, I was not aware about custom
> form. It seems exactly what I was searching for...
>
> Thanks.
>
> Richard
>
>
> On Thu, Jun 28, 2012 at 1:15 PM, vinicius...@gmail.com <
> vinicius...@gmail.com> wrote:
>
>> Richard, wouldn't be better organizing your form direct in HTML using
>> custom.form tags?
>>
>>
>>
>> On 06/28/2012 01:00 PM, Richard Vézina wrote:
>>
>>> Forget the precedent email... I think I found how, it didn't work the
>>> first time I try, so I just put everything into string, maybe I had
>>> problem with a comma...
>>>
>>> inputs_list = []
>>> for a in field1_names_dict:
>>>
>>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f1',
>>> type='boolean', widget=SQLFORM.widgets.**checkboxes.widget,
>>> requires=IS_EMPTY_OR(IS_IN_**SET([assay_names_dict[a]['**
>>> field1_name_ui']]
>>>
>>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f2',
>>> db.ref_tab1, requires = 
>>> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab1.id
>>> ','%(**REPRESENTFIELD)s'
>>>
>>>
>>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f3',
>>> db.ref_tab2, requires = 
>>> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab2.id
>>> ','%(**REPRESENTFIELD)s'
>>>
>>>
>>> I I just have to add the formstyle in the SQLFORM.factory call :
>>>
>>> form = SQLFORM.factory(*inputs_list, formstyle='divs')
>>>
>>> On Thu, Jun 28, 2012 at 11:47 AM, Richard Vézina
>>> >> >
>>> wrote:
>>>
>>>Hello Anthony,
>>>
>>>If I don't use eval(), should I use web2py dummy table, I don't see
>>>how I will be able to build dummy table dynamically and declare it
>>>as inputs_list to be use with the asterisk... If I just put a
>>>asterisk in front of my actual generated inputs_list it not working
>>>since the item in the list are text. I don't see how I can insert
>>>Field into the list without generating them as strings...
>>>
>>>I will read a bit the links you sent.
>>>
>>>Thanks.
>>>
>>>Richard
>>>
>>>
>>>On Thu, Jun 28, 2012 at 11:29 AM, Anthony >>> wrote:
>>>
>>>I wounder what should be the best way to alter a form
>>>generated by SQLFORM.factory in a way where fields will be
>>>placed into a html table a 3 columns.
>>>
>>>So each 3 fields I need to insert a "tr" and each field need
>>>to be in a "td"...
>>>
>>>
>>>You might want to create a custom form layout in the view:
>>>
>>> http://web2py.com/books/**default/chapter/29/7#Custom-**forms.
>>> That
>>>way you can still use SQLFORM.factory to handle all the widget
>>>creation and processing, but you can present the fields however
>>>you want. You might also check out plugin_solidform
>>>
>>> 
>>> >.
>>>
>>>
>>> formstring = "SQLFORM.factory("
>>> +','.join(inputs_list)+")"
>>>
>>> form = eval(formstring)
>>>
>>>
>>>No need to eval code like that in Python. If you have a list of
>>>objects you want to submit as separate args to a function, just
>>>precede the list with an asterisk:
>>>
>>>|
>>>form =SQLFORM.factory(*input_list)
>>>|
>>>
>>>In that case, you can change the way you define the Field items
>>>in the list -- make them actual Field() objects rather than just
>>>strings of code.
>>>
>>>Note, for keyword arguments, you can submit a dictionary
>>>preceded by two asterisks:
>>>
>>>|
>>>some_function(**some_**dictionary)
>>>|
>>>
>>>Anthony
>>>
>>>
>>>
>>>
>>
>


[web2py] Re: Image Optimization

2012-06-28 Thread Yannick
Used the PIL API to do this

On Tuesday, June 26, 2012 6:49:43 AM UTC-4, Sanjeet Roy wrote:
>
> Can anyone tell me how can i optimize the image when the user will be 
> uploaded ? Acually i want to create a web application where the user can 
> upload and see the image on the categorization of album.i want optimize 
> image should be appeared in the thumbnail 
>


Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Richard Vézina
Yes that what I am doing right now... I generate the form with
SQLFORM.factory and then in the view as you and Anthony suggest I "refact"
my form to get what I want.

I am pretty impress by this new feature, I was not aware about custom form.
It seems exactly what I was searching for...

Thanks.

Richard

On Thu, Jun 28, 2012 at 1:15 PM, vinicius...@gmail.com <
vinicius...@gmail.com> wrote:

> Richard, wouldn't be better organizing your form direct in HTML using
> custom.form tags?
>
>
>
> On 06/28/2012 01:00 PM, Richard Vézina wrote:
>
>> Forget the precedent email... I think I found how, it didn't work the
>> first time I try, so I just put everything into string, maybe I had
>> problem with a comma...
>>
>> inputs_list = []
>> for a in field1_names_dict:
>>
>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f1',
>> type='boolean', widget=SQLFORM.widgets.**checkboxes.widget,
>> requires=IS_EMPTY_OR(IS_IN_**SET([assay_names_dict[a]['**
>> field1_name_ui']]
>>
>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f2',
>> db.ref_tab1, requires = 
>> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab1.id
>> ','%(**REPRESENTFIELD)s'
>>
>>
>> inputs_list.append(Field(**field1_names_dict[a]['field1_**name']+'_f3',
>> db.ref_tab2, requires = 
>> IS_EMPTY_OR(IS_IN_DB(db,'ref_**tab2.id
>> ','%(**REPRESENTFIELD)s'
>>
>>
>> I I just have to add the formstyle in the SQLFORM.factory call :
>>
>> form = SQLFORM.factory(*inputs_list, formstyle='divs')
>>
>> On Thu, Jun 28, 2012 at 11:47 AM, Richard Vézina
>> > >
>> wrote:
>>
>>Hello Anthony,
>>
>>If I don't use eval(), should I use web2py dummy table, I don't see
>>how I will be able to build dummy table dynamically and declare it
>>as inputs_list to be use with the asterisk... If I just put a
>>asterisk in front of my actual generated inputs_list it not working
>>since the item in the list are text. I don't see how I can insert
>>Field into the list without generating them as strings...
>>
>>I will read a bit the links you sent.
>>
>>Thanks.
>>
>>Richard
>>
>>
>>On Thu, Jun 28, 2012 at 11:29 AM, Anthony >> wrote:
>>
>>I wounder what should be the best way to alter a form
>>generated by SQLFORM.factory in a way where fields will be
>>placed into a html table a 3 columns.
>>
>>So each 3 fields I need to insert a "tr" and each field need
>>to be in a "td"...
>>
>>
>>You might want to create a custom form layout in the view:
>>
>> http://web2py.com/books/**default/chapter/29/7#Custom-**forms.
>> That
>>way you can still use SQLFORM.factory to handle all the widget
>>creation and processing, but you can present the fields however
>>you want. You might also check out plugin_solidform
>>
>> 
>> >.
>>
>>
>> formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"
>>
>> form = eval(formstring)
>>
>>
>>No need to eval code like that in Python. If you have a list of
>>objects you want to submit as separate args to a function, just
>>precede the list with an asterisk:
>>
>>|
>>form =SQLFORM.factory(*input_list)
>>|
>>
>>In that case, you can change the way you define the Field items
>>in the list -- make them actual Field() objects rather than just
>>strings of code.
>>
>>Note, for keyword arguments, you can submit a dictionary
>>preceded by two asterisks:
>>
>>|
>>some_function(**some_**dictionary)
>>|
>>
>>Anthony
>>
>>
>>
>>
>


Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread vinicius...@gmail.com
Richard, wouldn't be better organizing your form direct in HTML using 
custom.form tags?



On 06/28/2012 01:00 PM, Richard Vézina wrote:

Forget the precedent email... I think I found how, it didn't work the
first time I try, so I just put everything into string, maybe I had
problem with a comma...

 inputs_list = []
 for a in field1_names_dict:

inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f1',
type='boolean', widget=SQLFORM.widgets.checkboxes.widget,
requires=IS_EMPTY_OR(IS_IN_SET([assay_names_dict[a]['field1_name_ui']]

inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f2',
db.ref_tab1, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab1.id
','%(REPRESENTFIELD)s'

inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f3',
db.ref_tab2, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab2.id
','%(REPRESENTFIELD)s'

I I just have to add the formstyle in the SQLFORM.factory call :

form = SQLFORM.factory(*inputs_list, formstyle='divs')

On Thu, Jun 28, 2012 at 11:47 AM, Richard Vézina
mailto:ml.richard.vez...@gmail.com>> wrote:

Hello Anthony,

If I don't use eval(), should I use web2py dummy table, I don't see
how I will be able to build dummy table dynamically and declare it
as inputs_list to be use with the asterisk... If I just put a
asterisk in front of my actual generated inputs_list it not working
since the item in the list are text. I don't see how I can insert
Field into the list without generating them as strings...

I will read a bit the links you sent.

Thanks.

Richard


On Thu, Jun 28, 2012 at 11:29 AM, Anthony mailto:abasta...@gmail.com>> wrote:

I wounder what should be the best way to alter a form
generated by SQLFORM.factory in a way where fields will be
placed into a html table a 3 columns.

So each 3 fields I need to insert a "tr" and each field need
to be in a "td"...


You might want to create a custom form layout in the view:
http://web2py.com/books/default/chapter/29/7#Custom-forms. That
way you can still use SQLFORM.factory to handle all the widget
creation and processing, but you can present the fields however
you want. You might also check out plugin_solidform
.

 formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"

 form = eval(formstring)


No need to eval code like that in Python. If you have a list of
objects you want to submit as separate args to a function, just
precede the list with an asterisk:

|
form =SQLFORM.factory(*input_list)
|

In that case, you can change the way you define the Field items
in the list -- make them actual Field() objects rather than just
strings of code.

Note, for keyword arguments, you can submit a dictionary
preceded by two asterisks:

|
some_function(**some_dictionary)
|

Anthony







Re: [web2py] Re: uWSGI + Cherokee + web2py - a howto.

2012-06-28 Thread Leopold

Hi. First of all, sorry for not posting back, I had some unplanned issues.
Anyway, I tried the Ngnix approach (
http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh)
 
and long story short it didn't work either; same result as it did with 
cherokee on web browser:

*uWSGI Error*Python application not found 

So this is beyond the web server, something is wrong with uwsgi 
configuration but no error is displayed at uwsgi log:

# cat /var/log/uwsgi/app/web2py.log
Thu Jun 28 09:47:44 2012 - *** Starting uWSGI 1.2.3 (32bit) on [Thu Jun 28 
09:47:44 2012] ***
Thu Jun 28 09:47:44 2012 - compiled with version: 4.6.3 on 07 June 2012 
09:24:31
Thu Jun 28 09:47:44 2012 - detected number of CPU cores: 1
Thu Jun 28 09:47:44 2012 - current working directory: /
Thu Jun 28 09:47:44 2012 - writing pidfile to /run/uwsgi/app/web2py/pid
Thu Jun 28 09:47:44 2012 - detected binary path: /usr/bin/uwsgi
Thu Jun 28 09:47:44 2012 - setgid() to 33
Thu Jun 28 09:47:44 2012 - setuid() to 33
Thu Jun 28 09:47:44 2012 - your memory page size is 4096 bytes
Thu Jun 28 09:47:44 2012 - detected max file descriptor number: 1024
Thu Jun 28 09:47:44 2012 - lock engine: pthread robust mutexes
Thu Jun 28 09:47:44 2012 - uwsgi socket 0 bound to UNIX address 
/run/uwsgi/app/web2py/socket fd 3
Thu Jun 28 09:47:44 2012 - uwsgi socket 1 bound to TCP address 
127.0.0.1:9001 fd 5
Thu Jun 28 09:47:44 2012 - Python version: 2.7.3 (default, Apr 20 2012, 
23:06:40)  [GCC 4.6.3]
Thu Jun 28 09:47:44 2012 - *** Python threads support is disabled. You can 
enable it with --enable-threads ***
Thu Jun 28 09:47:44 2012 - Python main interpreter initialized at 0x8899410
Thu Jun 28 09:47:44 2012 - your server socket listen backlog is limited to 
100 connections
Thu Jun 28 09:47:44 2012 - *** Operational MODE: preforking ***
Thu Jun 28 09:47:44 2012 - added /home/www-data/web2py/ to pythonpath.
Thu Jun 28 09:47:44 2012 - mounting wsgihandler on /
Thu Jun 28 09:47:44 2012 - *** no app loaded. going in full dynamic mode ***
Thu Jun 28 09:47:44 2012 - *** uWSGI is running in multiple interpreter 
mode ***
Thu Jun 28 09:47:44 2012 - spawned uWSGI master process (pid: 6429)
Thu Jun 28 09:47:44 2012 - spawned uWSGI worker 1 (pid: 6437, cores: 1)
Thu Jun 28 09:47:44 2012 - spawned uWSGI worker 2 (pid: 6438, cores: 1)


This is what happens when I try to restart uwsgi:

# /etc/init.d/uwsgi restart
 * Restarting app server(s) uwsgi
[uWSGI] getting INI configuration from /usr/share/uwsgi/conf/default.ini
[uWSGI] parsing config file /etc/uwsgi/apps-enabled/web2py.xml
*./python_plugin.so: cannot open shared object file: No such file or 
directory*
Thu Jun 28 10:07:33 2012 - [WARNING] option "app" is deprecated: use the 
more advanced "mount" option


when in fact python_plugin.so does exist:
# list /usr/lib/uwsgi/plugins
total 128K
lrwxrwxrwx 1 root root   37 Jun 28 09:22 python_plugin.so -> 
/etc/alternatives/uwsgi-plugin-python
-rw-r--r-- 1 root root 127K Feb 20 02:08 python27_plugin.so

Any ideas?
Thanks for your time


[web2py] Container div background

2012-06-28 Thread Kevin Miller
Hi All,


I am using  the Nightly Build with twitter-bootstrap which is fun for the
most part. However I wanted the container to have a white background.
I thought I could just find the div and add the color:#FF; to the div
in the web2py.css file. This has some weird effects. I even tried using
inline CSS as I thought something else in the web2py.css was affected me,
but still the same problem. What I am trying to achieve is this:
I have a static background which is working, but I want the div container
to have a white background. When I tried the above, only some content in
some of my divs is being wiped out.

Any ideas on how I can get the container to be white?


Thanks very much.


Re: [web2py] migrating date to datetime (mysql)

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 8:46 AM, Jonathan Lundell wrote:
> 
> What should I expect? Should it Just Work™, or am I going to have to do a 
> manual conversion?

Answering my own question: works fine, sets the time to 00:00:00

[web2py] Re: Parsing python from db fields?

2012-06-28 Thread RKS
That's fine. I'm sorry for such a dumb mistake. Don't know why I did that. 
Here it is.


Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Richard Vézina
Forget the precedent email... I think I found how, it didn't work the first
time I try, so I just put everything into string, maybe I had problem with
a comma...

inputs_list = []
for a in field1_names_dict:
inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f1',
type='boolean', widget=SQLFORM.widgets.checkboxes.widget,
requires=IS_EMPTY_OR(IS_IN_SET([assay_names_dict[a]['field1_name_ui']]
inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f2',
db.ref_tab1, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab1.id
','%(REPRESENTFIELD)s'
inputs_list.append(Field(field1_names_dict[a]['field1_name']+'_f3',
db.ref_tab2, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab2.id
','%(REPRESENTFIELD)s'

I I just have to add the formstyle in the SQLFORM.factory call :

form = SQLFORM.factory(*inputs_list, formstyle='divs')

On Thu, Jun 28, 2012 at 11:47 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> Hello Anthony,
>
> If I don't use eval(), should I use web2py dummy table, I don't see how I
> will be able to build dummy table dynamically and declare it as inputs_list
> to be use with the asterisk... If I just put a asterisk in front of my
> actual generated inputs_list it not working since the item in the list are
> text. I don't see how I can insert Field into the list without generating
> them as strings...
>
> I will read a bit the links you sent.
>
> Thanks.
>
> Richard
>
>
> On Thu, Jun 28, 2012 at 11:29 AM, Anthony  wrote:
>
>> I wounder what should be the best way to alter a form generated by
>>> SQLFORM.factory in a way where fields will be placed into a html table a 3
>>> columns.
>>>
>>> So each 3 fields I need to insert a "tr" and each field need to be in a
>>> "td"...
>>>
>>
>> You might want to create a custom form layout in the view:
>> http://web2py.com/books/default/chapter/29/7#Custom-forms. That way you
>> can still use SQLFORM.factory to handle all the widget creation and
>> processing, but you can present the fields however you want. You might also
>> check out plugin_solidform .
>>
>> formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"
>>>
>>> form = eval(formstring)
>>>
>>
>> No need to eval code like that in Python. If you have a list of objects
>> you want to submit as separate args to a function, just precede the list
>> with an asterisk:
>>
>> form = SQLFORM.factory(*input_list)
>>
>> In that case, you can change the way you define the Field items in the
>> list -- make them actual Field() objects rather than just strings of code.
>>
>> Note, for keyword arguments, you can submit a dictionary preceded by two
>> asterisks:
>>
>> some_function(**some_dictionary)
>>
>> Anthony
>>
>
>


[web2py] Re: Image Optimization

2012-06-28 Thread Jim S
Just saw this today:  https://github.com/doda/imagy




On Tuesday, June 26, 2012 5:49:43 AM UTC-5, Sanjeet Roy wrote:
>
> Can anyone tell me how can i optimize the image when the user will be 
> uploaded ? Acually i want to create a web application where the user can 
> upload and see the image on the categorization of album.i want optimize 
> image should be appeared in the thumbnail 
>


Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Richard Vézina
Hello Anthony,

If I don't use eval(), should I use web2py dummy table, I don't see how I
will be able to build dummy table dynamically and declare it as inputs_list
to be use with the asterisk... If I just put a asterisk in front of my
actual generated inputs_list it not working since the item in the list are
text. I don't see how I can insert Field into the list without generating
them as strings...

I will read a bit the links you sent.

Thanks.

Richard

On Thu, Jun 28, 2012 at 11:29 AM, Anthony  wrote:

> I wounder what should be the best way to alter a form generated by
>> SQLFORM.factory in a way where fields will be placed into a html table a 3
>> columns.
>>
>> So each 3 fields I need to insert a "tr" and each field need to be in a
>> "td"...
>>
>
> You might want to create a custom form layout in the view:
> http://web2py.com/books/default/chapter/29/7#Custom-forms. That way you
> can still use SQLFORM.factory to handle all the widget creation and
> processing, but you can present the fields however you want. You might also
> check out plugin_solidform .
>
> formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"
>>
>> form = eval(formstring)
>>
>
> No need to eval code like that in Python. If you have a list of objects
> you want to submit as separate args to a function, just precede the list
> with an asterisk:
>
> form = SQLFORM.factory(*input_list)
>
> In that case, you can change the way you define the Field items in the
> list -- make them actual Field() objects rather than just strings of code.
>
> Note, for keyword arguments, you can submit a dictionary preceded by two
> asterisks:
>
> some_function(**some_dictionary)
>
> Anthony
>


[web2py] migrating date to datetime (mysql)

2012-06-28 Thread Jonathan Lundell
What should I expect? Should it Just Work™, or am I going to have to do a 
manual conversion?

Re: [web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Anthony

>
> I wounder what should be the best way to alter a form generated by 
> SQLFORM.factory in a way where fields will be placed into a html table a 3 
> columns.
>
> So each 3 fields I need to insert a "tr" and each field need to be in a 
> "td"...
>

You might want to create a custom form layout in the view: 
http://web2py.com/books/default/chapter/29/7#Custom-forms. That way you can 
still use SQLFORM.factory to handle all the widget creation and processing, 
but you can present the fields however you want. You might also check out 
plugin_solidform .

formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"
>
> form = eval(formstring)
>

No need to eval code like that in Python. If you have a list of objects you 
want to submit as separate args to a function, just precede the list with 
an asterisk:

form = SQLFORM.factory(*input_list)

In that case, you can change the way you define the Field items in the list 
-- make them actual Field() objects rather than just strings of code.

Note, for keyword arguments, you can submit a dictionary preceded by two 
asterisks:

some_function(**some_dictionary)

Anthony


[web2py] Re: long text as content for PluginMModal

2012-06-28 Thread Massimo Di Pierro
very odd? Do they have different python versions?

On Thursday, 28 June 2012 09:55:53 UTC-5, Marco Prosperi wrote:
>
>
> If I open the main page of my web2py application with web2py running on my 
> pc then accented characters are shown correctly but if I open the main page 
> of the copy of my application installed on webfaction server I see 
> mis-rendered accented characters (in both cases I use the same Firefox 
> browser)
>
>
> On Thursday, June 28, 2012 4:44:07 PM UTC+2, Massimo Di Pierro wrote:
>>
>> Online do you mean console/terminal? terminal many not support unicode.
>>
>>



[web2py] Alter SQLFORM.factory generated form to put tag into a table

2012-06-28 Thread Richard Vézina
Hello,

I wounder what should be the best way to alter a form generated by
SQLFORM.factory in a way where fields will be placed into a html table a 3
columns.

So each 3 fields I need to insert a "tr" and each field need to be in a
"td"...

It could be simpler to use FORM instead, but it seems easier until now to
use SQLFORM.factory since it manage all validators and I get generic
widget...

Here some code :

inputs_list = []
for a in field1_names_dict:

inputs_list.append("Field('"+field1_names_dict[a]['field1_name']+'_f1'+"',
type='boolean', widget=SQLFORM.widgets.checkboxes.widget,
requires=IS_EMPTY_OR(IS_IN_SET(['"+assay_names_dict[a]['field1_name_ui']+"'])))")

inputs_list.append("Field('"+field1_names_dict[a]['field1_name']+'_f2'+"',
db.ref_tab1, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab1.id
','%(REPRESENTFIELD)s')))")

inputs_list.append("Field('"+field1_names_dict[a]['field1_name']+'_f3'+"',
db.ref_tab2, requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab2.id
','%(REPRESENTFIELD)s')))")

inputs_list.append("formstyle='divs'")

formstring = "SQLFORM.factory(" +','.join(inputs_list)+")"

form = eval(formstring)

# ALTERING the form...

Thanks for helping.

Just to mention, the form is not bind directly to a table I will parse the
output of the form to insert value in a linking table that contains other
fields information.

Richard


Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Massimo DiPierro
Can I see the code?

On Jun 28, 2012, at 10:08 AM, Daniel González Zaballos wrote:

> It does not work.
> 
> If I use the self.db = 0 sometimes i get this error (and connections are 
> open):
> 
> mod_wsgi (pid=1419): Exception occurred processing WSGI script 
> '/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py'.
> Traceback (most recent call last):
> File 
> "/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py",
>  line 64, in check_password
> close_auth(auth)
> File 
> "/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py",
>  line 68, in close_auth
> auth.close()
> File 
> "/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py",
>  line 97, in close
> self.db.close()
> File "/home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py", line 
> 6343, in __getattr__
>  return self[key]
> File "/home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py", line 
> 6337, in __getitem__
>  return dict.__getitem__(self, str(key))
>  KeyError: 'close'
> 
> With BaseAdapter.close_all_instances('commit') its the same
> 
> 
> El 28/06/12 16:47, Massimo Di Pierro escribió:
>> why not simply?
>> 
>> db.commit()
>> db.close()
>> 
>> if db in an on object attribute like self.db you can do
>> 
>> if self.db:
>>self.db.commit()
>>self.db.close()
>>self.db = 0
>> 
>> you can also do:
>> 
>> BaseAdapter.close_all_instances('commit')
>> 
>> 
>> 
>> On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:
>> 
>> Hi everyone,
>> 
>> I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
>> standalone DAL. When you do a dav petition with the navigator it makes a lot 
>> of petitions. Well, the thing is that always there is a connection opened (i 
>> can see them with PhpMyAdmin)
>> 
>> if self.db: 
>> self.db._adapter.close()
>> 
>> seeing this issue: http://code.google.com/p/web2py/issues/detail?id=731
>> 
>> I have tried a lot of the lines that i found there
>> 
>> something like:
>> 
>> if self.db:
>> from gluon.dal import BaseAdapter
>> BaseAdapter.close_all_instances(None)
>> BaseAdapter.close_all_instances('commit')
>> BaseAdapter.close_all_instances('rollback')
>> 
>> something like:
>> if self.db:
>> from gluon.dal import thread as dal_thread
>> dal_thread.instances.remove(self.db._adapter)
>> self.db._adapter.close()
>> 
>> and even something desesperated like:
>> if self.db:
>> from gluon.dal import thread as dal_thread
>> dal_thread.instances.remove(self.db._adapter)
>> self.db._adapter.close()
>> self.db._adapter.close_all_instances(None)
>> self.db._adapter.close_all_instances('commit')
>> self.db._adapter.close_all_instances('rollback')
>> 
>> from gluon.dal import ConnectionPool
>> ConnectionPool.close_all_instances(None)
>> ConnectionPool.close_all_instances('commit')
>> ConnectionPool.close_all_instances('rollback')
>> 
>> from gluon.dal import BaseAdapter
>> BaseAdapter.close_all_instances(None)
>> BaseAdapter.close_all_instances('commit')
>> BaseAdapter.close_all_instances('rollback')
>> 
>> But always, in the best, it leaves at least one connection opened, and i 
>> don't know how to deal with it.
>> 
>> I have using web2py 1.99.7 in both development and production environments.
>> 
>> Any ideas? in this moment we are building a python mysql script, but we want 
>> to use DAL to make it runnable on any of the web2py/DAL supported db
>> 
>> Thanks in advance
> 
> 



Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Daniel González Zaballos

It does not work.

If I use the self.db = 0 sometimes i get this error (and connections are 
open):


mod_wsgi (pid=1419): Exception occurred processing WSGI script 
'/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py'.

Traceback (most recent call last):
File 
"/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py", 
line 64, in check_password

close_auth(auth)
File 
"/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py", 
line 68, in close_auth

auth.close()
File 
"/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py", 
line 97, in close

self.db.close()
File "/home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py", line 
6343, in __getattr__

 return self[key]
File "/home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py", line 
6337, in __getitem__

 return dict.__getitem__(self, str(key))
 KeyError: 'close'

With BaseAdapter.close_all_instances('commit') its the same


El 28/06/12 16:47, Massimo Di Pierro escribió:

why not simply?

db.commit()
db.close()

if db in an on object attribute like self.db you can do

if self.db:
   self.db.commit()
   self.db.close()
   self.db = 0

you can also do:

BaseAdapter.close_all_instances('commit')



On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:


Hi everyone,

I have connected WebDAV and SVN auth with a wsgi script. I needed
to use a standalone DAL. When you do a dav petition with the
navigator it makes a lot of petitions. Well, the thing is that
always there is a connection opened (i can see them with PhpMyAdmin)

|
if self.db:
self.db._adapter.close()
|

seeing this issue:
http://code.google.com/p/web2py/issues/detail?id=731


I have tried a lot of the lines that i found there

something like:

|
if self.db:
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

something like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
|

and even something desesperated like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
self.db._adapter.close_all_instances(None)
self.db._adapter.close_all_instances('commit')
self.db._adapter.close_all_instances('rollback')

from gluon.dal import ConnectionPool
ConnectionPool.close_all_instances(None)
ConnectionPool.close_all_instances('commit')
ConnectionPool.close_all_instances('rollback')

from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

But always, in the best, it leaves at least one connection opened,
and i don't know how to deal with it.

I have using web2py 1.99.7 in both development and production
environments.

Any ideas? in this moment we are building a python mysql script,
but we want to use DAL to make it runnable on any of the
web2py/DAL supported db

Thanks in advance






[web2py] Re: Parsing python from db fields?

2012-06-28 Thread Anthony
I would actually like to look into this, but the packed application you 
sent was compiled and doesn't include the original uncompiled code. Could 
you instead send the uncompiled version?

Anthony

On Wednesday, June 27, 2012 4:09:45 PM UTC-4, RKS wrote:
>
> Unless you're very curious about this problem I wouldn't try too hard. I'm 
> under a deadline so I just used an if statement to wrap the include file I 
> need and referenced the specific pages inside the if.
>
> Might not be the most elegant way to do things and certainly it falls into 
> the workaround way of doing it, but for now it's what I'm going to do. 
>
> Thanks, both of you, for all your help on this.
>


Re: [web2py] Bug in url parsing / extensions

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 7:29 AM, Corne Dickens wrote:
> There are a few places in the code which are a bit buggy (it looks like code 
> that should be 'changed' already but where skipped)
> 
> It is about parsing the extension from the erquest url. In some places rsplit 
> is used (which is correct) but in other places split is used which can cause 
> problems in some situations.
> Should be nice if this will be fixed in the next release..

Good point.

> 
> diff -u -r web2py/gluon/compileapp.py ../web2py/gluon/compileapp.py   
>  





[web2py] Re: Bug in url parsing / extensions

2012-06-28 Thread Massimo Di Pierro
In trunk too. :-)

On Thursday, 28 June 2012 09:29:35 UTC-5, Corne Dickens wrote:
>
> Hi,
>
> There are a few places in the code which are a bit buggy (it looks like 
> code that should be 'changed' already but where skipped)
>
> It is about parsing the extension from the erquest url. In some places 
> rsplit is used (which is correct) but in other places split is used which 
> can cause problems in some situations.
> Should be nice if this will be fixed in the next release..
>
> diff -u -r web2py/gluon/compileapp.py ../web2py/gluon/compileapp.py   
>  
> --- web2py/gluon/compileapp.py  2012-03-04 23:11:41.0 +0100   
>  
> +++ ../web2py/gluon/compileapp.py   2012-05-01 16:37:18.902869042 +
> 0200
> @@ -128,7 +128,7 @@   
>  
>  attr['_id']=target   
>  
>  request = current.request   
>   
>  if '.' in f: 
>  
> -f, extension = f.split('.',1)   
>   
> +f, extension = f.rsplit('.',1)   
>  
>  if url or ajax: 
>   
>  url = url or URL(request.application, c, f, r=request,   
>  
>   args=args, vars=vars, extension=extension, 
>   
> @@ -235,7 +235,7 @@   
>  
>  attr['_id']=target   
>  
>  request = self.environment['request']   
>   
>  if '.' in f: 
>  
> -f, extension = f.split('.',1)   
>   
> +f, extension = f.rsplit('.',1)   
>  
>  if url or ajax: 
>   
>  url = url or html.URL(request.application, c, f, r=request,  
> 
>args=args, vars=vars, extension=
> extension,  
> diff -u -r web2py/gluon/html.py ../web2py/gluon/html.py   
>  
> --- web2py/gluon/html.py2012-03-04 23:11:41.0 +0100   
>  
> +++ ../web2py/gluon/html.py 2012-05-01 16:35:18.138211870 +0200   
>  
> @@ -266,7 +266,7 @@   
>  
>  else:   
>   
>  function = f 
>  
>  if '.' in function: 
>   
> -function, extension = function.split('.', 1)
> +function, extension = function.rsplit('.', 1)
>
>  function2 = '%s.%s' % (function,extension or 'html')
>
>
>
>
>

[web2py] Re: long text as content for PluginMModal

2012-06-28 Thread Marco Prosperi

If I open the main page of my web2py application with web2py running on my 
pc then accented characters are shown correctly but if I open the main page 
of the copy of my application installed on webfaction server I see 
mis-rendered accented characters (in both cases I use the same Firefox 
browser)


On Thursday, June 28, 2012 4:44:07 PM UTC+2, Massimo Di Pierro wrote:
>
> Online do you mean console/terminal? terminal many not support unicode.
>
>
>>>
>>>

[web2py] Re: import modules

2012-06-28 Thread Niphlod
Ahem
If I install a module using easy_install web2py recognizes it 
correctly (you should use pip, btw)

Maybe you are running two different python version and the easy_installed 
library is on one interpreter and you run web2py with another 
interpreter..

Web2py first looks into modules/ of the application folder, than into 
site-packages/ of web2py folder and then in normal interpreter paths.
so, if you can:

>> python
>> import this

you can also

>>python web2py.py

and call "import this" in your apps.


Il giorno giovedì 28 giugno 2012 16:27:58 UTC+2, Corne Dickens ha scritto:
>
> Hi,
>
> Web2py imports modules from the site-packages directory which is a great 
> way to build a project withoud any 'external' dependencies.
> Only it does not work with modules installed by python easy-install.
>
> Python it's self uses a site module for this, which can be added to web2py 
> in an easy way.
> Maybe this is a nice addition for the next version?
>
> --- web2py/gluon/admin.py   2012-03-04 23:11:41.0 +0100
> +++ ../web2py/gluon/admin.py2012-03-08 12:19:52.0 +0100
> @@ -7,6 +7,7 @@
>  ===   
>  """   
>  import os 
> +import site   
>  import sys
>  import traceback  
>  import zipfile
> @@ -430,6 +431,7 @@
>
>  def add_path_first(path): 
>  sys.path = [path]+[p for p in sys.path if (not p==path and not 
> p==(path+'/'))]
> +site.addsitedir(path) 
> 
>   
>  
>  def create_missing_folders(): 
> 
>  if not global_settings.web2py_runtime_gae:   
>  
>
>
>
>

[web2py] Re: import modules

2012-06-28 Thread Massimo Di Pierro
In trunk. Excellent!

On Thursday, 28 June 2012 09:27:58 UTC-5, Corne Dickens wrote:
>
> Hi,
>
> Web2py imports modules from the site-packages directory which is a great 
> way to build a project withoud any 'external' dependencies.
> Only it does not work with modules installed by python easy-install.
>
> Python it's self uses a site module for this, which can be added to web2py 
> in an easy way.
> Maybe this is a nice addition for the next version?
>
> --- web2py/gluon/admin.py   2012-03-04 23:11:41.0 +0100
> +++ ../web2py/gluon/admin.py2012-03-08 12:19:52.0 +0100
> @@ -7,6 +7,7 @@
>  ===   
>  """   
>  import os 
> +import site   
>  import sys
>  import traceback  
>  import zipfile
> @@ -430,6 +431,7 @@
>
>  def add_path_first(path): 
>  sys.path = [path]+[p for p in sys.path if (not p==path and not 
> p==(path+'/'))]
> +site.addsitedir(path) 
> 
>   
>  
>  def create_missing_folders(): 
> 
>  if not global_settings.web2py_runtime_gae:   
>  
>
>
>
>

Re: [web2py] Re: Multi_tenant

2012-06-28 Thread Massimo Di Pierro
Do me the issue is, should all data always be filtered by hospital.
If there should only be filtered in some cases and not in other, use 
explicit queries
If some tables are always filtered and some are not, you may want to use 
the tenant feature.

On Thursday, 28 June 2012 05:45:13 UTC-5, Ovidio Marinho wrote:
>
> I can not split into separate database, as the management reports need 
> to filter all information. What I need is that the data are shown to 
> hosptal (1) is only seen by him. No problem if all hospitals being in 
> the same database, so is the question of security in view. When the 
> login Hospital (1) is made only data related to hospital (1) should 
> appear on the screen. 
>
>
>
>
>Ovidio Marinho Falcao Neto 
> Web Developer 
>  ovidio...@gmail.com 
>   ovidiomari...@itjp.net.br 
>  ITJP - itjp.net.br 
>83   8826 9088 - Oi 
>83   9334 0266 - Claro 
> Brasil 
>
>
>
> 2012/6/27 Massimo Di Pierro : 
> > I would suggest you use a different database (a different connection 
> string) 
> > for each hospital depending on the hostname. 
> > 
> > .domain.com 
> > import re; regex = re.compile('.*\://(.*?)/.* 
> > db = DAL('postgresq:///%s' % 
> > regex.match(request.env.http_host).group(1)) 
> > 
> > In this way you keep your data separate (which is better for security) 
> and 
> > will allow you scale horizontally by setting up multiple db server 
> > instances. 
> > 
> > 
> > 
> > On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote: 
> >> 
> >> I am making an application to control government medical appointments 
> >> in more than fifty hospitals all use a single postgres database, but 
> >> each hospital must have administrator access, Operator and User, and 
> >> each access must be made with the view of their unique data . 
> >> 
> >> is this. 
> >> 
> >> 
> > 
>


Re: [web2py] Quoting reserved words in DAL

2012-06-28 Thread Niphlod
this is quite complicate to port over all databases, because there are no 
standards for quoting.
I can't really express the issue better than this stackoverflow answer

http://stackoverflow.com/questions/10573922/what-does-the-sql-standard-say-about-usage-of

Il giorno giovedì 28 giugno 2012 16:41:22 UTC+2, Massimo Di Pierro ha 
scritto:
>
> Please upload this in a google code issue.
>
> I see you use the `tablename` syntax in baseadapter. This works for MySQL 
> my I suspect it will break other databases. I cannot find any doc which 
> says this is a standard SQL syntax.
>
> On Wednesday, 27 June 2012 23:56:05 UTC-5, Michael Toomim wrote:
>>
>> Ok, here's one step closer to a fix!
>>
>> This is what had to be manually changed in order to quote the names of 
>> tables/fields to load a postgres database into MySQL.
>>
>> This won't work for other databases. And this only works for *importing 
>> a database*—table creation, with foreign keys, and insert statements. 
>> Nothing else (e.g. selects, updates) was tested. And we had to guide it 
>> manually through the table creation, to get foreign key constraints 
>> satisfied in the right order.
>>
>> But this will show an interested developer exactly where to begin fixing 
>> the code for this bug... that seems to be biting a few of us.
>>
>

[web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Massimo Di Pierro
why not simply?

db.commit()
db.close()

if db in an on object attribute like self.db you can do

if self.db:
   self.db.commit()
   self.db.close()
   self.db = 0

you can also do:

BaseAdapter.close_all_instances('commit')



On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:
>
>
> Hi everyone,
>
> I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
> standalone DAL. When you do a dav petition with the navigator it makes a 
> lot of petitions. Well, the thing is that always there is a connection 
> opened (i can see them with PhpMyAdmin)
>
> if self.db: 
> self.db._adapter.close()
>
> seeing this issue: 
> http://code.google.com/p/web2py/issues/detail?id=731
>
> I have tried a lot of the lines that i found there
>
> something like:
>
> if self.db:
> from gluon.dal import BaseAdapter
> BaseAdapter.close_all_instances(None)
> BaseAdapter.close_all_instances('commit')
> BaseAdapter.close_all_instances('rollback')
>
> something like:
> if self.db:
> from gluon.dal import thread as dal_thread
> dal_thread.instances.remove(self.db._adapter)
> self.db._adapter.close()
>
> and even something desesperated like:
> if self.db:
> from gluon.dal import thread as dal_thread
> dal_thread.instances.remove(self.db._adapter)
> self.db._adapter.close()
> self.db._adapter.close_all_instances(None)
> self.db._adapter.close_all_instances('commit')
> self.db._adapter.close_all_instances('rollback')
>
> from gluon.dal import ConnectionPool
> ConnectionPool.close_all_instances(None)
> ConnectionPool.close_all_instances('commit')
> ConnectionPool.close_all_instances('rollback')
> 
> from gluon.dal import BaseAdapter
> BaseAdapter.close_all_instances(None)
> BaseAdapter.close_all_instances('commit')
> BaseAdapter.close_all_instances('rollback')
>
> But always, in the best, it leaves at least one connection opened, and i 
> don't know how to deal with it.
>
> I have using web2py 1.99.7 in both development and production environments.
>
> Any ideas? in this moment we are building a python mysql script, but we 
> want to use DAL to make it runnable on any of the web2py/DAL supported db
>
> Thanks in advance
>


[web2py] Re: long text as content for PluginMModal

2012-06-28 Thread Massimo Di Pierro
Online do you mean console/terminal? terminal many not support unicode.

On Thursday, 28 June 2012 03:36:43 UTC-5, Marco Prosperi wrote:
>
>
> the first issue is solved by your suggestion, thank you. For the second I 
> still have problems:
> I've created my application using 'welcome' application as template. So I 
> have   in layout.html and @charset "UTF-8"; in 
> base.css.
>
> The strange thing is that if I run the application locally on my WinVista 
> pc the accented characters are shown correctly in the browsser but on line 
> (hosted on webfaction) they are not (although I use the same browser). What 
> do I have to check?
>
> Marco
>
> On Thursday, June 28, 2012 12:47:56 AM UTC+2, Massimo Di Pierro wrote:
>>
>> 1) the newline are respected but not converted into . You have to do 
>> this manually if that is what you want to do.
>>
>> db.table.field.represent=lambda value, row: DIV(*[P(p) for p in 
>> value.split('\n')])
>>
>> 2) check your layout. Perhaps it sends an encoding other than utf8
>>
>>
>>

[web2py] Re: Redirected https is returning HTML instead of JSON. Direct call works fine.

2012-06-28 Thread Massimo Di Pierro
can you show some code and tel us how it expect to behave?

On Thursday, 28 June 2012 02:02:02 UTC-5, Larry Weinberg wrote:
>
> I have a function that returns JSON data.
> It works great when called directly over https (using curl or pycurl).
>
> If however I have a redirect somewhere that sends me to my web2py function 
> it  returns html instead which requests a redirect from the caller.
> I would like it to continue to deliver the JSON.  Is that possible or not 
> allowed ?
>
> It delivers something like this:
> 
> 
> 
> My Title
> 
> 
> https://mysite/myapp/mycontroller/statecheck?state=84b148ce-8960-4393-a5a2-f6e92d6ff169
> ">
>
>
>

Re: [web2py] Quoting reserved words in DAL

2012-06-28 Thread Massimo Di Pierro
Please upload this in a google code issue.

I see you use the `tablename` syntax in baseadapter. This works for MySQL 
my I suspect it will break other databases. I cannot find any doc which 
says this is a standard SQL syntax.

On Wednesday, 27 June 2012 23:56:05 UTC-5, Michael Toomim wrote:
>
> Ok, here's one step closer to a fix!
>
> This is what had to be manually changed in order to quote the names of 
> tables/fields to load a postgres database into MySQL.
>
> This won't work for other databases. And this only works for *importing a 
> database*—table creation, with foreign keys, and insert statements. 
> Nothing else (e.g. selects, updates) was tested. And we had to guide it 
> manually through the table creation, to get foreign key constraints 
> satisfied in the right order.
>
> But this will show an interested developer exactly where to begin fixing 
> the code for this bug... that seems to be biting a few of us.
>


[web2py] Re: Suggestion to add more mod_wsgi info to help new users -- WSGIPassAuthorization for instance

2012-06-28 Thread Massimo Di Pierro
Thank you. I updated setup-web2py-ubuntu.sh and setup-web2py-fedora.sh

On Wednesday, 27 June 2012 20:47:34 UTC-5, Larry Weinberg wrote:
>
> In order to have the web2py examples work out of the box on Apache with 
> mod_wsgi, an extra directive is needed in the Apache configuration for the 
> VirtualHost (or directory, or .htaccess)
>
> WSGIPassAuthorization On
>
> This allows basic authentication to proceed through. 
>
> It looks like there are some good reasons why mod_wsgi in apache strips 
> authorization by default:
> The link to the info is: 
> http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPassAuthorization
>
>
>
>
>
>

[web2py] Bug in url parsing / extensions

2012-06-28 Thread Corne Dickens
Hi,

There are a few places in the code which are a bit buggy (it looks like 
code that should be 'changed' already but where skipped)

It is about parsing the extension from the erquest url. In some places 
rsplit is used (which is correct) but in other places split is used which 
can cause problems in some situations.
Should be nice if this will be fixed in the next release..

diff -u -r web2py/gluon/compileapp.py ../web2py/gluon/compileapp.py 
   
--- web2py/gluon/compileapp.py  2012-03-04 23:11:41.0 +0100 
   
+++ ../web2py/gluon/compileapp.py   2012-05-01 16:37:18.902869042 +0200 
  
@@ -128,7 +128,7 @@ 
   
 attr['_id']=target 
   
 request = current.request 

 if '.' in f:   
   
-f, extension = f.split('.',1) 

+f, extension = f.rsplit('.',1) 
   
 if url or ajax:   

 url = url or URL(request.application, c, f, r=request, 
   
  args=args, vars=vars, extension=extension,   

@@ -235,7 +235,7 @@ 
   
 attr['_id']=target 
   
 request = self.environment['request'] 

 if '.' in f:   
   
-f, extension = f.split('.',1) 

+f, extension = f.rsplit('.',1) 
   
 if url or ajax:   

 url = url or html.URL(request.application, c, f, r=request,   

   args=args, vars=vars, extension=extension
,  
diff -u -r web2py/gluon/html.py ../web2py/gluon/html.py 
   
--- web2py/gluon/html.py2012-03-04 23:11:41.0 +0100 
   
+++ ../web2py/gluon/html.py 2012-05-01 16:35:18.138211870 +0200 
   
@@ -266,7 +266,7 @@ 
   
 else: 

 function = f   
   
 if '.' in function:   

-function, extension = function.split('.', 1)
+function, extension = function.rsplit('.', 1)

 function2 = '%s.%s' % (function,extension or 'html')






[web2py] import modules

2012-06-28 Thread Corne Dickens
Hi,

Web2py imports modules from the site-packages directory which is a great 
way to build a project withoud any 'external' dependencies.
Only it does not work with modules installed by python easy-install.

Python it's self uses a site module for this, which can be added to web2py 
in an easy way.
Maybe this is a nice addition for the next version?

--- web2py/gluon/admin.py   2012-03-04 23:11:41.0 +0100
+++ ../web2py/gluon/admin.py2012-03-08 12:19:52.0 +0100
@@ -7,6 +7,7 @@
 ===   
 """   
 import os 
+import site   
 import sys
 import traceback  
 import zipfile
@@ -430,6 +431,7 @@
   
 def add_path_first(path): 
 sys.path = [path]+[p for p in sys.path if (not p==path and not 
p==(path+'/'))]
+site.addsitedir(path) 


   
 def create_missing_folders(): 

 if not global_settings.web2py_runtime_gae: 
   





Re: [web2py] Form not processed on first submit

2012-06-28 Thread Anthony
Hmm, this is a bit hard to follow, and I don't readily see the problem. 
Somewhere, though, on the initial load, it is creating the form twice but 
displaying the first version in the view (so the _formkey in the view is 
outdated). Looks like the reload also creates the form twice, but it is the 
second one that gets displayed, so the _formkey remains valid. From the 
code you've shown, I don't quite see how that is happening. Also, where is 
gekose_skrywers() called -- don't see any reference to it in the early code 
posted?

Anthony

On Thursday, June 28, 2012 8:59:09 AM UTC-4, Johann Spies wrote:
>
>
>
>
>> In Module:
>>
>>
> Sorry here is the correct code for the function in the module:
>
> def gekose_skrywers(db, ids):
> import pdb
> request = current.request
> session = current.session
> if ids:
> session.ids = ids
> session.skrywers = set([x.uuid for x in (db.akb_authors.id.belongs
> (ids)).select(db.akb_authors.uuid)])
> redirect(URL(r = request, c = 'articles', f = 'add_article'
>  )
> )
> else:
> redirect(URL(r = request, c = 'default', f = 'index'))
> return
>  
>
>  Regards
> Johann
>


Re: [web2py] Routes - simple requirement, but how??

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 5:18 AM, Anthony wrote:
> A controller-name map (or perhaps some generalization of that concept) would 
> be relatively straightforward in the parametric router. Not sure how 
> generally useful it'd be.
> 
> Something like that would be particularly useful when using plugins, as you 
> usually do not want "plugin_" in your URLs (and may generally not like the 
> name the plugin author chose for the plugin).
> 

I was thinking something like: you'd specify a list of duples. Each duple would 
carry the external and internal controller name, thus: 

route_map = [ ('prettyname', 'plugin_ugly'), ],

We could allow function names in the map:

route_map = [ ('prettyname/prettyfunc', 'plugin_ugly/uglyfunc'), ],

(it would be an error to have a function in only half of a duple)

The tricky part: by default, we have controllers = 'DEFAULT', which gets the 
list of valid controllers from the file system, which is to say (in terms of 
the map) the internal controller names. But we need to do incoming routing 
first, and then apply the mapping (otherwise we haven't yet figured out the 
intended a/c/f). To do the incoming routing we need the list of external 
controller names. 

Moreover, I figure that we also want to accept incoming URLs that use the 
internal names, following the principle (in the parametric router, at least) 
that a fully specified URL that works with routing disabled should also work 
with routing enabled.

So I'm thinking: all controller names mentioned in the map are implicitly added 
to the controllers= list.

There might be some other difficulties. Not sure.

[web2py] Re: Installing scheduler on linux

2012-06-28 Thread Tyrone
Hi Guys,

Although this script works great when upstart is available, when upstart is 
not available you can't do it like this. I struggled to find a solution on 
here or anywhere online, so I have made an alternative script which will 
work on sysvinit (/etc/init.d)

#!/bin/sh

DAEMON=/usr/local/bin/python
PARAMETERS="/var/www/html/web2py/web2py.py -K init"
LOGFILE=/var/log/web2py-scheduler.log

start() {
echo -n "starting up $DAEMON"
RUN=`$DAEMON $PARAMETERS > $LOGFILE 2>&1`
if [ "$?" -eq 0 ]; then
echo " Done."
else
echo " FAILED."
fi
}
stop() {
killall $DAEMON
}
status() {
killall -0 $DAEMON
if [ "$?" -eq 0 ]; then
echo "Running."
else
echo "Not Running."
fi
}
case "$1" in
start)
start
;;
restart)
stop
sleep 2
start
;;
stop)
stop
;;
status)
status
;;
*)
echo "usage : $0 start|restart|stop|status"
;;
esac
exit 0

I installed this on CentOS release 5.5, however I needed to follow these 
instructions to install:

1.) # vi web2py-scheduler
2.) Paste in the above
3.) Add in the following 2 lines in the web2py-scheduler file (required for 
centos i believe):

# chkconfig: 2345 90 10
# description: web2py-scheduler

4.) make it executable # chmod 755 web2py-scheduler
5.) add it to startup # chkconfig --add web2py-scheduler


Re: [web2py] URL vs http_referer

2012-06-28 Thread Jonathan Lundell
On Jun 28, 2012, at 3:41 AM, Manuele Pesenti wrote:
> 
> how could it be that this controller returns two different values for url1 
> and url2 if I visit the page through https? Is it correct? I was lookig a way 
> to distinguish in my app the protocoll used for browsing.

If you call URL(scheme=True) it uses request.env.wsgi_url_scheme as the scheme. 
You might take a look at what you're getting there, and also at 
request.is_https. 

In some configurations (mod_proxy, for example) web2py doesn't necessarily know 
the real scheme of the request.

> 
> def test():
>url1 = URL(host=True, scheme=True) # -> http://...
>url2 = request.env.http_referer   # -> https://...
>return locals()
> 
> thanks a lot




[web2py] Re: Multi_tenant

2012-06-28 Thread Cliff Kachinske
If you identify the hospital somehow in the domain name, it's easy.  

As Massimo suggested, .mydomain.com, then

db.define_table('super_secret_hospital_stuff',
  Field('something'),
  Field('request_tenant', default=request.env.http_host)
  ...
)

Be sure to add the same request_tenant field to auth_user as well.  That 
way there's something to match against.

On Wednesday, June 27, 2012 3:48:14 PM UTC-4, Ovidio Marinho wrote:
>
> Procurei isto nas listas todo mundo fala e ninguem esclarece como esta 
> coisa funciona com claridade. 
>
> I tried that lists everyone talks and no one explains how this thing 
> works with clarity. 
>
>
>
>Ovidio Marinho Falcao Neto 
> Web Developer 
>  ovidio...@gmail.com 
>   ovidiomari...@itjp.net.br 
>  ITJP - itjp.net.br 
>83   8826 9088 - Oi 
>83   9334 0266 - Claro 
> Brasil 
>


[web2py] Re: Use of custom CSS, HTML and JS for the view

2012-06-28 Thread Anthony

>
> I am trying to use some custom CSS (web2py.css is not used due to 
> potential conflict), HTML and JS (web2py.js is also not used). Now I wonder 
> how should I tell web2py to link up these custom resources? Do I still have 
> to use layout.html and web2py_ajax.html and modify them accordingly to use 
> the custom stuff?
>

Standard  and 

Re: [web2py] Form not processed on first submit

2012-06-28 Thread Johann Spies



> In Module:
>
>
Sorry here is the correct code for the function in the module:

def gekose_skrywers(db, ids):
import pdb
request = current.request
session = current.session
if ids:
session.ids = ids
session.skrywers = set([x.uuid for x in (db.akb_authors.id.belongs(
ids)).select(db.akb_authors.uuid)])
redirect(URL(r = request, c = 'articles', f = 'add_article'
 )
)
else:
redirect(URL(r = request, c = 'default', f = 'index'))
return
 

 Regards
Johann


[web2py] Use of custom CSS, HTML and JS for the view

2012-06-28 Thread mrtn

Hi,

I am trying to use some custom CSS (web2py.css is not used due to potential 
conflict), HTML and JS (web2py.js is also not used). Now I wonder how 
should I tell web2py to link up these custom resources? Do I still have to 
use layout.html and web2py_ajax.html and modify them accordingly to use the 
custom stuff?

In addition, if we are not using web2py.css and web2py.js, how much impact 
does it have on SQLFROM stuff in the view (e.g. {{=form}})? Thanks.


Re: [web2py] Routes - simple requirement, but how??

2012-06-28 Thread Anthony

>
> A controller-name map (or perhaps some generalization of that concept) 
> would be relatively straightforward in the parametric router. Not sure how 
> generally useful it'd be.
>

Something like that would be particularly useful when using plugins, as you 
usually do not want "plugin_" in your URLs (and may generally not like the 
name the plugin author chose for the plugin).

Anthony 


[web2py] Re: response.menu problem

2012-06-28 Thread Anthony

>
> @auth.requires(lambda: auth.has_membership(ADMIN))
> def router():
> [snip]
> adjustCmsMenu()
> redirect(url)
>

The menu is stored on the response object, which only lives during the 
request. Above, you adjust the menu, but then immediately redirect, which 
starts a new request (and therefore discards the current response). 
Instead, maybe you should store the menu in the session if you want it to 
survive across requests.

Anthony


Re: [web2py] Form not processed on first submit

2012-06-28 Thread Anthony
Probably need to see more code -- for grid page, component, and add_article.

On Thursday, June 28, 2012 5:29:40 AM UTC-4, Johann Spies wrote:
>
>
>
> On Wednesday, 27 June 2012 17:51:44 UTC+2, Anthony wrote:
>>
>> Perhaps form.process() is failing the first time because the _formkey in 
>> the session isn't matching for some reason (don't know why, though).
>>>
>>>
>>>
> Anthony, I have investigated by putting a 'print session'  in the 
> controller and found this:
>
> First time:
>
> Firebug shows:
> 
>  "_formkey">
> 
>
>
> And the 'print session'  revealed:
>
>  'e502ec08-acf2-4b4e-ab93-7449c52efa97'}>
>  'e502ec08-acf2-4b4e-ab93-7449c52efa97'}>
>  '3e834837-f578-45b4-9cc6-8105a7c9bacf'}>
>
>
> Then I reloaded
>
> Firebug:
>
> 
>  "_formkey">
> 
>
> And the session:
>
>  '3e834837-f578-45b4-9cc6-8105a7c9bacf'}>
>  '6aed7bbb-0523-47ba-a83f-fb25931559cd'}> 
>
> The history: 
>
> From a component (selectable grid) in another screen, the submit button 
> was clicked and a function in a module called which did the following:
>
> def gekose_skrywers(db, ids):
> import pdb
> request = current.request
> session = current.session
> if ids:
> session.ids = ids
> session.skrywers = set([x.uuid for x in db(db.akb_authors.id.
> belongs(ids)).select(db.akb_authors.uuid)])
> redirect(URL(r = request, c = 'articles', f = 'add_article'
>  )
> )
> else:
> redirect(URL(r = request, c = 'default', f = 'index'))
> return
>
> How do I find out where that last _formkey in before the reload comes from?
>
> Regards
> Johann
>
>

Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-28 Thread Anthony

>
> > Anyway, you might be better off looking into using the scheduler, or a 
> > third-party task queue like Celery (a web2py Celery plugin was started 
> at 
> > some point, though not sure it is complete). 
>
> I don't understand, how will that let me do a read-modify-update 
> transaction? It seems as if for_update is precisely what I need to do 
> that.
>

I thought your original goal was to set up a task queue -- those 
suggestions are specialized for that purpose.

Anthony


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-28 Thread Doug Philips
On Thu, Jun 28, 2012 at 1:02 AM, Jonathan Lundell  wrote:
> The SQLite adapter simulates select for update by wrapping the select+update
> in a transaction. Not too efficient, since it has to lock the entire
> database, but it'll do it.

Thanks, I wish it worked in the released version, and I'm hopeful that
it can be made to work in the next version!
-=D


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-28 Thread Doug Philips
On Thu, Jun 28, 2012 at 12:08 AM, Anthony  wrote:
> SQLite is a file-based database, so has to have more course locking than a
> typical client/server database. Other databases have "select for update"
> functionality, which allows you to select a set of records and lock them.
> web2py actually supports this, via .select(..., for_update=True).

Thanks, "for_update" is not documented in The Book, but is exactly
what I am looking for.

Checking the gluon code for Version 1.99.7 (2012-03-04 22:12:08) stable
shows that SQLite tries to support 'for_update', unfortunately it
doesn't work (causes an exception). So far as I could tell by
searching, that wasn't already reported so I created a new issue:
http://code.google.com/p/web2py/issues/detail?id=864 for it.

> Anyway, you might be better off looking into using the scheduler, or a
> third-party task queue like Celery (a web2py Celery plugin was started at
> some point, though not sure it is complete).

I don't understand, how will that let me do a read-modify-update
transaction? It seems as if for_update is precisely what I need to do
that.

Thanks,
-Doug


Re: [web2py] Re: Multi_tenant

2012-06-28 Thread Ovidio Marinho
I can not split into separate database, as the management reports need
to filter all information. What I need is that the data are shown to
hosptal (1) is only seen by him. No problem if all hospitals being in
the same database, so is the question of security in view. When the
login Hospital (1) is made only data related to hospital (1) should
appear on the screen.




       Ovidio Marinho Falcao Neto
                Web Developer
             ovidio...@gmail.com
          ovidiomari...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil



2012/6/27 Massimo Di Pierro :
> I would suggest you use a different database (a different connection string)
> for each hospital depending on the hostname.
>
> .domain.com
> import re; regex = re.compile('.*\://(.*?)/.*
> db = DAL('postgresq:///%s' %
> regex.match(request.env.http_host).group(1))
>
> In this way you keep your data separate (which is better for security) and
> will allow you scale horizontally by setting up multiple db server
> instances.
>
>
>
> On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote:
>>
>> I am making an application to control government medical appointments
>> in more than fifty hospitals all use a single postgres database, but
>> each hospital must have administrator access, Operator and User, and
>> each access must be made with the view of their unique data .
>>
>> is this.
>>
>>
>


[web2py] URL vs http_referer

2012-06-28 Thread Manuele Pesenti
how could it be that this controller returns two different values for 
url1 and url2 if I visit the page through https? Is it correct? I was 
lookig a way to distinguish in my app the protocoll used for browsing.


def test():
url1 = URL(host=True, scheme=True) # -> http://...
url2 = request.env.http_referer   # -> https://...
return locals()

thanks a lot

Manuele


Re: [web2py] Standalone DAL leaves mysql connections opened

2012-06-28 Thread Daniel González Zaballos
A little bump in this topic. Somebody has any idea of how use standalone 
dal without leaving connections opened?


BR
Daniel

El 22/06/12 18:23, demetrio escribió:


Hi everyone,

I have connected WebDAV and SVN auth with a wsgi script. I needed to 
use a standalone DAL. When you do a dav petition with the navigator it 
makes a lot of petitions. Well, the thing is that always there is a 
connection opened (i can see them with PhpMyAdmin)


|
if self.db:
self.db._adapter.close()
|

seeing this issue: 
http://code.google.com/p/web2py/issues/detail?id=731 



I have tried a lot of the lines that i found there

something like:

|
if self.db:
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

something like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
|

and even something desesperated like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
self.db._adapter.close_all_instances(None)
self.db._adapter.close_all_instances('commit')
self.db._adapter.close_all_instances('rollback')

from gluon.dal import ConnectionPool
ConnectionPool.close_all_instances(None)
ConnectionPool.close_all_instances('commit')
ConnectionPool.close_all_instances('rollback')

from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

But always, in the best, it leaves at least one connection opened, and 
i don't know how to deal with it.


I have using web2py 1.99.7 in both development and production 
environments.


Any ideas? in this moment we are building a python mysql script, but 
we want to use DAL to make it runnable on any of the web2py/DAL 
supported db


Thanks in advance
--





Re: [web2py] DAL performance vs executesql

2012-06-28 Thread Johann Spies
On 27 June 2012 03:34, Anthony  wrote:

> I wish it was possible to use other time-saving tools like SQLFORM.grid
>> with db.executesql().
>>
>> At the moment most of the representation tools like SQLTABLE and
>> plugin_wiki's jqgrid suppose DAL usage.
>>
>
> This wouldn't help with SQLFORM.grid, which does its own query, but for
> other cases where you need a Rows object with executesql, this might work:
>
> raw_rows = db.executesql('[SQL code]')
> rows = db._adapter.parse(raw_rows,
> fields=[db.mytable[f] for f in db.mytable.fields],
> colnames=db.mytable.fields)
>
>
Thanks.  This help a little bit.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Form not processed on first submit

2012-06-28 Thread Johann Spies


On Wednesday, 27 June 2012 17:51:44 UTC+2, Anthony wrote:
>
> Perhaps form.process() is failing the first time because the _formkey in 
> the session isn't matching for some reason (don't know why, though).
>>
>>
>>
Anthony, I have investigated by putting a 'print session'  in the 
controller and found this:

First time:

Firebug shows:





And the 'print session'  revealed:






Then I reloaded

Firebug:





And the session:


 

The history: 

>From a component (selectable grid) in another screen, the submit button was 
clicked and a function in a module called which did the following:

def gekose_skrywers(db, ids):
import pdb
request = current.request
session = current.session
if ids:
session.ids = ids
session.skrywers = set([x.uuid for x in db(db.akb_authors.id.belongs
(ids)).select(db.akb_authors.uuid)])
redirect(URL(r = request, c = 'articles', f = 'add_article'
 )
)
else:
redirect(URL(r = request, c = 'default', f = 'index'))
return

How do I find out where that last _formkey in before the reload comes from?

Regards
Johann



[web2py] Re: response.menu problem

2012-06-28 Thread Annet
I made some adjustments:

In menu.py:

def adjustCmsMenu():
response.cms_menu = [['Home',request.controller=='cms' and 
request.function=='index',URL('cms','index')]]
if session.cmsadmin_menu:

response.cms_menu.append(['Admin',request.controller=='cmsadmin',URL('cmsadmin','index')])
if session.cmsnode_menu:

response.cms_menu.append(['Basis',request.controller=='cmsnode',URL('cmsnode','index')])
if session.cmssite_menu:

response.cms_menu.append(['Site',request.controller=='cmssite',URL('cmssite','index')])
if session.cmsabout_menu:

response.cms_menu.append(['Over',request.controller=='cmsabout',URL('cmsabout','index')])
if session.cmscalendar_menu:

response.cms_menu.append(['Kalender',request.controller=='cmscalendar',URL('cmscalendar','index')])

def nullify():

session.authnodeID=session.authnodename=session.vcardsettings=session.sitesettings=\
session.aboutsettings=session.calendarsettings=[]

session.cmsadmin_menu=session.cmsnode_menu=session.cmssite_menu=session.cmsabout_menu=session.cmscalendar_menu=False


In cms.py

def index():
nullify()
adjustCmsMenu()
...
return dict()

In cmsadmin.py

def index():
nullify()
session.cmsadmin_menu=True
adjustCmsMenu()
...
return dict()

def router():
if not len(request.args):
url=URL('cmsadmin','index')
elif len(request.args) or session.authnodeID!=request.args(0):
nullify()
session.cmsadmin_menu=True
session.authnodeID=request.args(0)
row=db(db.Node.id==request.args(0)).select(db.Organization.name,\
left=db.Organization.on(db.Node.id==db.Organization.nodeID)).first()
if row.name:
session.authnodename=row.name
session.cmsnode_menu=True
url=URL('cmsnode','index')

rows=db((db.auth_user.nodeID==session.authnodeID)&(db.auth_user.id==db.auth_membership.user_id))\
.select(db.auth_membership.group_id)
if rows:
for r in rows:
if r.group_id==VCARDGROUPID:
session.cmssite_menu=True
setVCardSettings()
if r.group_id==SITEGROUPID:
session.cmssite_menu=True
setSiteSettings()
if r.group_id==ABOUTGROUPID:
session.cmsabout_menu=True
setAboutSettings()
if r.group_id==CALENDARGROUPID:
session.cmscalendar_menu=True
setCalendarSettings()
adjustCmsMenu()
redirect(url)
return None

And in cms.node.py, csmsite.py, cmsabout.py and cmscalendar.py outside any 
function: adjustCmsMenu()

The whole menu system now works as intended, but I still wonder whether 
there is a way to code this without having to call adjustCmsMenu for every 
request. I tried session.cms_menu but than I lose the menu's state.


Kind regards,

Annet


[web2py] Re: long text as content for PluginMModal

2012-06-28 Thread Marco Prosperi

the first issue is solved by your suggestion, thank you. For the second I 
still have problems:
I've created my application using 'welcome' application as template. So I 
have   in layout.html and @charset "UTF-8"; in 
base.css.

The strange thing is that if I run the application locally on my WinVista 
pc the accented characters are shown correctly in the browsser but on line 
(hosted on webfaction) they are not (although I use the same browser). What 
do I have to check?

Marco

On Thursday, June 28, 2012 12:47:56 AM UTC+2, Massimo Di Pierro wrote:
>
> 1) the newline are respected but not converted into . You have to do 
> this manually if that is what you want to do.
>
> db.table.field.represent=lambda value, row: DIV(*[P(p) for p in 
> value.split('\n')])
>
> 2) check your layout. Perhaps it sends an encoding other than utf8
>
>
>

[web2py] web2py Application Development Cookbook

2012-06-28 Thread Alec Taylor
Mine finally arrived in the mail!

:D


Re: [web2py] Re: SQLdesigner still down for maintenance?

2012-06-28 Thread Alec Taylor
Thanks :)

On Thu, Jun 28, 2012 at 8:58 AM, Massimo Di Pierro
 wrote:
> Sorry I forgot. it is up.
>
> On Wednesday, 27 June 2012 11:48:05 UTC-5, Alec Taylor wrote:
>>
>> I remember trying out the designer when I first started using web2py,
>> but wanted to improve my web2py knowledge before using it (especially
>> how to do n+1 unrolling).
>>
>> I tried to access it about a week ago, but it was down.
>>
>> Just tried now, it still seems down.
>>
>> Can I assist somehow with the maintenance in order to get the designer
>> back up again?
>>
>> All the best,
>>
>> Alec Taylor


[web2py] Re: static files extending layout.html

2012-06-28 Thread Annet


> Me neither but look into routes.
>

Indeed, the problem was caused by an incorrect routes, thanks for pointing 
me in that direction.


Kind regards,

Annet. 


[web2py] response.menu problem

2012-06-28 Thread Annet
In menu.py  I have the following code:

response.cms_menu = [['Home',request.controller=='cms' and 
request.function=='index',URL('cms','index')]]

def adjustCmsMenu():
if session.cmsadmin_menu:

response.cms_menu.append(['Admin',request.controller=='cmsadmin',URL('cmsadmin','router')])
if session.cmsnode_menu:

response.cms_menu.append(['Basis',request.controller=='cmsnode',URL('cmsnode','index')])
if session.cmssite_menu:

response.cms_menu.append(['Site',request.controller=='cmssite',URL('cmssite','index')])
if session.cmsabout_menu:

response.cms_menu.append(['About',request.controller=='cmsabout',URL('cmsabout','index')])
if session.cmscalendar_menu:

response.cms_menu.append(['Calendar',request.controller=='cmscalendar',URL('cmscalendar','index')])


In a controller outside any function I have the following code:

session.cmsadmin_menu=True
adjustCmsMenu()

In a function called router I have:

@auth.requires(lambda: auth.has_membership(ADMIN))
def router():

session.authnodeID=session.authnodename=session.vcardsettings=session.sitesettings=\
session.aboutsettings=session.calendarsettings=[]

session.cmsnode_menu=session.cmssite_menu=session.cmsabout_menu=session.cmscalendar_menu=False
if not len(request.args):
redirect(URL('cmsadmin','index'))
elif len(request.args) or session.authnodeID!=request.args(0):
session.authnodeID=request.args(0)
row=db(db.Node.id==request.args(0)).select(db.Organization.name,\
left=db.Organization.on(db.Node.id==db.Organization.nodeID)).first()
if row.name:
session.authnodename=row.name
session.cmsnode_menu=True
url=URL('cmsnode','index')

rows=db((db.auth_user.nodeID==session.authnodeID)&(db.auth_user.id==db.auth_membership.user_id))\
.select(db.auth_membership.group_id)
if rows:
for r in rows:
if r.group_id==VCARDGROUPID:
session.cmssite_menu=True
setVCardSettings()
if r.group_id==SITEGROUPID:
session.cmssite_menu=True
setSiteSettings()
if r.group_id==ABOUTGROUPID:
session.cmsabout_menu=True
setAboutSettings()
if r.group_id==CALENDARGROUPID:
session.cmscalendar_menu=True
setCalendarSettings()
adjustCmsMenu()
redirect(url)
return None

The problem is that the first call to adjustCmsMenu() , the one outside any 
function, does work, however, the one inside the router function doesn't 
work. The items aren't appended to response.cms_menu

When I put the response.cms_menu.append() outside the function:

response.cms_menu = [['Home',request.controller=='cms' and 
request.function=='index',URL('cms','index')]]
if session.cmsadmin_menu:

response.cms_menu.append(['Admin',request.controller=='cmsadmin',URL('cmsadmin','router')])
if session.cmsnode_menu:

response.cms_menu.append(['Basis',request.controller=='cmsnode',URL('cmsnode','index')])
if session.cmssite_menu:

response.cms_menu.append(['Site',request.controller=='cmssite',URL('cmssite','index')])
if session.cmsabout_menu:
response.cms_menu.append(['Over 
ons/mij',request.controller=='cmsabout',URL('cmsabout','index')])
if session.cmscalendar_menu:

response.cms_menu.append(['Kalender',request.controller=='cmscalendar',URL('cmscalendar','index')])

The cms_menu displays alright, but I am always one step behind with the 
items that should and shouldn't be displayed. Why doesn't this work?


Kind regards,

Annet.



[web2py] Redirected https is returning HTML instead of JSON. Direct call works fine.

2012-06-28 Thread Larry Weinberg
I have a function that returns JSON data.
It works great when called directly over https (using curl or pycurl).

If however I have a redirect somewhere that sends me to my web2py function 
it  returns html instead which requests a redirect from the caller.
I would like it to continue to deliver the JSON.  Is that possible or not 
allowed ?

It delivers something like this:



My Title


https://mysite/myapp/mycontroller/statecheck?state=84b148ce-8960-4393-a5a2-f6e92d6ff169";>