[web2py] R: How to insert icons into a column of a table created using SQLTABLE()

2011-08-17 Thread Valter Foresto
To further explain my requirements and request for suggestions:
*How can I exchange few different text values with few different small 
images in a SQLTABLE() object before send it to the view. *

Thank you for your help.
Valter   



[web2py] Re: Postgresql 9.0 problem.

2011-08-17 Thread annet
Hi Richard,

I did as you suggested and that solved the problem, thanks.


Kind regards,

Annet.

> Did you set your pg_hba.conf and postgresql.conf...
>
> These lines at least :
>
> pg_hba.conf :
>
> host    all         all         *127.0.0.1*/24          md5
>
> postgresql.conf :
>
> listen_addresses = '***' # Don't remember original value...
>
> ssl =* true or false *


[web2py] Re: Use of SSL in web2py fails in firefox (missing intermediary cert)

2011-08-17 Thread Markus Schmitz
After some more research yesterday night, I think I found the solution
to my problem:

As mentioned Verisign is using an intermediate certificate. You can
find more information on the topic, if searching for "chained
certificates". The solution is not only to have your own private
certificate in the crt file, but also the intermediate. These are just
plain text files, which can be copied-and-pasted in a text editor.
Important here is the order, first the private, than the intermediate.

After this things are working fine.



[web2py] Re: No spaces... now that would be nice...

2011-08-17 Thread encompass
I just wanted to start some discussion about it, as I am programming
in Django at my work and ran across the feature.  I know 3 or 4 places
off hand that could use this feature in our current django project and
it makes the templates look a lot cleaner.


On Aug 17, 3:04 pm, Ross Peoples  wrote:
> I've only run in to this issue once where I had a toolbar that would break
> if I put each button on its own line. So I just put everything on one line.
> There are only 3 or 4 buttons, so it's not that big of a deal, but I could
> see where this could be an issue in some cases. However, I'm not sure if
> this would be the right way to fix such a problem.


Re: [web2py] Re: proper usage of exclusive_domain = True ?

2011-08-17 Thread Jonathan Lundell
On Aug 17, 2011, at 4:29 PM, vapirix wrote:

> That would be truly excellent.
> 
> It would change the way I do a lot of stuff. Right now I am forced to
> use php for a lot of small little apps that I don't want to surrender
> an entire web2py install for. =D

The problem is that exclusive_domain is enforced for URL(), but not for 
incoming requests. That's actually how it's documented:

> #  exclusive_domain: If True (default is False), an exception is raised if an 
> attempt is made to generate
> #an outgoing URL with a different application without 
> providing an explicit host.


It's easy to extend to incoming apps, but I'd like to be sure of the rule that 
gets enforced. I think the rule should be: if exclusive_domain is True for a 
given app (either because it's set True in the base router or in an 
app-specific router), then that app will only recognized if the incoming domain 
(and possibly port) matches one mapped to that app in the domains dictionary. 
If it doesn't match, we'd raise a 400 invalid request/invalid application error.


BTW, you can share a web2py installation across completely separate app 
installs, by creating a separate applications/ directory for each app, and 
starting web2py with the --folder option, once for each app. I'm not sure how 
you'd configure wsgi for this kind of thing, but it'd be easy enough (I think) 
with mod_proxy.


> 
> On Aug 17, 4:01 pm, Jonathan Lundell  wrote:
>> Sounds like a bug in exclusive_domain. I'll look at it when I get home later.
>> 
>> On Aug 17, 2011, at 12:57 PM, vapirix  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> OR can maybe somebody point me in a different direction to achieve the
>>> same thing without a hilariously complicated config process that I
>>> won't want to do every time? =)
>> 
>>> On Aug 16, 5:07 pm, vapirix  wrote:
 So I'm attempting to set up the usage scenario of:
>> 
 domain1.com -> load app 1
 domain2.com -> load app 2
 etc. etc.
>> 
 I need domain1 to NOT have access to app 2, 3, 4, 5, etc.
>> 
 That all works using the router's "domain" settings. Obviously you run
 into the problem of: domain1.com loads app1, but domain1.com/app2
 loading app2, so I use "exclusive_domain = True", and then I have to
 do domain1.com/app1/ to load the app without raising an exception,
 which seems counter productive. Besides that, even with
 exclusive_domain = True, I can do domain1.com/app2 to load the second
 app. Is there any way to do what I'm attempting to do here? I'd rather
 not have to set up separate web2py installs for the tons of tiny apps
 I do for my clients that get 1 hit every 6 months.
>> 
 What can I do here, friends?




[web2py] Re: dowloading attachments with AJAX

2011-08-17 Thread mart
HI Mic!

This is fantastic! Thanks for the info! :)

On Aug 17, 6:33 pm, Michele Comitini 
wrote:
> Hi Mart!
>
> Copy sample code in my previous mail.
>
> to test quicly you cat put the view code somewhere in
> /welcome/views/default/index.html
>
> {{=A(T('be brave!'), _onclick="ajax('%s',[],':eval');" %
> URL('gen_pdf'), _class='button')}}
>
> copy the function gen_pdf() in /welcome/controllers/default.py
>
>  def gen_pdf():
>      from gluon.contrib.pyfpdf import FPDF
>
>      pdf=FPDF()
>      pdf.add_page()
>      pdf.set_font('Arial','B',16)
>      pdf.cell(40,10,'Hello World at %s!' % request.now)
>      doc=pdf.output(dest='S')
>
>      doc64=embed64(data=doc,extension='application/pdf')
>
>      return 'window.location="%s";' % doc64
>
> No need for other code. The trick is all in the use of 'data:' URI
> that is created by embed64()
>
> ok now URL('gen_pdf()') calls gen_pdf() in the controller that
> generates the pdf on the fly and posts it back to the browser.
> All in one pass, no session no temporary files around, no form, no GET...
>
> ;-)
>
> mic
>
> 2011/8/16 mart :
>
>
>
>
>
>
>
> > Hi Mic!
>
> > This is very interesting! :) how does it work?  you have
> > "URL('gen_pdf')", what is that referencing?
>
> > would you have a model/sample app that we could peek at? :)
>
> > Thanks,
> > Mart :)
>
> > On Aug 15, 4:47 pm, Michele Comitini 
> > wrote:
> >> Suppose you want to make an AJAX call that starts a file download.
> >> How can you do that?
> >> 1. form submission
> >> 2. a element href
> >> 3. iframe
>
> >> Too complex!
>
> >> of course *web2py* comes to rescue...
> >> BIG NOTE: the following is based on 'data:' url type and was tested
> >> only on FF and chrome. I do not have
> >>  IE but I suppose that  is not compatible with the standard!
>
> >> In your view put a web2py ajax call similar to the following wherever
> >> you need it:
>
> >> ajax('%s',[],':eval');" % URL('gen_pdf')
>
> >> ex.
>
> >> {{=A(T('be brave!'), _onclick="ajax('%s',[],':eval');" %
> >> URL('gen_pdf'), _class='button')}}
>
> >> in the controller use embed64.
>
> >> def gen_pdf():
> >>     from gluon.contrib.pyfpdf import FPDF
>
> >>     pdf=FPDF()
> >>     pdf.add_page()
> >>     pdf.set_font('Arial','B',16)
> >>     pdf.cell(40,10,'Hello World at %s!' % request.now)
> >>     doc=pdf.output(dest='S')
>
> >>     doc64=embed64(data=doc,extension='application/pdf')
>
> >>     return 'window.location="%s";' % doc64
>
> >> have fun!
>
> >> mic


Re: [web2py] Re: CAS Auth redirect loop

2011-08-17 Thread Anthony
Hmm, it appears to have something to do with the fact that you've got a 
custom auth_user table, but I can't figure out what. Maybe Massimo can help.
 
Anthony

On Wednesday, August 17, 2011 4:19:58 PM UTC-4, Bruno Codeman wrote:

> Everytime I click the login button, I receive a message from firefox/chrome 
> with a 310 error(too_many_redirects) telling me to delete the cookies
> or allow third-party cookies. I have an app called "login"(the CAS Server) 
> and another one called "ControleDeAtivos"(which should use the other app as 
> a cas provider). Everything's going fine on the client app. When I click the 
> "login" link(on the menu), I'm redirected to the cas server app login 
> page,and after click the submit button, the browser shows the message. The 
> URL showing on browser is this: *
> http://172.16.7.10:8000/ControleDeAtivos/default/user/login?_next=%2FControleDeAtivos%2Fdefault%2Findex
> *
>
> The db.py file is attached.
>
> 2011/8/17 Anthony 
>
>> Can you show some minimal code that reproduces the problem?
>>
>> On Wednesday, August 17, 2011 3:56:32 PM UTC-4, Bruno Codeman wrote:
>>
>>> Anyone? The app is entering a redirecting loop everytime I try to 
>>> authenticate...
>>>
>>> 2011/8/17 Bruno de Oliva Bemfica 
>>>
 Hi again, everyone. Does anyone know why a CAS auth could be entering a 
 loop redirect?

 -- 
 Bruno de Oliva Bemfica
 *Engenheiro de Software*

 MSN: brun...@live.com

 Mobile: +55 11 8457-0978
 http://www.devfranca.com.br
 http://www.brunobemfica.net
 http://www.codigofree.net


>>>
>>>
>>> -- 
>>> Bruno de Oliva Bemfica
>>> *Engenheiro de Software*
>>>
>>> MSN: brun...@live.com
>>>
>>> Mobile: +55 11 8457-0978
>>> http://www.devfranca.com.br
>>> http://www.brunobemfica.net
>>> http://www.codigofree.net
>>>
>>>
>
>
> -- 
> Bruno de Oliva Bemfica
> *Engenheiro de Software*
> MSN: brunoc...@live.com
> Mobile: +55 11 8457-0978
> http://www.devfranca.com.br
> http://www.brunobemfica.net
> http://www.codigofree.net
>


[web2py] queries on a firebird database

2011-08-17 Thread dnlarp
Hi all,

My first post... I'm reading the book at the beginning so i'm very
noob on web2py and may intent is to create a simple system that do
queries only on a huge existent firebird database for mobile devices.
This database is in prodution on a php framework for web users.

So, is possible to work on a system in other server that just connect
via internet in the database of the other server and just do queries
WITHOUT change anything in the database? I want to do some tests
locally first, so...

May progress is: I already install the proper version of kinterbase
and python. And ran web2py by the source without error.

My issues are:
- I couldn t connect locally on the backup file 'mydatabase.fdb'.
Which folder should I put? and it have the '@' char on the password
that may confusing the connect line. How can I deal with it, without
changing it? And after, if is possible, how will stay the line to
connect remotely to the other server in prodution?

-Some samples of detailed sql queries are welcome...


Thank you

Daniel


[web2py] Re: custom_import weirdness ?

2011-08-17 Thread Anthony
What version of Python is on the server?

On Wednesday, August 17, 2011 7:58:26 PM UTC-4, Niphlod wrote:

> Hi all, I have a problem deploying my app to a VPS. 
>
> I created an app with linkedin support, using 
> https://github.com/mrgaaron/LinkedIn-Client-Library . 
> Just to avoid to install this module systemwide, I put it under myapp/ 
> modules folder. 
>
> myapp 
>   - modules 
> - liclient 
> - __init__.py (containing class LinkedInAPI) 
>
> Now, the weird part: in a model I defined some helper functions, that 
> I call later on some controllers. 
> In these,  I call "from liclient import LinkedInAPI" . 
> All is working fine on the local system, but in the VPS - an exact 
> copy of the local environment - this call throws an exception. 
>
> Traceback (most recent call last): 
>   File "/home/niphlod/production/web2py/gluon/restricted.py", line 
> 192, in restricted 
> exec ccode in environment 
>   File "/home/niphlod/production/web2py/applications/whoisper/models/ 
> default/linkedin_helpers.py", line 25, in  
> from liclient import LinkedInAPI 
>   File "/home/niphlod/production/web2py/gluon/custom_import.py", line 
> 280, in __call__ 
> fromlist, level) 
>   File "/home/niphlod/production/web2py/gluon/custom_import.py", line 
> 74, in __call__ 
> level) 
> ImportError: No module named liclient 
>
> Am I doing something wrong? Any hints or tips ? 
>
> PS: in the local system the library is not installed, i.e. if I open a 
> python shell and type "from liclient import LinkedInAPI" response is 
> "ImportError: No module named liclient". The same thing happens in the 
> VPS. 
>
> sys.path is the same for the local and the VPS system. 
>
>

Re: [web2py] [OFF] what-should-a-developer-know-before-building-a-public-web-site

2011-08-17 Thread Bruno da Silva Assis
Pretty good!
It's very useful as a checklist also, even for experienced programmers.
Sometimes you just don't remember EVERYTHING right from the start in a
project.

--

*Bruno Assis*
São Paulo - SP
+55 11 9269-9914
Twitter - @BrunoAssis 


On Wed, Aug 17, 2011 at 3:41 AM, Bruno Rocha  wrote:

> useful reading
>
>
> http://programmers.stackexchange.com/questions/46716/what-should-a-developer-know-before-building-a-public-web-site
>


[web2py] Re: extend (add methods, not subclass) web2py classes

2011-08-17 Thread pbreit
OK, thanks. Is that a reasonable aspiration or does the current architecture 
not really lend itself to such?

[web2py] Re: Integer representation in mySQL

2011-08-17 Thread pbreit
Looks like no bigger integers:
http://web2py.com/book/default/chapter/06#Record-Representation

Unless you're going to perform a lot of math on the numbers, string is 
probably better anyway.


[web2py] Integer representation in mySQL

2011-08-17 Thread ram
I am writing an application to capture tweets (home_timeline) for an
analysis - to check what my followers are reading, etc. I use the
following DB structure to capture the  max_id to use it in my next
request:

db.define_table("MaxID",
Field("max_id", type='integer', notnull=True),
Field('modified_on', type='datetime', notnull=True,
default=request.now))

The status_id of a tweet is 103502712657813505

In SQLite, and in GAE (both development and production), it is stored
as long integer.

In mySQL, the max_id field is translated as of type int(11)" and the
signed value it could hold is between -2147483648 and  2147483647 and
the unsigned is 4294967295. Hence when I try to store the value
103502712657813505, it will be stored 2147483647.

One option could be - one could use string type and convert back and
forth for max_id or update the Field type in MySQL.

Since I encountered this problem, I thought I will bring this to the
notice of everyone

Is there a way to define BIGINT in DAL?

Thanks
Best
Ram


[web2py] Re: web2py on OSX - Uses CPU when idling

2011-08-17 Thread ecafracs
Looking around it would seem I should be running from source.

I'll do that, give it a try & post an update.

Thanks.


[web2py] custom_import weirdness ?

2011-08-17 Thread Niphlod
Hi all, I have a problem deploying my app to a VPS.

I created an app with linkedin support, using
https://github.com/mrgaaron/LinkedIn-Client-Library .
Just to avoid to install this module systemwide, I put it under myapp/
modules folder.

myapp
  - modules
- liclient
- __init__.py (containing class LinkedInAPI)

Now, the weird part: in a model I defined some helper functions, that
I call later on some controllers.
In these,  I call "from liclient import LinkedInAPI" .
All is working fine on the local system, but in the VPS - an exact
copy of the local environment - this call throws an exception.

Traceback (most recent call last):
  File "/home/niphlod/production/web2py/gluon/restricted.py", line
192, in restricted
exec ccode in environment
  File "/home/niphlod/production/web2py/applications/whoisper/models/
default/linkedin_helpers.py", line 25, in 
from liclient import LinkedInAPI
  File "/home/niphlod/production/web2py/gluon/custom_import.py", line
280, in __call__
fromlist, level)
  File "/home/niphlod/production/web2py/gluon/custom_import.py", line
74, in __call__
level)
ImportError: No module named liclient

Am I doing something wrong? Any hints or tips ?

PS: in the local system the library is not installed, i.e. if I open a
python shell and type "from liclient import LinkedInAPI" response is
"ImportError: No module named liclient". The same thing happens in the
VPS.

sys.path is the same for the local and the VPS system.



[web2py] web2py app give "Application not responding" in MAC, when provide -a password

2011-08-17 Thread xzhang
Hello,

I am using web2py mac version.
Because I don't need my user know anything about the server and
password,
So I add "-a password" argument in web2py.py.

This working fine if I start it from command line by: ./web2py
But not working when start it from double click the app.

Because the app doesn't provide the gui anymore, it go into a
"Application not responding" status.

The web server is actually works fine, I still can browser my pages.
but when I try to quit the server,  I have to use force quit, this
will give me report window back.

I am worry about this "Application not responding" and "force quit"
will scare my user.

So I want to know is there any other way to running the server without
password and command line?

Ideally, I hope after user double click the app, an icon will show in
dock just like an application, without any console or gui window, and
they can quick it by click quit from dock.

Thanks for reading my question.
xzhang



[web2py] Fragmented packets when accessing from amicrocontroller

2011-08-17 Thread Angelo Compagnucci
Hi list,

I'm using web2py for a microcontroller project and I'm facing a really
strange problem.

This microcontroller (a modified arduino with an enc28j60) can accept
only one tcp packet a time, because the packet fills the ram and so it
freezes the micro.
The pages it can process are to be small and fit in one packet. For a
microcontroller project, a single packet is sufficient for most use
cases.

I have an http library that I tested towards an example hosted by the
jqplot project (http://www.jqplot.com/tests/jsondata.txt) and it works
well, I can read the data and I can manipulate the json object.

I also observed with wireshark that only a single packet is issued in
reply to my get. There is something like this:

GET -> ACK -> HTTP 200 OK

I procedeed further writing a small controller (the count one found on
the book) to test the micro with web2py. Boom, it doesn't work!

I can read only the header of the packet. Further investigation with
wireshark lead me to think that the rocket webserver fragments the
response in a way that I can get only the first packet (containing the
header) and not the second one containg the data (as expected by the
micro limitations).
In wireshark I have something like this:

GET -> ACK -> TCP segment of a reassembled PDU -> HTTP 200 OK

The packet "TCP segment of a reassembled PDU" which comes first,
actually contains only the headers, instead the http 200 one contains
the complete packet.

To confirm this, I tested the micro with other webservers (apache,
IIS, tomcat) and noone shows the undesired behaviour.

Can you give me an hint?

Thank you!


[web2py] Re: proper usage of exclusive_domain = True ?

2011-08-17 Thread vapirix
That would be truly excellent.

It would change the way I do a lot of stuff. Right now I am forced to
use php for a lot of small little apps that I don't want to surrender
an entire web2py install for. =D

On Aug 17, 4:01 pm, Jonathan Lundell  wrote:
> Sounds like a bug in exclusive_domain. I'll look at it when I get home later.
>
> On Aug 17, 2011, at 12:57 PM, vapirix  wrote:
>
>
>
>
>
>
>
> > OR can maybe somebody point me in a different direction to achieve the
> > same thing without a hilariously complicated config process that I
> > won't want to do every time? =)
>
> > On Aug 16, 5:07 pm, vapirix  wrote:
> >> So I'm attempting to set up the usage scenario of:
>
> >> domain1.com -> load app 1
> >> domain2.com -> load app 2
> >> etc. etc.
>
> >> I need domain1 to NOT have access to app 2, 3, 4, 5, etc.
>
> >> That all works using the router's "domain" settings. Obviously you run
> >> into the problem of: domain1.com loads app1, but domain1.com/app2
> >> loading app2, so I use "exclusive_domain = True", and then I have to
> >> do domain1.com/app1/ to load the app without raising an exception,
> >> which seems counter productive. Besides that, even with
> >> exclusive_domain = True, I can do domain1.com/app2 to load the second
> >> app. Is there any way to do what I'm attempting to do here? I'd rather
> >> not have to set up separate web2py installs for the tons of tiny apps
> >> I do for my clients that get 1 hit every 6 months.
>
> >> What can I do here, friends?


Re: [web2py] Re: dowloading attachments with AJAX

2011-08-17 Thread Michele Comitini
Hi Mart!

Copy sample code in my previous mail.

to test quicly you cat put the view code somewhere in
/welcome/views/default/index.html

{{=A(T('be brave!'), _onclick="ajax('%s',[],':eval');" %
URL('gen_pdf'), _class='button')}}

copy the function gen_pdf() in /welcome/controllers/default.py

 def gen_pdf():
     from gluon.contrib.pyfpdf import FPDF

     pdf=FPDF()
     pdf.add_page()
     pdf.set_font('Arial','B',16)
     pdf.cell(40,10,'Hello World at %s!' % request.now)
     doc=pdf.output(dest='S')

     doc64=embed64(data=doc,extension='application/pdf')

     return 'window.location="%s";' % doc64

No need for other code. The trick is all in the use of 'data:' URI
that is created by embed64()

ok now URL('gen_pdf()') calls gen_pdf() in the controller that
generates the pdf on the fly and posts it back to the browser.
All in one pass, no session no temporary files around, no form, no GET...

;-)

mic


2011/8/16 mart :
> Hi Mic!
>
> This is very interesting! :) how does it work?  you have
> "URL('gen_pdf')", what is that referencing?
>
> would you have a model/sample app that we could peek at? :)
>
>
> Thanks,
> Mart :)
>
>
> On Aug 15, 4:47 pm, Michele Comitini 
> wrote:
>> Suppose you want to make an AJAX call that starts a file download.
>> How can you do that?
>> 1. form submission
>> 2. a element href
>> 3. iframe
>>
>> Too complex!
>>
>> of course *web2py* comes to rescue...
>> BIG NOTE: the following is based on 'data:' url type and was tested
>> only on FF and chrome. I do not have
>>  IE but I suppose that  is not compatible with the standard!
>>
>> In your view put a web2py ajax call similar to the following wherever
>> you need it:
>>
>> ajax('%s',[],':eval');" % URL('gen_pdf')
>>
>> ex.
>>
>> {{=A(T('be brave!'), _onclick="ajax('%s',[],':eval');" %
>> URL('gen_pdf'), _class='button')}}
>>
>> in the controller use embed64.
>>
>> def gen_pdf():
>>     from gluon.contrib.pyfpdf import FPDF
>>
>>     pdf=FPDF()
>>     pdf.add_page()
>>     pdf.set_font('Arial','B',16)
>>     pdf.cell(40,10,'Hello World at %s!' % request.now)
>>     doc=pdf.output(dest='S')
>>
>>     doc64=embed64(data=doc,extension='application/pdf')
>>
>>     return 'window.location="%s";' % doc64
>>
>> have fun!
>>
>> mic


[web2py] Re: web2py on OSX - Uses CPU when idling

2011-08-17 Thread ecafracs
Wow. Quick response! Thanks!!

Can I pass -N into the OSX binary, i.e. web2py.app?

Getting ImportError: No module named gluon.widget when trying to run
python web2py.py in the /Applications/web2py.app/Contents/Resources
directory.


On Aug 18, 7:37 am, Massimo Di Pierro 
wrote:
> Can you start it with -N and see if you can reproduce the problem. It
> may be cron and the different ways the two OSes handle processes.
>
> On Aug 17, 4:29 pm, ecafracs  wrote:
>
>
>
>
>
>
>
> > I install web2py on Windows and OSX and start it, enter the admin
> > password and wait for a few moments to let web2py settle down to idle.
>
> > Behaviour I'm seeing is:
> > * On Windows web2py uses virtually no CPU cycles if it's doing nothing
> > * On OSX it uses anywhere between 1-3% of CPU, when in theory it
> > should be doing nothing
>
> > Can anyone shed any light into why this would be?
>
> > Thanks in advance.


Re: [web2py] Re: belongs and orderby not working on gae?

2011-08-17 Thread Dave Hollingworth
Ah, could be. I'm still new to the GAE datastore. I'll look into the
indexes.

Thanks
Dave


2011/8/17 Massimo Di Pierro 

>
>
> On Aug 17, 10:52 am, fishwebby  wrote:
> > Hi, I've got the following query to select auth_users from a list of
> > IDs, then ordered by name:
> >
> > users = db(db.auth_user.id.belongs((1,2,3))).select(orderby =
> > db.auth_user.first_name)
>
> This should work. Could be that you need a index?
>
> >
> > which works fine in sqlite, but when deployed to gae the orderby
> > doesn't work. Do belongs and orderby not work together in gae?
> >
> > NB. There does seem to be an issue about it, but the page (about the
> > fifth result with this Google search:
> http://www.google.es/search?q=web2py+belongs+orderby+gae)
> > on the issue tracker gives a 502 error at the moment so I can't read
> > it...)
> >
> > I could get around it by sorting in Python afterwards, e.g.
> >
> > users = (db(db.auth_user.id.belongs((1,2,3))).select()).sort(lambda
> > row:row.first_name)
> >
> > would this be computationally expensive for a large dataset or is this
> > an acceptable workaround?
> >
> > Many thanks
> > Dave
>


[web2py] Re: Form radio buttons from db with image - how to select "checked"?

2011-08-17 Thread Anthony
Also, auth.user always contains the db.auth_user record of the current 
logged in user (or None), and auth.user_id is the logged in user's id (see 
http://web2py.com/book/default/chapter/08#Authentication). So, you don't 
have to refer to session.auth.user or do a db query to pull the current user 
record.
 
Anthony

On Wednesday, August 17, 2011 5:20:20 PM UTC-4, Massimo Di Pierro wrote:

> This 
> {{if record.id == user.auth_user.default_card: print 
> 'checked="checked''}} 
>
> should be 
>
> {{if record.id == auth.user.default_card:}} checked="checked" {{pass}} 
>
> or 
>
> {{if record.id == auth.user.default_card: response.write(' 
> checked="checked"')}} 
>
> On Aug 17, 2:57 pm, Eric Scott  wrote: 
> > I'm new to both Python and web2py and am having difficulty coding a 
> > web2py radio form where each input field displays a name and an 
> > image.  One (and only one) of these images should be set as the user's 
> > default image.  I'm having trouble figuring out how to do this in 
> > web2py.  I was able to produce the dict and then loop through to list 
> > them accordingly: 
> > 
> > CONTROLLER: 
> > @auth.requires_login() 
> > def show_cards(): 
> > records = db((db.card.owner == session.auth.user.id) | 
> > (db.card.is_active == True)).select() 
> > user = db(db.auth_user.id == session.auth.user.id).select() 
> > return dict(records=records,user=user) 
> > 
> > VIEW (show_cards.html): 
> > 
> > {{for record in records:}}  > _value="{{=record.id}}">  {{pass}} 
> > 
> > MODEL: 
> > 
> > db.define_table('auth_user', 
> > Field('id','id'), 
> > Field('username', type='string', 
> >   label=T('Username')), 
> > Field('password', type='password', 
> >   readable=False, 
> >   label=T('Password')), 
> > Field('default_card', 'reference card') 
> > 
> > db.define_table('card', 
> > Field('id','id'), 
> > Field('image', 'upload', 
> > uploadfield='image_file',label=T('Image')), 
> > Field('image_file', 'blob'), 
> > Field('nick',label=T('Nickname')), 
> > Field('owner', db.auth_user), 
> > Field('is_active','boolean',default=False, 
> >   label=T('Active')), 
> > 
> > The problem now is, I have no idea how to structure the view so that 
> > "checked=checked" is printed if the card value is equal to the owner's 
> > default value.  I know it's going to involve a nested "if" clause, but 
> > I'm not sure how to do this in a view. Something like: "{{if record.id 
> > == user.auth_user.default_card: print 'checked="checked''}}"  How 
> > should I include this in the code?  I've not yet seen how to format 
> > nested logic in a view. 
> > 
> > I also think that I could do this with a widget, but the more I read 
> > on radio buttons and widgets, the more lost I become.  I know there 
> > are probably much better ways to do this, but this is all I could hack 
> > together. 
> > 
> > Any guidance would be greatly appreciated, even if it's just a pointer 
> > in the right direction. 
> > 
> > Thanks in advance for your help. 
> > 
> > Eric



[web2py] Re: New release of pyForum

2011-08-17 Thread Anthony
Awesome. Thanks for the contribution.

On Wednesday, August 17, 2011 5:13:51 PM UTC-4, Julio Schwarzbeck wrote:

> Folks, 
>
> After a hiatus of almost 9 months I finally finished a brand new 
> version of pyForum, it was a core component re-design, PEP-8 
> compliance issues, and many issues and bug fixes completed. 
>
> The system supports Janrain and local accounts, please read the latest 
> discussions there if you had a local account, if you are/were using 
> Janrain to log in you will not have any problems, in addition, I need 
> forum administrators, please ping me once you have an account in there 
> to give you admin so you can see all that you can do in the system as 
> far as management options. 
>
> Cheers, 
>
> Julio 
> (pyforum: speedbird) 
>
> http://www.pyforum.org/ 
>


[web2py] Re: web2py on OSX - Uses CPU when idling

2011-08-17 Thread Massimo Di Pierro
Can you start it with -N and see if you can reproduce the problem. It
may be cron and the different ways the two OSes handle processes.

On Aug 17, 4:29 pm, ecafracs  wrote:
> I install web2py on Windows and OSX and start it, enter the admin
> password and wait for a few moments to let web2py settle down to idle.
>
> Behaviour I'm seeing is:
> * On Windows web2py uses virtually no CPU cycles if it's doing nothing
> * On OSX it uses anywhere between 1-3% of CPU, when in theory it
> should be doing nothing
>
> Can anyone shed any light into why this would be?
>
> Thanks in advance.


[web2py] web2py on OSX - Uses CPU when idling

2011-08-17 Thread ecafracs
I install web2py on Windows and OSX and start it, enter the admin
password and wait for a few moments to let web2py settle down to idle.

Behaviour I'm seeing is:
* On Windows web2py uses virtually no CPU cycles if it's doing nothing
* On OSX it uses anywhere between 1-3% of CPU, when in theory it
should be doing nothing

Can anyone shed any light into why this would be?

Thanks in advance.



[web2py] Re: New release of pyForum

2011-08-17 Thread Massimo Di Pierro
:-)

On Aug 17, 4:13 pm, Julio Schwarzbeck  wrote:
> Folks,
>
> After a hiatus of almost 9 months I finally finished a brand new
> version of pyForum, it was a core component re-design, PEP-8
> compliance issues, and many issues and bug fixes completed.
>
> The system supports Janrain and local accounts, please read the latest
> discussions there if you had a local account, if you are/were using
> Janrain to log in you will not have any problems, in addition, I need
> forum administrators, please ping me once you have an account in there
> to give you admin so you can see all that you can do in the system as
> far as management options.
>
> Cheers,
>
> Julio
> (pyforum: speedbird)
>
> http://www.pyforum.org/


[web2py] Re: Error running web2py shell with IPython 0.11

2011-08-17 Thread Massimo Di Pierro
In trunk. Thanks.

On Aug 17, 3:38 pm, dkuhlman  wrote:
> The interface to the embedded shell in IPython has apparently
> changed.  When I do:
>
>     $ ./web2py -S myapp
>
> I get this message:
>
>     WARNING:web2py:import IPython error; use default python shell
>
> Here is a patch.  It seems to work, but I'll admit that I'm not too
> sure that it does everything that it should.  Or, is there some other
> place where I should post this?
>
> # ==
> --- shell.py.orig       2011-08-17 13:27:33.888019538 -0700
> +++ shell.py    2011-08-17 13:25:07.778019604 -0700
> @@ -216,12 +216,9 @@
>                          'import bpython error; trying ipython...')
>              else:
>                  try:
> -                    import IPython
> -                    # following 2 lines fix a problem with IPython;
> thanks Michael Toomim
> -                    if '__builtins__' in _env:
> -                        del _env['__builtins__']
> -                    shell = IPython.Shell.IPShell(argv=[],
> user_ns=_env)
> -                    shell.mainloop()
> +                    from IPython.frontend.terminal.embed import
> InteractiveShellEmbed
> +                    shell = InteractiveShellEmbed(user_ns=_env)
> +                    shell()
>                      return
>                  except:
>                      logger.warning(
> # ==
>
> - Dave

[web2py] Re: auth.accessible_query(...)

2011-08-17 Thread Massimo Di Pierro
It is not intentional and I think I have a workaround in trunk (please
check it). yet it makes no sense to get an accessible_query if user is
not logged it. It would just generate a query that always evaluates to
false.

On Aug 17, 3:48 pm, Marin Pranjic  wrote:
> Repeating the question :)
>
>
>
>
>
>
>
> On Tue, Aug 16, 2011 at 10:21 AM, Marin  wrote:
> > Also, I noticed that accessible_query raises an exception if user is
> > not logged in.
> > It's because of a line 2805 (trunk) in gluon/tools.py:
> > user_id = self.user.id
>
> > What is expected behavior if user is not logged in? Is this
> > intentional?


[web2py] Re: extend (add methods, not subclass) web2py classes

2011-08-17 Thread Massimo Di Pierro
No. At this time I cannot recommend doing this.

On Aug 17, 3:42 pm, pbreit  wrote:
> Is there a summary anywhere of how to extend/subclass gluon modules?


[web2py] Re: Form radio buttons from db with image - how to select "checked"?

2011-08-17 Thread Massimo Di Pierro
This
{{if record.id == user.auth_user.default_card: print
'checked="checked''}}

should be

{{if record.id == auth.user.default_card:}} checked="checked" {{pass}}

or

{{if record.id == auth.user.default_card: response.write('
checked="checked"')}}

On Aug 17, 2:57 pm, Eric Scott  wrote:
> I'm new to both Python and web2py and am having difficulty coding a
> web2py radio form where each input field displays a name and an
> image.  One (and only one) of these images should be set as the user's
> default image.  I'm having trouble figuring out how to do this in
> web2py.  I was able to produce the dict and then loop through to list
> them accordingly:
>
> CONTROLLER:
> @auth.requires_login()
> def show_cards():
>     records = db((db.card.owner == session.auth.user.id) |
> (db.card.is_active == True)).select()
>     user = db(db.auth_user.id == session.auth.user.id).select()
>     return dict(records=records,user=user)
>
> VIEW (show_cards.html):
>
> {{for record in records:}}  _value="{{=record.id}}">  {{pass}}
>
> MODEL:
>
> db.define_table('auth_user',
>     Field('id','id'),
>     Field('username', type='string',
>           label=T('Username')),
>     Field('password', type='password',
>           readable=False,
>           label=T('Password')),
>     Field('default_card', 'reference card')
>
> db.define_table('card',
>     Field('id','id'),
>     Field('image', 'upload',
> uploadfield='image_file',label=T('Image')),
>     Field('image_file', 'blob'),
>     Field('nick',label=T('Nickname')),
>     Field('owner', db.auth_user),
>     Field('is_active','boolean',default=False,
>           label=T('Active')),
>
> The problem now is, I have no idea how to structure the view so that
> "checked=checked" is printed if the card value is equal to the owner's
> default value.  I know it's going to involve a nested "if" clause, but
> I'm not sure how to do this in a view. Something like: "{{if record.id
> == user.auth_user.default_card: print 'checked="checked''}}"  How
> should I include this in the code?  I've not yet seen how to format
> nested logic in a view.
>
> I also think that I could do this with a widget, but the more I read
> on radio buttons and widgets, the more lost I become.  I know there
> are probably much better ways to do this, but this is all I could hack
> together.
>
> Any guidance would be greatly appreciated, even if it's just a pointer
> in the right direction.
>
> Thanks in advance for your help.
>
> Eric


[web2py] Re: question about RBAC and ajax functions

2011-08-17 Thread Massimo Di Pierro
Strange I never had this problem. I used those browsers without issue.
Can anybody else reproduce this?

On Aug 17, 2:00 pm, angleto  wrote:
> On Aug 17, 8:11 pm, Massimo Di Pierro 
> wrote:
>
> > This may be a browser issue, the ajax call is not padding cookies.
> > Which browser?
>
> I can reproduce the problem with:
> - Chrome 14.0.835.94 beta
> - Firefox 5.0.1
> - Safari 5.1 (7534.48.3)
>
> Do you think that using CAS could solve the problem ?
> thanks
>
>
>
>
>
>
>
>
>
> > On Aug 17, 11:15 am, angleto  wrote:
>
> > > Hello, in my application I'm using both the embedded Auth module and
> > > ajax calls. Everything works fine with synchronous functions, but I
> > > have problems with ajax calls. Seems that each ajax call initialize a
> > > new session and despite the fact that I'm logged in the ajax functions
> > > still require me to login because auth.user is not initialized. I
> > > tried both trunk and stable version of web2py but the problem is the
> > > same, somebody can help me?
> > > thanks


[web2py] Re: question about RBAC and ajax functions

2011-08-17 Thread Massimo Di Pierro
I meant to say "his may be a browser issue, the ajax call is not
passing cookies."

On Aug 17, 1:11 pm, Massimo Di Pierro 
wrote:
> This may be a browser issue, the ajax call is not padding cookies.
> Which browser?
>
> On Aug 17, 11:15 am, angleto  wrote:
>
>
>
>
>
>
>
> > Hello, in my application I'm using both the embedded Auth module and
> > ajax calls. Everything works fine with synchronous functions, but I
> > have problems with ajax calls. Seems that each ajax call initialize a
> > new session and despite the fact that I'm logged in the ajax functions
> > still require me to login because auth.user is not initialized. I
> > tried both trunk and stable version of web2py but the problem is the
> > same, somebody can help me?
> > thanks


[web2py] New release of pyForum

2011-08-17 Thread Julio Schwarzbeck
Folks,

After a hiatus of almost 9 months I finally finished a brand new
version of pyForum, it was a core component re-design, PEP-8
compliance issues, and many issues and bug fixes completed.

The system supports Janrain and local accounts, please read the latest
discussions there if you had a local account, if you are/were using
Janrain to log in you will not have any problems, in addition, I need
forum administrators, please ping me once you have an account in there
to give you admin so you can see all that you can do in the system as
far as management options.

Cheers,

Julio
(pyforum: speedbird)

http://www.pyforum.org/


Re: [web2py] Re: proper usage of exclusive_domain = True ?

2011-08-17 Thread Jonathan Lundell
Sounds like a bug in exclusive_domain. I'll look at it when I get home later. 

On Aug 17, 2011, at 12:57 PM, vapirix  wrote:

> OR can maybe somebody point me in a different direction to achieve the
> same thing without a hilariously complicated config process that I
> won't want to do every time? =)
> 
> On Aug 16, 5:07 pm, vapirix  wrote:
>> So I'm attempting to set up the usage scenario of:
>> 
>> domain1.com -> load app 1
>> domain2.com -> load app 2
>> etc. etc.
>> 
>> I need domain1 to NOT have access to app 2, 3, 4, 5, etc.
>> 
>> That all works using the router's "domain" settings. Obviously you run
>> into the problem of: domain1.com loads app1, but domain1.com/app2
>> loading app2, so I use "exclusive_domain = True", and then I have to
>> do domain1.com/app1/ to load the app without raising an exception,
>> which seems counter productive. Besides that, even with
>> exclusive_domain = True, I can do domain1.com/app2 to load the second
>> app. Is there any way to do what I'm attempting to do here? I'd rather
>> not have to set up separate web2py installs for the tons of tiny apps
>> I do for my clients that get 1 hit every 6 months.
>> 
>> What can I do here, friends?


[web2py] Error running web2py shell with IPython 0.11

2011-08-17 Thread dkuhlman
The interface to the embedded shell in IPython has apparently
changed.  When I do:

$ ./web2py -S myapp

I get this message:

WARNING:web2py:import IPython error; use default python shell

Here is a patch.  It seems to work, but I'll admit that I'm not too
sure that it does everything that it should.  Or, is there some other
place where I should post this?

# ==
--- shell.py.orig   2011-08-17 13:27:33.888019538 -0700
+++ shell.py2011-08-17 13:25:07.778019604 -0700
@@ -216,12 +216,9 @@
 'import bpython error; trying ipython...')
 else:
 try:
-import IPython
-# following 2 lines fix a problem with IPython;
thanks Michael Toomim
-if '__builtins__' in _env:
-del _env['__builtins__']
-shell = IPython.Shell.IPShell(argv=[],
user_ns=_env)
-shell.mainloop()
+from IPython.frontend.terminal.embed import
InteractiveShellEmbed
+shell = InteractiveShellEmbed(user_ns=_env)
+shell()
 return
 except:
 logger.warning(
# ==

- Dave


Re: [web2py] auth.accessible_query(...)

2011-08-17 Thread Marin Pranjic
Repeating the question :)

On Tue, Aug 16, 2011 at 10:21 AM, Marin  wrote:


> Also, I noticed that accessible_query raises an exception if user is
> not logged in.
> It's because of a line 2805 (trunk) in gluon/tools.py:
> user_id = self.user.id
>
> What is expected behavior if user is not logged in? Is this
> intentional?


[web2py] Possible new deployment option: FluxFlex

2011-08-17 Thread pbreit
https://www.fluxflex.com

I have not tried it but it seems like this could be an easy way to deploy 
(once we figure out how to do it in the first place).


Re: [web2py] list:reference , reprensent not working : potential issue

2011-08-17 Thread Richard Vézina
Ok, forget notice, I think, I just should use something like this :

db.table2.linked_self.requires=\
IS_EMPTY_OR(IS_IN_DB(db,'table2.id','%(field1t2)s',\
orderby=('field1t2'),multiple=True))

But, still the list representation not working in crud.select for self
referenced field.

Richard

On Wed, Aug 17, 2011 at 4:29 PM, Richard Vézina  wrote:

> Here a simple app that show the problem, I made on the same table a self
> referenced field and a foreign referenced field...
>
> I notice, also, that the "nav built-in wigdet" for multiple don't works
> neither in the crud.update or create form...
>
> Thanks
>
> Richard
>
>
> On Wed, Aug 17, 2011 at 4:09 PM, Richard wrote:
>
>> Hello,
>>
>> I think I have a issue with list:reference with a self referenced
>> table the representation not working in sqltable... It's work when I
>> change my referenced table from the self referenced to a different
>> table...
>>
>> Book says :
>> While list:reference has a default validator and a default
>> representation...
>>
>> web2py 1.98.2
>>
>> Thanks
>>
>> Richard
>
>
>


Re: [web2py] extend (add methods, not subclass) web2py classes

2011-08-17 Thread pbreit
Is there a summary anywhere of how to extend/subclass gluon modules?

[web2py] Re: downloads

2011-08-17 Thread Anthony
No problem. Happy to help.
 
Anthony


Re: [web2py] Re: CAS Auth redirect loop

2011-08-17 Thread Bruno de Oliva Bemfica
Everytime I click the login button, I receive a message from firefox/chrome
with a 310 error(too_many_redirects) telling me to delete the cookies
or allow third-party cookies. I have an app called "login"(the CAS Server)
and another one called "ControleDeAtivos"(which should use the other app as
a cas provider). Everything's going fine on the client app. When I click the
"login" link(on the menu), I'm redirected to the cas server app login
page,and after click the submit button, the browser shows the message. The
URL showing on browser is this: *
http://172.16.7.10:8000/ControleDeAtivos/default/user/login?_next=%2FControleDeAtivos%2Fdefault%2Findex
*

The db.py file is attached.

2011/8/17 Anthony 

> Can you show some minimal code that reproduces the problem?
>
> On Wednesday, August 17, 2011 3:56:32 PM UTC-4, Bruno Codeman wrote:
>
>> Anyone? The app is entering a redirecting loop everytime I try to
>> authenticate...
>>
>> 2011/8/17 Bruno de Oliva Bemfica 
>>
>>> Hi again, everyone. Does anyone know why a CAS auth could be entering a
>>> loop redirect?
>>>
>>> --
>>> Bruno de Oliva Bemfica
>>> *Engenheiro de Software*
>>>
>>> MSN: brunoc...@live.com
>>>
>>> Mobile: +55 11 8457-0978
>>> http://www.devfranca.com.br
>>> http://www.brunobemfica.net
>>> http://www.codigofree.net
>>>
>>>
>>
>>
>> --
>> Bruno de Oliva Bemfica
>> *Engenheiro de Software*
>>
>> MSN: brunoc...@live.com
>>
>> Mobile: +55 11 8457-0978
>> http://www.devfranca.com.br
>> http://www.brunobemfica.net
>> http://www.codigofree.net
>>
>>


-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


db.py
Description: Binary data


[web2py] Re: XMPP chat client

2011-08-17 Thread Fernando Macedo
Thanks Massimiliano! Great reference!

On Aug 17, 4:40 am, Massimiliano  wrote:
> Take a look if that can help you.
>
> http://thp.io/2007/python-jabberbot/
>
>
>
>
>
>
>
>
>
> On Tue, Aug 16, 2011 at 9:52 PM, Fernando Macedo  wrote:
> > Hello all,
>
> > I'm trying to figure out how to implement a xmpp chat bot to run some
> > intranet queries and return those data. Like add the bot as friend on Google
> > Talk, and ask him a 'list employees' command.
>
> > I'd like to use the built-in server (not in gae).
>
> > Is there an easy way to get this working?
>
> > Can anyone suggest me the first steps or some reference? I've also googled
> > it, but I don't know much about de xmpp protocol itself.
>
> > Thanks in advance,
>
> > Fernando Macedo
>
> > "Somos o que repetidamente fazemos; a excelência, portanto, não é um feito,
> > mas sim um hábito!" - Aristóteles
>
> --
> Massimiliano


[web2py] Re: downloads

2011-08-17 Thread peter
Setting
"
response.headers['Content-Disposition'] = 'attachment; filename=%s' %
request.vars.filename   # to force download as attachment
"

Did indeed get the 'Do you want to open or save' dialog to use
request.vars.filename instead of request.args(0)

And now for instance "harold's bossa.mp3" works fine.

So I really appreciate your input. These things are very difficult to
sort out without the help of more exprienced people such as yourself.

Thanks
Peter


On Aug 17, 8:53 pm, peter  wrote:
> Next time I need to hire a hacker, I will ask you. Seriously though it
> is very useful being informed of vulnerabilities like this. I am a
> very experienced programmer but new to web design, so this is all
> valuable to understand.
>
> Thanks
> Peter
>
> On Aug 16, 2:50 pm, Anthony  wrote:
>
>
>
> > On Tuesday, August 16, 2011 9:41:17 AM UTC-4, peter wrote:
>
> > > The URL I gave in the example happens behind the scenes, so it does
> > > not get displayed to the user.
>
> > That's good, but note that an attacker could look at your HTML/Javascript
> > source code or watch the outgoing requests from your application, observe
> > the structure of your URLs, and still put together a directory traversal
> > attack, so be careful.
>
> > Anthony- Hide quoted text -
>
> - Show quoted text -


[web2py] list:reference , reprensent not working : potential issue

2011-08-17 Thread Richard
Hello,

I think I have a issue with list:reference with a self referenced
table the representation not working in sqltable... It's work when I
change my referenced table from the self referenced to a different
table...

Book says :
While list:reference has a default validator and a default
representation...

web2py 1.98.2

Thanks

Richard


[web2py] Re: CAS Auth redirect loop

2011-08-17 Thread Anthony
Can you show some minimal code that reproduces the problem?

On Wednesday, August 17, 2011 3:56:32 PM UTC-4, Bruno Codeman wrote:

> Anyone? The app is entering a redirecting loop everytime I try to 
> authenticate...
>
> 2011/8/17 Bruno de Oliva Bemfica 
>
>> Hi again, everyone. Does anyone know why a CAS auth could be entering a 
>> loop redirect?
>>
>> -- 
>> Bruno de Oliva Bemfica
>> *Engenheiro de Software*
>> MSN: brunoc...@live.com
>> Mobile: +55 11 8457-0978
>> http://www.devfranca.com.br
>> http://www.brunobemfica.net
>> http://www.codigofree.net
>>
>
>
>
> -- 
> Bruno de Oliva Bemfica
> *Engenheiro de Software*
> MSN: brunoc...@live.com
> Mobile: +55 11 8457-0978
> http://www.devfranca.com.br
> http://www.brunobemfica.net
> http://www.codigofree.net
>


[web2py] Re: proper usage of exclusive_domain = True ?

2011-08-17 Thread vapirix
OR can maybe somebody point me in a different direction to achieve the
same thing without a hilariously complicated config process that I
won't want to do every time? =)

On Aug 16, 5:07 pm, vapirix  wrote:
> So I'm attempting to set up the usage scenario of:
>
> domain1.com -> load app 1
> domain2.com -> load app 2
> etc. etc.
>
> I need domain1 to NOT have access to app 2, 3, 4, 5, etc.
>
> That all works using the router's "domain" settings. Obviously you run
> into the problem of: domain1.com loads app1, but domain1.com/app2
> loading app2, so I use "exclusive_domain = True", and then I have to
> do domain1.com/app1/ to load the app without raising an exception,
> which seems counter productive. Besides that, even with
> exclusive_domain = True, I can do domain1.com/app2 to load the second
> app. Is there any way to do what I'm attempting to do here? I'd rather
> not have to set up separate web2py installs for the tons of tiny apps
> I do for my clients that get 1 hit every 6 months.
>
> What can I do here, friends?


[web2py] Form radio buttons from db with image - how to select "checked"?

2011-08-17 Thread Eric Scott
I'm new to both Python and web2py and am having difficulty coding a
web2py radio form where each input field displays a name and an
image.  One (and only one) of these images should be set as the user's
default image.  I'm having trouble figuring out how to do this in
web2py.  I was able to produce the dict and then loop through to list
them accordingly:

CONTROLLER:
@auth.requires_login()
def show_cards():
records = db((db.card.owner == session.auth.user.id) |
(db.card.is_active == True)).select()
user = db(db.auth_user.id == session.auth.user.id).select()
return dict(records=records,user=user)


VIEW (show_cards.html):

{{for record in records:}}   {{pass}}

MODEL:

db.define_table('auth_user',
Field('id','id'),
Field('username', type='string',
  label=T('Username')),
Field('password', type='password',
  readable=False,
  label=T('Password')),
Field('default_card', 'reference card')

db.define_table('card',
Field('id','id'),
Field('image', 'upload',
uploadfield='image_file',label=T('Image')),
Field('image_file', 'blob'),
Field('nick',label=T('Nickname')),
Field('owner', db.auth_user),
Field('is_active','boolean',default=False,
  label=T('Active')),

The problem now is, I have no idea how to structure the view so that
"checked=checked" is printed if the card value is equal to the owner's
default value.  I know it's going to involve a nested "if" clause, but
I'm not sure how to do this in a view. Something like: "{{if record.id
== user.auth_user.default_card: print 'checked="checked''}}"  How
should I include this in the code?  I've not yet seen how to format
nested logic in a view.

I also think that I could do this with a widget, but the more I read
on radio buttons and widgets, the more lost I become.  I know there
are probably much better ways to do this, but this is all I could hack
together.

Any guidance would be greatly appreciated, even if it's just a pointer
in the right direction.

Thanks in advance for your help.

Eric


[web2py] Re: CAS Auth redirect loop

2011-08-17 Thread Bruno de Oliva Bemfica
Anyone? The app is entering a redirecting loop everytime I try to
authenticate...

2011/8/17 Bruno de Oliva Bemfica 

> Hi again, everyone. Does anyone know why a CAS auth could be entering a
> loop redirect?
>
> --
> Bruno de Oliva Bemfica
> *Engenheiro de Software*
> MSN: brunocode...@live.com 
> Mobile: +55 11 8457-0978
> http://www.devfranca.com.br
> http://www.brunobemfica.net
> http://www.codigofree.net
>



-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: downloads

2011-08-17 Thread peter
Next time I need to hire a hacker, I will ask you. Seriously though it
is very useful being informed of vulnerabilities like this. I am a
very experienced programmer but new to web design, so this is all
valuable to understand.

Thanks
Peter

On Aug 16, 2:50 pm, Anthony  wrote:
> On Tuesday, August 16, 2011 9:41:17 AM UTC-4, peter wrote:
>
> > The URL I gave in the example happens behind the scenes, so it does
> > not get displayed to the user.
>
> That's good, but note that an attacker could look at your HTML/Javascript
> source code or watch the outgoing requests from your application, observe
> the structure of your URLs, and still put together a directory traversal
> attack, so be careful.
>
> Anthony


Re: [web2py] Re: Bug (in gluon.contrib.populate) TRUNK

2011-08-17 Thread Marin Pranjic
Hi Massimo,

It works now :-)


Regards,
Marin

On Wed, Aug 17, 2011 at 8:50 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The reason for the change was to avoid records populated with the zero
> option ('').
> I think I fixed the problem, please check it.
>
> On Aug 17, 1:44 pm, Marin Pranjić  wrote:
> > Hi,
> >
> > i have a code that works on latest stable, but raises an exception in
> > trunk version.
> >
> >   File "/srv/web2py/gluon/contrib/populate.py", line 97, in populate
> > record[fieldname] = options[random.randint(0,len(options)-1)][0]
> >   File "/usr/lib/python2.7/random.py", line 241, in randint
> > return self.randrange(a, b+1)
> >   File "/usr/lib/python2.7/random.py", line 217, in randrange
> > raise ValueError, "empty range for randrange() (%d,%d, %d)" %
> > (istart, istop, width)
> > ValueError: empty range for randrange() (0,0, 0)
> >
> > I'm still trying to reproduce this and find what causes this
> > exception. It must be something related to latest changes because it
> > works in stable.
> > Line 96 has changed so someone must know why and where is the bug :-)
> > 96: options=field.requires.options(zero=False)
> >
> > Something related to Field(... requires=... ) ?
> > I will reply when I reproduce on minimalist test app.
> >
> > Marin
>


[web2py] MSSQL DAL multiple cascade paths not allowed

2011-08-17 Thread Omi Chiba
I was fololwing the web2py book with mssql for my database.

db.define_table('comment',
Field('page_id', db.page),
Field('body', 'text'),
Field('created_on', 'datetime', default=request.now),
Field('created_by', db.auth_user, default=auth.user_id))

will generate

CREATE TABLE comment(
id INT IDENTITY PRIMARY KEY,
page_id INT NULL, CONSTRAINT comment_page_id__constraint FOREIGN
KEY (page_id) REFERENCES page(id) ON DELETE CASCADE,
body TEXT NULL,
created_on DATETIME NULL,
created_by INT NULL, CONSTRAINT comment_created_by__constraint
FOREIGN KEY (created_by) REFERENCES auth_user(id) ON DELETE CASCADE
)

and will cause the error says:

Introducing FOREIGN KEY constraint 'comment_created_by__constraint' on
table 'comment' may cause cycles or multiple cascade paths. Specify ON
DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY
constraints.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.

The details for the error is descrived in here
http://support.microsoft.com/kb/321843

After I made the change on dal.py it worked fine.

def __init__(
self,
fieldname,
type='string',
length=None,
default=DEFAULT,
required=False,
requires=DEFAULT,
# ondelete='CASCADE',
ondelete='NO ACTION',

Can we make this change as path to avoid the error for mssql ? I'm not
sure if other database has the same problem.


[web2py] Re: question about RBAC and ajax functions

2011-08-17 Thread angleto
On Aug 17, 8:11 pm, Massimo Di Pierro 
wrote:
> This may be a browser issue, the ajax call is not padding cookies.
> Which browser?

I can reproduce the problem with:
- Chrome 14.0.835.94 beta
- Firefox 5.0.1
- Safari 5.1 (7534.48.3)

Do you think that using CAS could solve the problem ?
thanks

>
> On Aug 17, 11:15 am, angleto  wrote:
>
> > Hello, in my application I'm using both the embedded Auth module and
> > ajax calls. Everything works fine with synchronous functions, but I
> > have problems with ajax calls. Seems that each ajax call initialize a
> > new session and despite the fact that I'm logged in the ajax functions
> > still require me to login because auth.user is not initialized. I
> > tried both trunk and stable version of web2py but the problem is the
> > same, somebody can help me?
> > thanks


[web2py] Re: Bug (in gluon.contrib.populate) TRUNK

2011-08-17 Thread Massimo Di Pierro
The reason for the change was to avoid records populated with the zero
option ('').
I think I fixed the problem, please check it.

On Aug 17, 1:44 pm, Marin Pranjić  wrote:
> Hi,
>
> i have a code that works on latest stable, but raises an exception in
> trunk version.
>
>   File "/srv/web2py/gluon/contrib/populate.py", line 97, in populate
>     record[fieldname] = options[random.randint(0,len(options)-1)][0]
>   File "/usr/lib/python2.7/random.py", line 241, in randint
>     return self.randrange(a, b+1)
>   File "/usr/lib/python2.7/random.py", line 217, in randrange
>     raise ValueError, "empty range for randrange() (%d,%d, %d)" %
> (istart, istop, width)
> ValueError: empty range for randrange() (0,0, 0)
>
> I'm still trying to reproduce this and find what causes this
> exception. It must be something related to latest changes because it
> works in stable.
> Line 96 has changed so someone must know why and where is the bug :-)
> 96: options=field.requires.options(zero=False)
>
> Something related to Field(... requires=... ) ?
> I will reply when I reproduce on minimalist test app.
>
> Marin


[web2py] Bug (in gluon.contrib.populate) TRUNK

2011-08-17 Thread Marin Pranjić
Hi,

i have a code that works on latest stable, but raises an exception in
trunk version.

  File "/srv/web2py/gluon/contrib/populate.py", line 97, in populate
record[fieldname] = options[random.randint(0,len(options)-1)][0]
  File "/usr/lib/python2.7/random.py", line 241, in randint
return self.randrange(a, b+1)
  File "/usr/lib/python2.7/random.py", line 217, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" %
(istart, istop, width)
ValueError: empty range for randrange() (0,0, 0)


I'm still trying to reproduce this and find what causes this
exception. It must be something related to latest changes because it
works in stable.
Line 96 has changed so someone must know why and where is the bug :-)
96: options=field.requires.options(zero=False)

Something related to Field(... requires=... ) ?
I will reply when I reproduce on minimalist test app.


Marin


[web2py] CAS Auth redirect loop

2011-08-17 Thread Bruno de Oliva Bemfica
Hi again, everyone. Does anyone know why a CAS auth could be entering a loop
redirect?

-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: question about RBAC and ajax functions

2011-08-17 Thread Massimo Di Pierro
This may be a browser issue, the ajax call is not padding cookies.
Which browser?

On Aug 17, 11:15 am, angleto  wrote:
> Hello, in my application I'm using both the embedded Auth module and
> ajax calls. Everything works fine with synchronous functions, but I
> have problems with ajax calls. Seems that each ajax call initialize a
> new session and despite the fact that I'm logged in the ajax functions
> still require me to login because auth.user is not initialized. I
> tried both trunk and stable version of web2py but the problem is the
> same, somebody can help me?
> thanks


[web2py] Re: belongs and orderby not working on gae?

2011-08-17 Thread Massimo Di Pierro


On Aug 17, 10:52 am, fishwebby  wrote:
> Hi, I've got the following query to select auth_users from a list of
> IDs, then ordered by name:
>
> users = db(db.auth_user.id.belongs((1,2,3))).select(orderby =
> db.auth_user.first_name)

This should work. Could be that you need a index?

>
> which works fine in sqlite, but when deployed to gae the orderby
> doesn't work. Do belongs and orderby not work together in gae?
>
> NB. There does seem to be an issue about it, but the page (about the
> fifth result with this Google 
> search:http://www.google.es/search?q=web2py+belongs+orderby+gae)
> on the issue tracker gives a 502 error at the moment so I can't read
> it...)
>
> I could get around it by sorting in Python afterwards, e.g.
>
> users = (db(db.auth_user.id.belongs((1,2,3))).select()).sort(lambda
> row:row.first_name)
>
> would this be computationally expensive for a large dataset or is this
> an acceptable workaround?
>
> Many thanks
> Dave


[web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-17 Thread Massimo Di Pierro
Can you email me the controller, privately? I am puzzled by this.

On Aug 17, 9:56 am, Carlos  wrote:
> Hi Massimo (or others),
>
> This is one of the many errors I can get by executing concurrent web
> requests from different browsers ...
>
> web2py™ Version 1.98.2 (2011-08-16 12:27:18)
> Python Python 2.6.4: C:\Python26\python.exe
> Traceback
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 194, in restricted
>     exec ccode in environment
>   File "C:/web2py/applications/nube/controllers/web.py", line 242, in
> 
>   File "C:\web2py\gluon\globals.py", line 145, in 
>     self._caller = lambda f: f()
>   File "C:/web2py/applications/nube/controllers/web.py", line 28, in site
>     def site(): return __web()
> ... many other calls to models ...
> NameError: global name 'db' is not defined
>
> (global name 'db' is not defined)
>
> Note that NONE of these errors occur when there's no concurrency.
>
> Remember that these concurrency errors are occurring in my local environment
> (not yet in server) on win7, with postgresql and rocket.
>
> I am not ready yet to provide my complete web2py environment (models), they
> are huge, and I haven't had the chance to prepare something much smaller ...
> but I hope someone out there (Massimo?) can help me fix these show-stopper
> problems.
>
> Any clues?, thanks,
>
>    Carlos


Re: [web2py] extend (add methods, not subclass) web2py classes

2011-08-17 Thread Carlos
Hi Jonathan,

I can't subclass because I'm adding methods to lots of web2py classes, 
including:













And I believe web2py can't support subclasses for all of the above (plus 
more) because of the direct instantiations web2py does?.

For reference see Massimo's post: 
 https://groups.google.com/d/msg/web2py/ICT2YKiYFVg/D36K2o2A5GUJ

Thanks,

   Carlos



Re: [web2py] extend (add methods, not subclass) web2py classes

2011-08-17 Thread Jonathan Lundell
On Aug 17, 2011, at 10:14 AM, Carlos wrote:

> What would be the best way to extend (add methods, not subclass) web2py 
> classes?.
> 
> For reference if I want to add the method 'test' to db (DAL class)?.
> 
> I was doing something automated, but basically the following as a specific 
> example:
> 
>def test(self): return 'test from DAL'
>import gluon
>setattr(gluon.dal.DAL, 'test', test)
> 
> And that works ok so far:
> 
>db.test()  >  'test from DAL'
> 
> But I believe that is NOT thread / concurrent safe, right?.
> 
> I need to add multiple methods to multiple web2py classes (the above is just 
> a simple example to illustrate my goal).
> 
> And I also need to have access to the environment's own variables (db, 
> request, response, my own instances, etc.) on each web request, in a *safe* 
> way (without 'mixing' anything).
> 
> Is there anything you could recommend in order to accomplish this?.
> 
> I believe this has something (or everything) to do with the concurrency 
> problems I describe in my other post:
> 
>https://groups.google.com/d/topic/web2py/3qIJXnGV-mc/discussion
> 

One possible problem with your approach is that the method 'test' is going to 
disappear at the end of your request. And if you have multiple outstanding 
requests, this could be a problem. Request A patches 'test', then request B 
patches 'test', then request B terminates, and finally request A calls 'test' 
and gets the now-orphaned B reference.

Why *not* subclass instead? The subclass definition would be private to each 
request?




[web2py] Re: DAL query - GAE & local

2011-08-17 Thread ram
Thanks for clarifying

On Aug 17, 8:56 pm, howesc  wrote:
> note that standalone web2py defaults to sqlite storage, GAE development
> environment uses a GAE emulation of big-table, so data added when running
> standalone will not be available in GAE dev env and vice versa.
>
> cfh


[web2py] extend (add methods, not subclass) web2py classes

2011-08-17 Thread Carlos
Hi,

What would be the best way to extend (add methods, not subclass) web2py 
classes?.

For reference if I want to add the method 'test' to db (DAL class)?.

I was doing something automated, but basically the following as a specific 
example:

   def test(self): return 'test from DAL'
   import gluon
   setattr(gluon.dal.DAL, 'test', test)

And that works ok so far:

   db.test()  >  'test from DAL'

But I believe that is NOT thread / concurrent safe, right?.

I need to add multiple methods to multiple web2py classes (the above is just 
a simple example to illustrate my goal).

And I also need to have access to the environment's own variables (db, 
request, response, my own instances, etc.) on each web request, in a *safe* 
way (without 'mixing' anything).

Is there anything you could recommend in order to accomplish this?.

I believe this has something (or everything) to do with the concurrency 
problems I describe in my other post:

   https://groups.google.com/d/topic/web2py/3qIJXnGV-mc/discussion

Thanks!,

   Carlos



[web2py] Re: is the web2py autocomplete widget the best solution atm?

2011-08-17 Thread Anthony
On Wednesday, August 17, 2011 12:34:40 PM UTC-4, Anthony wrote:
>
> The jQuery widget probably offers my client-side options, though
>  
>
 
Meant "more client-side options". 


[web2py] Re: is the web2py autocomplete widget the best solution atm?

2011-08-17 Thread Daniel Aguayo
Thanks for your reply Anthony, was very useful.


[web2py] Re: is the web2py autocomplete widget the best solution atm?

2011-08-17 Thread Anthony
On Wednesday, August 17, 2011 12:10:44 PM UTC-4, Daniel Aguayo wrote:
>
> Hi List, 
>
> I remember that book used to say that for autocomplete was better 
> going for the jquery plugin for same purposes (altought i cannot find 
> that in the book, now).
>
I don't recall that in the book. There is a simple autocomplete example in 
the Ajax chapter (http://web2py.com/book/default/chapter/10#Auto-completion), 
which mentions there is a jQuery plugin with additional features, and also 
mentions that web2py includes its own built-in autocomplete widget (
http://web2py.com/book/default/chapter/07#Autocomplete-Widget).
 

>
> If I would have a large amount of fields to search (say, thousands or, 
> i hope not, millions) is the web2py autocomplete best solution for 
> this at this moment or should I go with jquery plugins (supposing the 
> same sql query using DAL)?

 
In terms of query performance, I don't suppose there would be much 
difference between the web2py widget and the jQuery UI widget, as they would 
both have to use the DAL to make the query. The jQuery widget probably 
offers my client-side options, though (I have also had problems with the 
web2py widget working in IE, which I hope to get to fixing soon).
 

>  

For Jquery plugins, I don't know if these are the same or if you could 
> recommend one over another: 
>
> * http://jqueryui.com/demos/autocomplete/ 
> * http://docs.jquery.com/Plugins/autocomplete
>
I think the jQuery UI autocomplete widget is the current one to use (the 
second one you list was deprecated -- see 
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/).
 
Anthony


[web2py] question about RBAC and ajax functions

2011-08-17 Thread angleto
Hello, in my application I'm using both the embedded Auth module and
ajax calls. Everything works fine with synchronous functions, but I
have problems with ajax calls. Seems that each ajax call initialize a
new session and despite the fact that I'm logged in the ajax functions
still require me to login because auth.user is not initialized. I
tried both trunk and stable version of web2py but the problem is the
same, somebody can help me?
thanks


[web2py] is the web2py autocomplete widget the best solution atm?

2011-08-17 Thread Daniel Aguayo
Hi List,

I remember that book used to say that for autocomplete was better
going for the jquery plugin for same purposes (altought i cannot find
that in the book, now).

If I would have a large amount of fields to search (say, thousands or,
i hope not, millions) is the web2py autocomplete best solution for
this at this moment or should I go with jquery plugins (supposing the
same sql query using DAL)?

For Jquery plugins, I don't know if these are the same or if you could
recommend one over another:

* http://jqueryui.com/demos/autocomplete/
* http://docs.jquery.com/Plugins/autocomplete

I'll appreciate your responses.
Best regards


[web2py] Re: DAL query - GAE & local

2011-08-17 Thread howesc
note that standalone web2py defaults to sqlite storage, GAE development 
environment uses a GAE emulation of big-table, so data added when running 
standalone will not be available in GAE dev env and vice versa.

cfh


[web2py] belongs and orderby not working on gae?

2011-08-17 Thread fishwebby
Hi, I've got the following query to select auth_users from a list of
IDs, then ordered by name:

users = db(db.auth_user.id.belongs((1,2,3))).select(orderby =
db.auth_user.first_name)

which works fine in sqlite, but when deployed to gae the orderby
doesn't work. Do belongs and orderby not work together in gae?

NB. There does seem to be an issue about it, but the page (about the
fifth result with this Google search: 
http://www.google.es/search?q=web2py+belongs+orderby+gae)
on the issue tracker gives a 502 error at the moment so I can't read
it...)

I could get around it by sorting in Python afterwards, e.g.

users = (db(db.auth_user.id.belongs((1,2,3))).select()).sort(lambda
row:row.first_name)

would this be computationally expensive for a large dataset or is this
an acceptable workaround?

Many thanks
Dave


Re: [web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-17 Thread Carlos
Hi Bruno,

The 'db' is pretty much the first model to be defined, and never ever reset, 
and all of them in root.

And note that 'db' is just one specific example of the many other errors I 
could get during concurrency.

For reference, objects instantiated in the first model suddenly are NOT 
recognized global in subsequent models / controller, same as what occurred 
with 'db'.

And this occurs only during concurrency, i.e. everything works perfectly 
fine during non-concurrent web requests.

Remember that my models code (so much more than db definitions) are huge 
(which is not the point for this issue).

Thanks again,

   Carlos



Re: [web2py] Re: Calender / datetime picker - localization

2011-08-17 Thread Anthony
Here's the documentation on the JS widget: 
http://www.dynarch.com/static/jscalendar-1.0/doc/html/reference.html.
 
Note, attaching the Calendar widget to date and datetime fields is handled 
in the web2py_ajax_init function of /static/js/web2py_ajax.js (
http://code.google.com/p/web2py/source/browse/applications/welcome/static/js/web2py_ajax.js#25),
 
so you could edit that (or change the class of date and datetime fields) in 
order to further customize the behavior.
 
Anthony

On Wednesday, August 17, 2011 10:24:08 AM UTC-4, mweissen wrote:

> Thx. But how can I translate the names of the months and the days and how 
> can I make the calendar start at Monday (and not at Sunday)?
>
> By the way: I wanted to get a timepicker and I have tried to use "... 
> _class='time'...". The datepicker works (_class='date') and also 
> _class='datetime', but not 'time'.
>
> Regards, Martin
>
> 2011/8/17 Anthony 
>
>> If you want to localize the date format in particular, in 
>> /views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format and 
>> w2p_ajax_datetime_format. Both of those are translated via the web2py 
>> translation system, so you can simply add translations for those two formats 
>> to your language files.
>>  
>> Anthony
>>
>> On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:
>>
>>> Who knows where to find details about the localization (and other 
>>> customization) of the built-in calender?
>>> In calendar.js I have found the link 
>>> http://www.dynarch.com/projects/calendar, but I could only find there 
>>> something about a (new) version JSCal2
>>>
>>> Regards, Martin
>>>
>>>
>

Re: [web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-17 Thread Bruno Rocha
BTW: where are you defining 'db' ? in db.py on the root of /models ?

On Wed, Aug 17, 2011 at 11:56 AM, Carlos  wrote:

> Hi Massimo (or others),
>
> This is one of the many errors I can get by executing concurrent web
> requests from different browsers ...
>
> web2py™ Version 1.98.2 (2011-08-16 12:27:18)
> Python Python 2.6.4: C:\Python26\python.exe
> Traceback
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 194, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/nube/controllers/web.py", line 242, in
> 
>   File "C:\web2py\gluon\globals.py", line 145, in 
> self._caller = lambda f: f()
>   File "C:/web2py/applications/nube/controllers/web.py", line 28, in site
> def site(): return __web()
> ... many other calls to models ...
> NameError: global name 'db' is not defined
>
> (global name 'db' is not defined)
>
>
> Note that NONE of these errors occur when there's no concurrency.
>
> Remember that these concurrency errors are occurring in my local
> environment (not yet in server) on win7, with postgresql and rocket.
>
> I am not ready yet to provide my complete web2py environment (models), they
> are huge, and I haven't had the chance to prepare something much smaller ...
> but I hope someone out there (Massimo?) can help me fix these show-stopper
> problems.
>
> Any clues?, thanks,
>
>Carlos
>
>


-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] Re: weird errors about not finding classes / objects when multiple simultaneous requests from different browsers/sessions.

2011-08-17 Thread Carlos
Hi Massimo (or others),

This is one of the many errors I can get by executing concurrent web 
requests from different browsers ...

web2py™ Version 1.98.2 (2011-08-16 12:27:18)
Python Python 2.6.4: C:\Python26\python.exe
Traceback

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 194, in restricted
exec ccode in environment
  File "C:/web2py/applications/nube/controllers/web.py", line 242, in 

  File "C:\web2py\gluon\globals.py", line 145, in 
self._caller = lambda f: f()
  File "C:/web2py/applications/nube/controllers/web.py", line 28, in site
def site(): return __web()
... many other calls to models ...
NameError: global name 'db' is not defined

(global name 'db' is not defined)


Note that NONE of these errors occur when there's no concurrency.

Remember that these concurrency errors are occurring in my local environment 
(not yet in server) on win7, with postgresql and rocket.

I am not ready yet to provide my complete web2py environment (models), they 
are huge, and I haven't had the chance to prepare something much smaller ... 
but I hope someone out there (Massimo?) can help me fix these show-stopper 
problems.

Any clues?, thanks,

   Carlos



Re: [web2py] Re: The use of dashes in helpers arguments.

2011-08-17 Thread Bruno Rocha
Thank you Massimo, this works very well. For the record, this is needed by
JqueryMobile and Sencha Touch.

On Wed, Aug 17, 2011 at 8:28 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> DIV(**{'_data-rol':'controlgroup', '_data-typ':'horizontal'})
>
> On Aug 17, 5:29 am, Bruno Rocha  wrote:
> > I need to create this:
> >
> > 
> >
> > using helpers this should be:
> >
> > DIV(_data-role='controlgroup', _data-type='horizontal')
> >
> > but the code above raises a Python error:
> >
> > SyntaxError: keyword can't be an expression
> >
> > what shoud I use in the place of dashes?
> >
> > thanks.
>



-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Re: Calender / datetime picker - localization

2011-08-17 Thread Martin Weissenboeck
Thx. But how can I translate the names of the months and the days and how
can I make the calendar start at Monday (and not at Sunday)?

By the way: I wanted to get a timepicker and I have tried to use "...
_class='time'...". The datepicker works (_class='date') and also
_class='datetime', but not 'time'.

Regards, Martin

2011/8/17 Anthony 

> If you want to localize the date format in particular, in
> /views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format and
> w2p_ajax_datetime_format. Both of those are translated via the web2py
> translation system, so you can simply add translations for those two formats
> to your language files.
>
> Anthony
>
> On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:
>
>> Who knows where to find details about the localization (and other
>> customization) of the built-in calender?
>> In calendar.js I have found the link
>> http://www.dynarch.com/projects/calendar, but I could only find there
>> something about a (new) version JSCal2
>>
>> Regards, Martin
>>
>>


[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Noel Villamor
Thanks for the tip(s). Have a nice day!


[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Anthony
On Wednesday, August 17, 2011 10:05:51 AM UTC-4, Noel Villamor wrote:
>
>
> Thanks for the link Anthony, it is what I need. Now, what is the 
> proper way implement the custom widget? Should I simply copy the code, 
> make the necessary alterations to it, and insert it in my app's 
> controller?
>
Sure. If you want to use it in multiple places, you could also put the 
widget definition in a model file, or put it in a module and import it.
 
Anthony


Re: [web2py] Re: custom form trouble

2011-08-17 Thread Bruno de Oliva Bemfica
Thanks for you answer, Anthony! Changed the code as you said and it worked!
:D

2011/8/17 Anthony 

> On Tuesday, August 16, 2011 11:35:40 PM UTC-4, Bruno Codeman wrote:
>>
>> Thanks for answering, Denes. I included manually the  tags
>> because it wasn't been generated by web2py. I thought it very strange, but
>> I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol).
>> Thanks for helping me again.
>
>
> You have {{form.custom.begin}}, but it should be {{=form.custom.begin}}
> (same for form.custom.end).
>
> Anthony
>
>



-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: No generic.json support anymore ?

2011-08-17 Thread Joseph.Piron
Ok.. works :)
I didn't see it in the changelog sorry.

On Aug 17, 3:54 pm, Anthony  wrote:
> There is a security risk with generic views (they expose all variables
> returned in the dict by the controller action, including all fields in any
> returned database selects, and sometimes developers
> unintentionally/unknowingly return more than they want to explicitly
> expose). You can enable some/all generic views for some/all requests by
> specifying response.generic_patterns somewhere. It should be a list of globs
> that match the controller/function.extension for which you want to enable
> generic views.
>
> response.generic_patterns = [*]    # will enable all generic views for all
> requests
>
> response.generic_patterns = ['json']   # will enable generic.json (if you
> put this in your controller or function, it will only enable it for that
> controller/function)
>
> Note, the current 'welcome' app enables all generic views, but only for
> local requests (there is a line in db.py that does this).
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, August 17, 2011 9:46:47 AM UTC-4, Joseph.Piron wrote:
> > Hi guys, quite a weirdo right here :)
>
> > I was on web2py 1.95.2 and everything was fine with my applications in
> > production.
> > To stay put, I have deciced to uppgrade to the last one 1.98.2 and
> > validate everything works.. and ... it doesn't .. :'(
>
> > I have a controller serving db information through a simple json
> > service and now, well I call for example
> >http://localhost/app/control/item.json
> > it fails with the 404: invalid view (control/item.json).
> > Or course I don't have any control/item.json as I'd like it to just
> > use the generic.json..
>
> > Can someone help me please ? Thanks !


[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Noel Villamor

Thanks for the link Anthony, it is what I need. Now, what is the
proper way implement the custom widget? Should I simply copy the code,
make the necessary alterations to it, and insert it in my app's
controller?


[web2py] Re: No generic.json support anymore ?

2011-08-17 Thread Anthony
There is a security risk with generic views (they expose all variables 
returned in the dict by the controller action, including all fields in any 
returned database selects, and sometimes developers 
unintentionally/unknowingly return more than they want to explicitly 
expose). You can enable some/all generic views for some/all requests by 
specifying response.generic_patterns somewhere. It should be a list of globs 
that match the controller/function.extension for which you want to enable 
generic views.
 
response.generic_patterns = [*]# will enable all generic views for all 
requests
 
response.generic_patterns = ['json']   # will enable generic.json (if you 
put this in your controller or function, it will only enable it for that 
controller/function)
 
Note, the current 'welcome' app enables all generic views, but only for 
local requests (there is a line in db.py that does this).
 
Anthony

On Wednesday, August 17, 2011 9:46:47 AM UTC-4, Joseph.Piron wrote:

> Hi guys, quite a weirdo right here :) 
>
> I was on web2py 1.95.2 and everything was fine with my applications in 
> production. 
> To stay put, I have deciced to uppgrade to the last one 1.98.2 and 
> validate everything works.. and ... it doesn't .. :'( 
>
> I have a controller serving db information through a simple json 
> service and now, well I call for example 
> http://localhost/app/control/item.json 
> it fails with the 404: invalid view (control/item.json). 
> Or course I don't have any control/item.json as I'd like it to just 
> use the generic.json.. 
>
> Can someone help me please ? Thanks !



[web2py] Re: No generic.json support anymore ?

2011-08-17 Thread Ross Peoples
There have been a lot of people asking this question lately, it seems. They 
were disabled for security reasons. Please see the book for more information 
and how to enable them 
again: http://web2py.com/book/default/chapter/09#Generic-Views

[web2py] No generic.json support anymore ?

2011-08-17 Thread Joseph.Piron
Hi guys, quite a weirdo right here :)

I was on web2py 1.95.2 and everything was fine with my applications in
production.
To stay put, I have deciced to uppgrade to the last one 1.98.2 and
validate everything works.. and ... it doesn't .. :'(

I have a controller serving db information through a simple json
service and now, well I call for example http://localhost/app/control/item.json
it fails with the 404: invalid view (control/item.json).
Or course I don't have any control/item.json as I'd like it to just
use the generic.json..

Can someone help me please ? Thanks !


Re: [web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Martín Mulone
Anthony is right is showing a complete solution, but what do you want to
achieve?, perhaps you are looking to customize the style and a less
complicate solution can be for example

To customize this:



some in css:

div.list {}
div.list input {}

or

#tag_tags {}

And this:



table.list {}
table.list input {}

or

#tag_tags {}


2011/8/17 Anthony 

> I think you might need a custom widget (see
> http://web2py.com/book/default/chapter/07#Widgets). For reference, here's
> the current radio widget:
> http://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#287.
>
> Anthony
>
> On Wednesday, August 17, 2011 3:57:48 AM UTC-4, Noel Villamor wrote:
>
>> I tried inserting crud.settings.formstyle = 'divs'  but it only
>> changed to divs the layout(?) but not the widget.
>>
>> DEFAULT FORM STYLE
>> 
>> 
>> 
>> 
>> ...
>>
>> FORM STYLE SET TO "divs"
>> 
>> 
>> 
>> 
>> ...
>>
>> As mentioned in my original post, I wanted
>>
>> 
>>
>> to be
>>
>> .
>>
>> Any other suggestion? Thanks again.
>
>


-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: Calender / datetime picker - localization

2011-08-17 Thread Anthony
If you want to localize the date format in particular, in 
/views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format and 
w2p_ajax_datetime_format. Both of those are translated via the web2py 
translation system, so you can simply add translations for those two formats 
to your language files.
 
Anthony

On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:

> Who knows where to find details about the localization (and other 
> customization) of the built-in calender?
> In calendar.js I have found the link 
> http://www.dynarch.com/projects/calendar, but I could only find there 
> something about a (new) version JSCal2
>
> Regards, Martin
>
>

[web2py] select by query in the link

2011-08-17 Thread cyber
How can I select rows from db using the link:

   
http://localhost:8000/init/default/select/db?query=db.autos.num.contains(...some...value...)

In the controller I have to describe current db, table and parse value
from the link.

So I need something like it is into appadmin but a little bit shorter.


[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Anthony
I think you might need a custom widget (see 
http://web2py.com/book/default/chapter/07#Widgets). For reference, here's 
the current radio widget: 
http://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#287.
 
Anthony

On Wednesday, August 17, 2011 3:57:48 AM UTC-4, Noel Villamor wrote:

> I tried inserting crud.settings.formstyle = 'divs'  but it only 
> changed to divs the layout(?) but not the widget. 
>
> DEFAULT FORM STYLE 
>  
>  
>  
>  
> ... 
>
> FORM STYLE SET TO "divs" 
>  
>  
>  
>  
> ... 
>
> As mentioned in my original post, I wanted 
>
>  
>
> to be 
>
> . 
>
> Any other suggestion? Thanks again.



Re: [web2py] Re: Postgresql 9.0 problem.

2011-08-17 Thread Richard Vézina
Did you set your pg_hba.conf and postgresql.conf...

These lines at least :

pg_hba.conf :

hostall all *127.0.0.1*/24  md5

postgresql.conf :

listen_addresses = '***' # Don't remember original value...

ssl =* true or false *



Richard


On Wed, Aug 17, 2011 at 6:40 AM, annet  wrote:

> @David,
>
> > Do you have PostgreSQL python adapter installed? Is the adapter listed in
> > web2py startup log?
>
> Yes I have.
>
>
> @pbreit
>
> > It seems to me I tried specifying the port once and it didn't work.
> Should it?
>
> I did work in 8.4. I think for now I just re-install version 8.4, it
> may not be a web2py issue.
>
>
> Thanks for your replies.
> Annet.


Re: [web2py] jqgrid-module import problem

2011-08-17 Thread Johann Spies
On 17 August 2011 13:28, Bruno Rocha  wrote:

> No more need to use lical_import it is deprecated. Newest web2py has a
> custom importer which works much better.
>
Thanks

Johann


-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-17 Thread fishwebby
> > - paginate the denormalised data, for example show a paginated list of
> > students on a course?
>
> You cannot. ListProperty does not allow this.

How about something like this?

limitby = (0, 10)
students = db(db.student.id.belongs(course.students)).select(limitby =
limitby)

(where course.students is potentially quite large, but would that
cause a problem?)


[web2py] Use of SSL in web2py fails in firefox (missing intermediary cert)

2011-08-17 Thread Markus Schmitz
Hi everybody,

this might be an implicit rocket problem, but because the SSL
parameters are passed on the command line of web2py, I thought to
address this here:

I am running a website based on web2py and installed SSL certificates
today to enable https. The corresponding files are passed with the '-
c' and '-k'  during startup of web2py. The certificate was obtained
from Verisign.

Now https access is working fine for IE, chrome etc., but not for
firefox, where I get an SSL error: sec_error_unknown_issuer

A bit of searching reveals, that I should pass the intermediary cert
of verisign to the web server. This can be done for example in the
Apache config file, if I would use Apache. But I am using the built-in
rocket and would like to keep it this way (for now).

Any idea how to make SSL work under firefox as a client and rocket as
a web server? Did anybody try?
Could it be, that we are missing a command line option for web2py?

Regards

Markus


[web2py] Re: No spaces... now that would be nice...

2011-08-17 Thread Ross Peoples
I've only run in to this issue once where I had a toolbar that would break 
if I put each button on its own line. So I just put everything on one line. 
There are only 3 or 4 buttons, so it's not that big of a deal, but I could 
see where this could be an issue in some cases. However, I'm not sure if 
this would be the right way to fix such a problem.

[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-17 Thread fishwebby
So it sounds like it's possible to do what I want, although if I do
want to do many to many perhaps GAE isn't the best fit. I'm going to
persevere and see if I can get it working, as GAE is very attractive
as a hosting option where I don't have to worry at all about scaling,
server maintenance or any of the usual hosting hassles.

In case it's useful to anyone reading this thread, this video (which
I'm watching at the moment) 
http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html

has a great explanation of the datastore in GAE. It's from 2009 so it
may have changed a bit but the concepts are clearly explained by the
presenter.

Best wishes
Dave


On Aug 17, 1:40 pm, fishwebby  wrote:
> (posting Massimo's reply)
>
> > e.g. 1, "Physics 101", 4|5|6
> > Is that how data has to be modelled using the GAE datastore?
>
> No. On GAE 'list:reference' maps into a ListProperty of integers
>
> > If so, is
> > it possible to do the following:
>
> > - paginate the denormalised data, for example show a paginated list of
> > students on a course?
>
> You cannot. ListProperty does not allow this.
>
> > - have hundreds of IDs in the list:reference field (a course could
> > have hundreds of students) - or is there an upper limit?
>
> If there is it is a GAE limitation. I am not aware of it.
>
>
>
> > Also, how are updates to these fields handled? For example, remove one
> > student from a course that has hundreds enrolled? Are there mechanisms
> > in web2py to handle this?
>
> course = db.course(name='Phsysics 101')
> course.students.remove(4) # remove student with id==4
> course.update_record()
>
> > Also, it would seem that the two list:reference fields would need to
> > be kept synchronised somehow - if a student is deleted, any course
> > that they were enrolled on needs to be updated too, which (with my
> > mind still in relational database mode) would seem to be very
> > inefficient.
>
> I would use a many-2-many with a link table and I would not use GAE
> for this.


[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-17 Thread fishwebby
(posting Massimo's reply)

> e.g. 1, "Physics 101", 4|5|6
> Is that how data has to be modelled using the GAE datastore?

No. On GAE 'list:reference' maps into a ListProperty of integers

> If so, is
> it possible to do the following:
>
> - paginate the denormalised data, for example show a paginated list of
> students on a course?

You cannot. ListProperty does not allow this.

> - have hundreds of IDs in the list:reference field (a course could
> have hundreds of students) - or is there an upper limit?

If there is it is a GAE limitation. I am not aware of it.

>
> Also, how are updates to these fields handled? For example, remove one
> student from a course that has hundreds enrolled? Are there mechanisms
> in web2py to handle this?

course = db.course(name='Phsysics 101')
course.students.remove(4) # remove student with id==4
course.update_record()

> Also, it would seem that the two list:reference fields would need to
> be kept synchronised somehow - if a student is deleted, any course
> that they were enrolled on needs to be updated too, which (with my
> mind still in relational database mode) would seem to be very
> inefficient.

I would use a many-2-many with a link table and I would not use GAE
for this.


[web2py] Re: The use of dashes in helpers arguments.

2011-08-17 Thread Massimo Di Pierro
DIV(**{'_data-rol':'controlgroup', '_data-typ':'horizontal'})

On Aug 17, 5:29 am, Bruno Rocha  wrote:
> I need to create this:
>
> 
>
> using helpers this should be:
>
> DIV(_data-role='controlgroup', _data-type='horizontal')
>
> but the code above raises a Python error:
>
> SyntaxError: keyword can't be an expression
>
> what shoud I use in the place of dashes?
>
> thanks.


Re: [web2py] jqgrid-module import problem

2011-08-17 Thread Bruno Rocha
No more need to use lical_import it is deprecated. Newest web2py has a
custom importer which works much better.

http://zerp.ly/rochacbruno
Em 17/08/2011 08:20, "Johann Spies"  escreveu:
> On 17 August 2011 12:55, Bruno Rocha  wrote:
>
>> try changing this:
>>
>> JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid
>>
>>
>> to this:
>>
>>
>> from jqgrid import JqGrid
>>
>>
> Thanks. That solved the problem but not the mystery (because my lack of
> understanding).
>
> When is it better to use the first version?
>
> Regards
> Johann
> --
> May grace and peace be yours in abundance through the full knowledge of
God
> and of Jesus our Lord! His divine power has given us everything we need
for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
> 2 Pet. 1:2b,3a


Re: [web2py] jqgrid-module import problem

2011-08-17 Thread Johann Spies
On 17 August 2011 12:55, Bruno Rocha  wrote:

> try changing this:
>
> JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid
>
>
> to this:
>
>
> from jqgrid import JqGrid
>
>
Thanks.  That solved the problem but not the mystery (because my lack of
understanding).

When is it better to use the first version?

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Google datastore concepts - denormalising and list:reference fields

2011-08-17 Thread fishwebby
Hi, I'm currently learning web2py for deployment on Google App Engine,
and I've got a couple of questions about how the datastore works.

Let's say I've got a relational database with students, courses and
enrolments. Enrolments is the join table that allows a many to many
relationship between students and courses. For example:

Students

id
name

Courses

id
title

Enrolments

student_id
course_id

This allows me to show a list of courses for a student, and a list of
users enrolled on a course, by using join queries. I can order these
lists by the student name, and do pagination too (using LIMIT and
OFFSET).

However, as I understand it, in the Google datastore, you can't do
joins like this. From what I've read you could do it with a
list:reference field, which basically contains a list of IDs like this
1|2|3|4 etc., so the data would look like this:

Student
---
id
name
courses

e.g. 1, "John Smith", 1|2|3

Course
--
id
title
students

e.g. 1, "Physics 101", 4|5|6

(and no enrolments table)

Is that how data has to be modelled using the GAE datastore? If so, is
it possible to do the following:

- paginate the denormalised data, for example show a paginated list of
students on a course?
- have hundreds of IDs in the list:reference field (a course could
have hundreds of students) - or is there an upper limit?

Also, how are updates to these fields handled? For example, remove one
student from a course that has hundreds enrolled? Are there mechanisms
in web2py to handle this?

Also, it would seem that the two list:reference fields would need to
be kept synchronised somehow - if a student is deleted, any course
that they were enrolled on needs to be updated too, which (with my
mind still in relational database mode) would seem to be very
inefficient.

I think what I need is a high-level overview of how data needs to be
designed for the GAE datastore ̣- however as I've found this forum to
be very helpful I thought I'd ask my specific questions here first
before I go off and watch some Google I/O videos.

Any help in me trying to get my head around this is greatly
appreciated!

Many thanks
Dave


Re: [web2py] jqgrid-module import problem

2011-08-17 Thread Bruno Rocha
try changing this:


JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid



to this:



from jqgrid import JqGrid



On Wed, Aug 17, 2011 at 7:44 AM, Johann Spies wrote:

> Strange: I have the app working on my laptop.  After packing it using the
> admin interface and installing it on the server I get this error on the
> server:
>
> ImportError: No module named jqgrid.modules.jqgrid
>
>
> The line in the controller which is referred to:
>
> JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid
>
> I am using the module from
> http://www.web2pyslices.com/slices/take_slice/140
>
> How do I have to change the import line?
>
> Why would it work correctly on one system and not on the other.
> Differences:
>
> Laptop: python   2.6.7-2
> Debian wheezy/sid
>
>
> Server: python2.6   2.6.6-8+b1
>Debian Squeeze
> Postgresql 9.0
>
> --
>  May grace and peace be yours in abundance through the full knowledge of
> God and of Jesus our Lord!  His divine power has given us everything we need
> for life and godliness through the full knowledge of the one who called us
> by his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>


-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] jqgrid-module import problem

2011-08-17 Thread Johann Spies
Strange: I have the app working on my laptop.  After packing it using the
admin interface and installing it on the server I get this error on the
server:

ImportError: No module named jqgrid.modules.jqgrid

The line in the controller which is referred to:

JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid

I am using the module from http://www.web2pyslices.com/slices/take_slice/140

How do I have to change the import line?

Why would it work correctly on one system and not on the other.
Differences:

Laptop: python   2.6.7-2
Debian wheezy/sid


Server: python2.6   2.6.6-8+b1
   Debian Squeeze
Postgresql 9.0

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


  1   2   >