[web2py] Re: How do I add JQuery UI to Web2PY

2011-09-17 Thread Anthony
On Sunday, September 18, 2011 2:11:04 AM UTC-4, JavierQQ wrote:
>
> can I do =form(_class="Dialog-form")? (Dialog-form is the id of 
> the example) 
>

Not exactly, but assuming 'form' is a web2py FORM or SQLFORM object, you can 
add a class to it by adding a '_class' attribute. You can either do that 
when you first create the form:

form = SQLFORM(..., _class='Dialog-form')

or after it is created:

form['_class']='Dialog-form'

See http://web2py.com/book/default/chapter/05#HTML-Helpers.

Anthony



[web2py] Re: =MENU

2011-09-17 Thread Anthony
On Sunday, September 18, 2011 1:15:44 AM UTC-4, JavierQQ wrote:
>
> background:url(images/menu_bt.gif) 
> I don't know how it works but I use ('../') with the dots and the 
> slash


The ../ refers to the parent folder of the current folder. So, if the 
current folder is /static/css, then ../ refers to static/. If your css is in 
/static/css and your images are in /static/images, then to refer to an image 
from a css file, you would do ../images/image_file, which is equivalent to 
/full/path/to/static/images/image_file.

Anthony 


[web2py] Re: How do I add JQuery UI to Web2PY

2011-09-17 Thread JavierQQ
Can I edit =FORM too?

is it difficult?
As a example I'm going to insert this
http://jqueryui.com/demos/dialog/#modal-form

and I have one view called 'regcliente.html'
that has this
{{extend 'layout.html'}}
Registrar cliente


Cliente
{{=form}}



can I do =form(_class="Dialog-form")? (Dialog-form is the id of
the example)

this is how I intend to put it folders
/static
  /css
/start
  jquery-ui-1.8.16.custom.css
  /images
..
  /js
jquery-1.6.2.min.js
jquery-ui-1.8.16-min.js
..

and in Layout.html I put the javascript here
 

and finally in the view I put the divs but it only appears without the
style

Is the something I missed?



On Sep 16, 10:06 pm, Anthony  wrote:
> On Friday, September 16, 2011 10:05:39 PM UTC-4, rami wrote:
>
> > Oh my bad,
> >                 // Accordion
> >                 $("#accordion").accordion({ header: "h3" });
>
> >                 $('#tabs').tabs();
>
> > I included the semicolon in my code but just for some dumb reason not
> > on my post. Sorry to confuse you :(
>
> > Any other reasons why this does not work??
>
> Nothing obvious. If accordion is working, I assume jQuery UI is loaded. You
> may need to check the source html delivered by web2py and do some debugging
> in the browser.
>
> Anthony


[web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-09-17 Thread tomt
Hi,

I have a question about using powertable.

When I try to build a powertable on the following select:
tasks=db(db.task.cpaid==3).select(db.task.cpa,db.task.description,db.task.ls_js)
I get the following error:
  File "/home/xa21/workspace/web2py/applications/cpa4/models/
plugin_powertable.py", line 219, in __init__
_id = record.id
  File "/home/xa21/workspace/web2py/gluon/dal.py", line 3786, in
__getattr__
return self[key]
  File "/home/xa21/workspace/web2py/gluon/dal.py", line 3777, in
__getitem__
return dict.__getitem__(self, key)
KeyError: 'id'

I suspect this means that powertable requires a field named 'id'. Is
this true, or is there a way I can get around this?
(The table I'm interested in displaying is a legacy table that doesn't
contain an .id field)

- Tom



[web2py] Re: Why web2py is in French by default? How can I change it?

2011-09-17 Thread weheh
No problems with book for me. English.


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
In the crud case

cud.create(...,next='action/[id]')

automatically fills in the id of the record being created.

Auth allows you to the same when a new user is created.



On Sep 17, 3:30 pm, Jonathan Lundell  wrote:
> On Sep 17, 2011, at 1:24 PM, Anthony wrote:
>
> > Sounds like this will be completely re-thought, so maybe comments on the 
> > current (trunk) code aren't necessary, but here are some observations (not 
> > sure if these are correct because I haven't tested anything, just quickly 
> > looked at the code):
> > It still looks like _auth_next will be the first URL visited during the 
> > session, whether or not it requires login, but then it can't get 
> > overwritten. So won't the redirect end up going to the first URL of the 
> > session rather than the last URL right before login (we want the latter, 
> > no)?
> > _auth_next is reset to None if it starts with the current URL, but don't we 
> > want it to be an exact match for the current URL (including args and vars) 
> > in order to conclude that the redirect has happened?
> > I'm not sure I'm following properly, but does this involve an additional 
> > redirect -- one immediately after login, and then another when that 
> > redirect hits Auth.__init__?
> > This is repeated many times:
> >         if is_relative(next):
> >             next = self.url(next.replace('[id]', str(form.vars.id)))
>
> > Instead of the is_relative function, how about a replace_id function that 
> > checks for a relative URL and does the replace? So, the above would just be:
>
> >         next = replace_id(next,form)
>
> What is the id logic, anyway? Some CRUD thing?
>
>
>
>
>
>
>
> > Anthony
>
> > On Saturday, September 17, 2011 11:36:41 AM UTC-4, Massimo Di Pierro wrote:
> > > It seems to me that there are two issues here. One is cleaning up the 
> > > logic to make it uniform, DRY and understandable. The other is deciding 
> > > where to put the next link (and doing proper validation of the URL).
>
> > > I understand (I think) the basic use case for @requires_login, I think.
>
> > > What's the use case for saving the return link in Auth()?
>
> > > Does it make sense to try to save a next link in cases like 
> > > change-password? Profile editing?
>
> > > I'm fine with reverting for now, but I really think that this logic is 
> > > due for a review and cleanup.
>
> > I agree with that. I think we may have to release 1.99.1 with the
> > _next solution and then try improve it.
>
> > > Maybe starting with a spec: what are we really trying to do? And how do 
> > > these dynamic _next links relate to the various next-URL links in 
> > > auth.settings?
>
> > I will try write more about this later today.
>
> > Massimo


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
There are cases when the original "next" got lost. I did not full
track the cause of the problem.
The code in Auth was a quick hack to handle it.



On Sep 17, 11:26 am, Jonathan Lundell  wrote:
> On Sep 17, 2011, at 8:46 AM, Massimo Di Pierro wrote:
>
>
>
>
>
>
>
>
>
> > The basic use case is this:
> > User clicks on a link that requires_login and gets redirected to the
> > login page. After login the user is redirected to the original
> > requested page.
> > Exceptions:
> > - the login is outsourced to janrain
> > - the login is outsourced to cas or other open-id
> > - the login is not possible and the user must first register
> > - after login is redirected to the intended page but the app logic
> > finds this user has incomplete profile and redirects to profile
> > editing (*)
> > - what if the user is impersonating another user? (?)
> > - the user is visiting a page that does not require login but LOADs a
> > component that does (?)
> > - the user is visiting a page that does not require login but IFRAMEs
> > a  component that does
> > - the user has another window open (**)
> > (*) is not currently supported. (?) not sure if it works (**) worked
> > with _next but not not with session._auth_next.
>
> The old logic saves a next link in session in Auth(). What's that for?


[web2py] Re: Python Exceptions: how to show in View

2011-09-17 Thread Massimo Di Pierro
Mind

try:
   #do something (*)
except Exception, e:
   db.rollback() # may be needed if (*) fail on db io
   response.flash = "Error occured %s" % str(e)

or if you need more info

try:
   #do something (*)
except:
   import traceback
   db.rollback() # may be needed if (*) fail on db io
   response.flash = DIV(H2('error'),PRE(traceback.format_exc()))



On Sep 17, 3:09 pm, Bruno Rocha  wrote:
> try:
>    #do something
> except Exception, e:
>    response.flash = "Error occured %s" % str(e)
>
> On Sat, Sep 17, 2011 at 9:26 AM, Vineet  wrote:
> > Regarding user data validation, I am comfortble with client-side
> > validation.
> > I also have server-side customized validation routines.
> > I am aware that a token is issued for an error.
> > Whenever an exception is raised server-side, what is the simplest way
> > to show it in a messagebox or a DIV (maybe in "flash")?
>
> > Regards,
> > Vineet
>
> --
>
> --
> 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: problem with updating Form with writable=False Fields

2011-09-17 Thread Massimo Di Pierro
Why not just do?

auth = Auth()
auth.settings.extra_field['auth_user'] = []
auth.define_tables()



On Sep 17, 10:46 am, Alex  wrote:
> Hi,
>
> first of all, many thanks to Massimo and all other contributers.
> web2py is an amazing framework and exactly what I was looking for.
> Keep up the excellent work!
>
> I've got a couple of questions and problems so I'll start with the one
> which is bugging me the most:
> I've defined the auth_user table, added username, password and some
> other fields. So far everything works fine. Now I want to create a
> form where the user can change the password. In this form I do not
> want to modify any of the other fields. So I'm doing the following
> before creating the SQLForm (user_table == db.auth_user):
>
> for field in user_table.fields:
>   if field == 'password':
>     user_table[field].readable = user_table[field].writable = True
>   else:
>     user_table[field].readable = user_table[field].writable =
> False
>
> this works fine, the form only contains the password field. But when I
> submit the form, I end up with the following error:
> File "C:\Tools\web2py_src\gluon\sqlhtml.py", line 1202, in accepts
>     fields[field.name] = self.record[field.name]
>   File "C:\Tools\web2py_src\gluon\dal.py", line 3777, in __getitem__
>     return dict.__getitem__(self, key)
> KeyError: 'registration_key'
>
> so its trying to update a field which is writable==False. When I look
> into the code in sqlhtml.py (line 1200) this is confusing me a little
> bit:
> for field in self.table:
>   if not field.name in fields and field.writable==False:
>     if record_id:
>       fields[field.name] = self.record[field.name]
>     elif self.table[field.name].default!=None:
>       fields[field.name] = self.table[field.name].default
>
> why is it checking writable==False? shouldn't it test for
> writable==True or do I get something wrong here?
>
> Alex


[web2py] Re: web2py with jython on linux

2011-09-17 Thread Massimo Di Pierro
Can you try

gluon/dal.py:import copy_reg

from the jython shell. That line is in dal.py not in storage.py
strange.

On Sep 17, 11:56 am, Vasile Ermicioi  wrote:
> > Can you do import cPickle form a regular jython shell?
>
> yes
>
> steps to reproduce:
> 1)
> install latest jython (2.5.2)
> 2)
> wgethttp://www.web2py.com/examples/static/web2py_src.zip
> unzip web2py_src.zip
> jython web2py.py


[web2py] Re: Why web2py is in French by default? How can I change it?

2011-09-17 Thread Anthony
Cleared my session cookie and now back to English (plugin_translate no 
longer linked in the HTML head).

Anthony

On Saturday, September 17, 2011 4:40:00 PM UTC-4, Anthony wrote:
>
> OK, now I'm seeing the book in French rather than English as well (only in 
> IE, not Chrome). The HTML source code is in English, so I guess it is being 
> translated client-side via plugin_translate. I see the following in the head 
> of the HTML:
>
>   src="/book/static/plugin_translate/jquery.translate-1.4.3-debug-all.js" 
> type="text/javascript">
>   type="text/javascript">
>
> I assume fr.js shouldn't be there.
>
> Note, I haven't made any changes to my browser. One minute everything was 
> in English, and upon a new page load, suddenly French.
>
> Anthony
>
> On Thursday, September 15, 2011 2:56:43 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Is this about the book? 
>>
>> On Sep 15, 12:30 pm, Cliff  wrote: 
>> > I'm seeing the problem too. 
>> > 
>> > On Sep 15, 4:08 am, Zhe Li  wrote: 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > > Hi, 
>> > 
>> > > I tried to find something in web2py book, but everything is in French 
>> now. 
>> > > (Wasn't like this yesterday) 
>> > 
>> > > I am sure I have set my browser to English, anything wrong? 
>> > 
>> > > Cheers, 
>> > > Zhe
>
>

Re: [web2py] Nginx-uwsgi problem.

2011-09-17 Thread Michele Comitini
Another thing you should look at is how much paging is the machine
doing under load.

*vmstat*  is your friend...

mic

2011/9/17 Bruno Rocha :
> I am using threads + Postgresql, I am using disk cache, but I am moving it
> for memcache or the new redis suport in trunk.
> I will try to change it for processes. Thanks.
>
> On Sat, Sep 17, 2011 at 5:50 PM, Michele Comitini
>  wrote:
>>
>> Hi Bruno!
>>
>> Are you using threads or processes, sqlite or a rdbms?
>> Seems a timeout while web2py is trying to access some resource.
>>
>> I suggest processes + rdbms (postgresql)
>>
>> mic
>>
>> 2011/9/17 Bruno Rocha :
>> > I am getting a high traffic on the new service I released www.rifar.me
>> > I did not expected too much access, and now my server is running in
>> > problems.
>> > Anybody has any hint about this error?
>> > 2011/09/17 12:56:36 [error] 15855#0: *55651 upstream timed out (110:
>> > Connection timed out) while reading response header from upstream,
>> > client:
>> > 177.41.102.72, server: www.rifar.me, request: "GET
>> > /rifa/quadro-da-artista-plastica-vicky-von-dorff HTTP/1.1", upstream:
>> > "uwsgi://127.0.0.1:9012", host: "www.rifar.me"
>> > 2011/09/17 14:29:17 [error] 15853#0: *56788 upstream timed out (110:
>> > Connection timed out) while reading response header from upstream,
>> > client:
>> > 189.68.92.92, server: www.rifar.me, request: "GET
>> > /static/images/logo.resized.black.png HTTP/1.1", upstream:
>> > "uwsgi://127.0.0.1:9012", host: "www.rifar.me", referrer:
>> >
>> > "http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/5/1.0.35/br/pt-BR/controller.html";
>> > 2011/09/17 16:30:38 [error] 15853#0: *58681 upstream timed out (110:
>> > Connection timed out) while reading response header from upstream,
>> > client:
>> > 189.110.52.2, server: www.rifar.me, request: "GET
>> >
>> > /rifa/sapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor
>> > HTTP/1.1", upstream: "uwsgi://127.0.0.1:9012", host: "www.rifar.me",
>> > referrer:
>> >
>> > "http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.rifar.me%2Frifa%2Fsapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor&h=AAQADMJmAAQCEnatNdBzs3l6PmgbGhSfV55YaYbFO24_Xgg";
>
>
>
> --
>
>
>
> --
> 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] Nginx-uwsgi problem.

2011-09-17 Thread Bruno Rocha
I am using threads + Postgresql, I am using disk cache, but I am moving it
for memcache or the new redis suport in trunk.

I will try to change it for processes. Thanks.

On Sat, Sep 17, 2011 at 5:50 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> Hi Bruno!
>
> Are you using threads or processes, sqlite or a rdbms?
> Seems a timeout while web2py is trying to access some resource.
>
> I suggest processes + rdbms (postgresql)
>
> mic
>
> 2011/9/17 Bruno Rocha :
> > I am getting a high traffic on the new service I released www.rifar.me
> > I did not expected too much access, and now my server is running in
> > problems.
> > Anybody has any hint about this error?
> > 2011/09/17 12:56:36 [error] 15855#0: *55651 upstream timed out (110:
> > Connection timed out) while reading response header from upstream,
> client:
> > 177.41.102.72, server: www.rifar.me, request: "GET
> > /rifa/quadro-da-artista-plastica-vicky-von-dorff HTTP/1.1", upstream:
> > "uwsgi://127.0.0.1:9012", host: "www.rifar.me"
> > 2011/09/17 14:29:17 [error] 15853#0: *56788 upstream timed out (110:
> > Connection timed out) while reading response header from upstream,
> client:
> > 189.68.92.92, server: www.rifar.me, request: "GET
> > /static/images/logo.resized.black.png HTTP/1.1", upstream:
> > "uwsgi://127.0.0.1:9012", host: "www.rifar.me", referrer:
> > "
> http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/5/1.0.35/br/pt-BR/controller.html
> "
> > 2011/09/17 16:30:38 [error] 15853#0: *58681 upstream timed out (110:
> > Connection timed out) while reading response header from upstream,
> client:
> > 189.110.52.2, server: www.rifar.me, request: "GET
> >
> /rifa/sapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor
> > HTTP/1.1", upstream: "uwsgi://127.0.0.1:9012", host: "www.rifar.me",
> > referrer:
> > "
> http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.rifar.me%2Frifa%2Fsapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor&h=AAQADMJmAAQCEnatNdBzs3l6PmgbGhSfV55YaYbFO24_Xgg
> "
>



-- 



--
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] Nginx-uwsgi problem.

2011-09-17 Thread Michele Comitini
Hi Bruno!

Are you using threads or processes, sqlite or a rdbms?
Seems a timeout while web2py is trying to access some resource.

I suggest processes + rdbms (postgresql)

mic

2011/9/17 Bruno Rocha :
> I am getting a high traffic on the new service I released www.rifar.me
> I did not expected too much access, and now my server is running in
> problems.
> Anybody has any hint about this error?
> 2011/09/17 12:56:36 [error] 15855#0: *55651 upstream timed out (110:
> Connection timed out) while reading response header from upstream, client:
> 177.41.102.72, server: www.rifar.me, request: "GET
> /rifa/quadro-da-artista-plastica-vicky-von-dorff HTTP/1.1", upstream:
> "uwsgi://127.0.0.1:9012", host: "www.rifar.me"
> 2011/09/17 14:29:17 [error] 15853#0: *56788 upstream timed out (110:
> Connection timed out) while reading response header from upstream, client:
> 189.68.92.92, server: www.rifar.me, request: "GET
> /static/images/logo.resized.black.png HTTP/1.1", upstream:
> "uwsgi://127.0.0.1:9012", host: "www.rifar.me", referrer:
> "http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/5/1.0.35/br/pt-BR/controller.html";
> 2011/09/17 16:30:38 [error] 15853#0: *58681 upstream timed out (110:
> Connection timed out) while reading response header from upstream, client:
> 189.110.52.2, server: www.rifar.me, request: "GET
> /rifa/sapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor
> HTTP/1.1", upstream: "uwsgi://127.0.0.1:9012", host: "www.rifar.me",
> referrer:
> "http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.rifar.me%2Frifa%2Fsapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor&h=AAQADMJmAAQCEnatNdBzs3l6PmgbGhSfV55YaYbFO24_Xgg";


[web2py] Re: Why web2py is in French by default? How can I change it?

2011-09-17 Thread Anthony
OK, now I'm seeing the book in French rather than English as well (only in 
IE, not Chrome). The HTML source code is in English, so I guess it is being 
translated client-side via plugin_translate. I see the following in the head 
of the HTML:

 
 

I assume fr.js shouldn't be there.

Note, I haven't made any changes to my browser. One minute everything was in 
English, and upon a new page load, suddenly French.

Anthony

On Thursday, September 15, 2011 2:56:43 PM UTC-4, Massimo Di Pierro wrote:
>
> Is this about the book? 
>
> On Sep 15, 12:30 pm, Cliff  wrote: 
> > I'm seeing the problem too. 
> > 
> > On Sep 15, 4:08 am, Zhe Li  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hi, 
> > 
> > > I tried to find something in web2py book, but everything is in French 
> now. 
> > > (Wasn't like this yesterday) 
> > 
> > > I am sure I have set my browser to English, anything wrong? 
> > 
> > > Cheers, 
> > > Zhe



[web2py] register recepatcha not working

2011-09-17 Thread Avik Basu
I am using recaptcha using the following code (public and private keys not 
shown):

auth.settings.register_captcha = Recaptcha(request, '', 
'yy', use_ssl=False, error_message='please complete the reCaptcha')

I've registered with recaptcha.net and I not running this from a localhost. 
 Also, the above line is called after auth is instantiated.  The rest of the 
registration page looks right, but the recaptcha box does not show up.  Any 
ideas?

Thanks,
Avik


Re: [web2py] My Journey to web2py

2011-09-17 Thread Michele Comitini
Read first 3 chapters of web2py book  then start right away coding
with web2py do not waste time , look at the examples and search
through the web2py user group messages; most of what you are trying to
do has been already answered.


Don't learn OOP from Java books you would learn the partial OOP
implementation of Java.
Smalltalk, C++ are better, but since you have little time you can
learn python and OOP in one pass.

See some good advice here:
http://goo.gl/ubj6k


mic

2011/9/17 binaryghost :
> Before anything else, I would like to introduce myself.
>
> I am a passionate computer programmer.  I started to learn programming
> thru Turbo Pascal and learned the essential concepts in C.
>
> I learned C++ and Java in school but sad to say, I haven’t got a firm
> grip on those languages even thinking in object-oriented Manner.
>
> I have basic knowledge in RPG, VB.NET and SAP ABAP.
>
> I’ve decided to be more serious in my craft and upgrade my skills and
> learn most of technologies used to day.
>
> I decided to focus on learning python before learning Java and C++/
> directive C.
>
> So I am here to seek your help and assistance in learning web2py.  I
> will be working on a mini-project to create a simple project
> management tool for our team.
>
> To give you a basic idea of our requirement, our metrics database (in
> excel format) is coming from a website.  We download the excel file
> and extract data to it to come up with a meaningful information.  Our
> team also update excel files which are stored in a shared network
> drive to put updates on the development assigned to each one of and
> submit it to our clients.  So my basic requirements can be summarized
> into two:
>
> 1.      Download excel file from a website and extract and move the records
> in a RDBMS database (for easy report generation ).  I’m planning to
> solve this using irobotsoft and let python do the data extraction and
> database updates.  Is there a better idea?
> 2.      A website that will let users meaningful information from this
> database such as charts and excel grids.
> 3.      A website that will allow each use enter data in forms (like
> creating an inventory system)
>
> I only put the basic requirements since if I made these 3, the other
> features will not a problem.
>
> I made a research and decided to put my trust in web2py.  However,
> this is my first time to create a useful website and I have no
> knowledge in Python as well.  I’ve tried to skim the web2py book but
> can’t think how to put things together to create a full working
> website.
>
> I’m here to ask for you help how can I get started building this
> website.  I have basic knowledge in HTML only and know C.  Starting
> today, I will be learning python by reading Wesley Chun’s Core python
> book and will try to read some books related to OOP (most of them are
> Java books).  I’m giving myself 2 weeks to learn python and will start
> to work on this website and October and planning to finish it in a
> month.
> Any help and suggestions is highly appreciated.  In this thread, I’ll
> be sending updates on the progress and ask questions in case I get
> stuck.
>
> Thank you in advance for all your support! 
>
>
>


Re: [web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Jonathan Lundell
On Sep 17, 2011, at 1:24 PM, Anthony wrote:

> Sounds like this will be completely re-thought, so maybe comments on the 
> current (trunk) code aren't necessary, but here are some observations (not 
> sure if these are correct because I haven't tested anything, just quickly 
> looked at the code):
> It still looks like _auth_next will be the first URL visited during the 
> session, whether or not it requires login, but then it can't get overwritten. 
> So won't the redirect end up going to the first URL of the session rather 
> than the last URL right before login (we want the latter, no)?
> _auth_next is reset to None if it starts with the current URL, but don't we 
> want it to be an exact match for the current URL (including args and vars) in 
> order to conclude that the redirect has happened?
> I'm not sure I'm following properly, but does this involve an additional 
> redirect -- one immediately after login, and then another when that redirect 
> hits Auth.__init__?
> This is repeated many times:
> if is_relative(next):
> next = self.url(next.replace('[id]', str(form.vars.id))) 
> 
> Instead of the is_relative function, how about a replace_id function that 
> checks for a relative URL and does the replace? So, the above would just be:
> 
> next = replace_id(next,form)
>  
> 

What is the id logic, anyway? Some CRUD thing?

> Anthony
> 
> On Saturday, September 17, 2011 11:36:41 AM UTC-4, Massimo Di Pierro wrote:
> > It seems to me that there are two issues here. One is cleaning up the logic 
> > to make it uniform, DRY and understandable. The other is deciding where to 
> > put the next link (and doing proper validation of the URL). 
> > 
> > I understand (I think) the basic use case for @requires_login, I think. 
> > 
> > What's the use case for saving the return link in Auth()? 
> > 
> > Does it make sense to try to save a next link in cases like 
> > change-password? Profile editing? 
> > 
> > I'm fine with reverting for now, but I really think that this logic is due 
> > for a review and cleanup. 
> 
> I agree with that. I think we may have to release 1.99.1 with the 
> _next solution and then try improve it. 
> 
> > Maybe starting with a spec: what are we really trying to do? And how do 
> > these dynamic _next links relate to the various next-URL links in 
> > auth.settings? 
> 
> I will try write more about this later today. 
> 
> Massimo 




[web2py] Nginx-uwsgi problem.

2011-09-17 Thread Bruno Rocha
I am getting a high traffic on the new service I released www.rifar.me

I did not expected too much access, and now my server is running in
problems.

Anybody has any hint about this error?

2011/09/17 12:56:36 [error] 15855#0: *55651 upstream timed out (*110:
Connection timed out*) while reading response header from upstream, client:
177.41.102.72, server: www.rifar.me, request: "GET
/rifa/quadro-da-artista-plastica-vicky-von-dorff HTTP/1.1", upstream:
"uwsgi://127.0.0.1:9012", host: "www.rifar.me"

2011/09/17 14:29:17 [error] 15853#0: *56788 upstream timed out (110:
Connection timed out) while reading response header from upstream, client:
189.68.92.92, server: www.rifar.me, request: "GET
/static/images/logo.resized.black.png HTTP/1.1", upstream: "*uwsgi://
127.0.0.1:9012*", host: "www.rifar.me", referrer: "
http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/5/1.0.35/br/pt-BR/controller.html
"

2011/09/17 16:30:38 [error] 15853#0: *58681 upstream timed out (110:
Connection timed out) while reading response header from upstream, client:
189.110.52.2, server: www.rifar.me, request: "GET
/rifa/sapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor
HTTP/1.1", upstream: "uwsgi://127.0.0.1:9012", host: "www.rifar.me",
referrer: "
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.rifar.me%2Frifa%2Fsapato-piccadilly-novo-modelo-cor-e-tamanho-escolhidos-pelo-vencedor&h=AAQADMJmAAQCEnatNdBzs3l6PmgbGhSfV55YaYbFO24_Xgg
"


[web2py] Re: Why web2py is in French by default? How can I change it?

2011-09-17 Thread Cliff
Not about the book itself, but apparently fixed now.

All Google search hits that referenced the book came with
"language=fr" appended as a var.

I notice that the book does not rank high in Google searches.

Very strange.

On Sep 15, 2:56 pm, Massimo Di Pierro 
wrote:
> Is this about the book?
>
> On Sep 15, 12:30 pm, Cliff  wrote:
>
>
>
> > I'm seeing the problem too.
>
> > On Sep 15, 4:08 am, Zhe Li  wrote:
>
> > > Hi,
>
> > > I tried to find something in web2py book, but everything is in French now.
> > > (Wasn't like this yesterday)
>
> > > I am sure I have set my browser to English, anything wrong?
>
> > > Cheers,
> > > Zhe


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Anthony
Sounds like this will be completely re-thought, so maybe comments on the 
current (trunk) code aren't necessary, but here are some observations (not 
sure if these are correct because I haven't tested anything, just quickly 
looked at the code):

   - It still looks like _auth_next will be the first URL visited during the 
   session, whether or not it requires login, but then it can't get 
   overwritten. So won't the redirect end up going to the first URL of the 
   session rather than the last URL right before login (we want the latter, 
   no)?
   - _auth_next is reset to None if it starts with the current URL, but 
   don't we want it to be an exact match for the current URL (including args 
   and vars) in order to conclude that the redirect has happened?
   - I'm not sure I'm following properly, but does this involve an 
   additional redirect -- one immediately after login, and then another when 
   that redirect hits Auth.__init__?
   - This is repeated many times:

if is_relative(next):
next = self.url(next.replace('[id]', str(form.vars.id))) 

Instead of the is_relative function, how about a replace_id function that 
checks for a relative URL and does the replace? So, the above would just be:


next = replace_id(next,form)
 

Anthony

On Saturday, September 17, 2011 11:36:41 AM UTC-4, Massimo Di Pierro wrote:
>
> > It seems to me that there are two issues here. One is cleaning up the 
> logic to make it uniform, DRY and understandable. The other is deciding 
> where to put the next link (and doing proper validation of the URL). 
> > 
> > I understand (I think) the basic use case for @requires_login, I think. 
> > 
> > What's the use case for saving the return link in Auth()? 
> > 
> > Does it make sense to try to save a next link in cases like 
> change-password? Profile editing? 
> > 
> > I'm fine with reverting for now, but I really think that this logic is 
> due for a review and cleanup. 
>
> I agree with that. I think we may have to release 1.99.1 with the 
> _next solution and then try improve it. 
>
> > Maybe starting with a spec: what are we really trying to do? And how do 
> these dynamic _next links relate to the various next-URL links in 
> auth.settings? 
>
> I will try write more about this later today. 
>
> Massimo 
>


Re: [web2py] Python Exceptions: how to show in View

2011-09-17 Thread Bruno Rocha
try:
   #do something
except Exception, e:
   response.flash = "Error occured %s" % str(e)



On Sat, Sep 17, 2011 at 9:26 AM, Vineet  wrote:

> Regarding user data validation, I am comfortble with client-side
> validation.
> I also have server-side customized validation routines.
> I am aware that a token is issued for an error.
> Whenever an exception is raised server-side, what is the simplest way
> to show it in a messagebox or a DIV (maybe in "flash")?
>
> Regards,
> Vineet




-- 



--
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] SmartGrid and authentization required for view and edit actions ... why?

2011-09-17 Thread Bruno Rocha
I guess

SQLFORM.smartgrid(..., user_signature=False)

should not ask for user signature

but I do not recommend as your actions will be exposed for logged out users,
and you will not b able to track the changes or apply crud permissions.

On Sat, Sep 17, 2011 at 12:30 PM, David Marko  wrote:

> I'm  testing SQLFORM.smartgrid() feature ... I can see the list of items
> but when clicking on view or edit links, I can just see flash message 'not
> authorized' . Why is this? How can I avoid this or even how to handle
> autorization correctly ... where to define it. I can imagine many different
> scenarios like user can view item but can't edit etc.




-- 



--
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: problem with updating Form with writable=False Fields

2011-09-17 Thread pbreit
Just wanted to check if you know that Web2py that comes with a complete 
registration/login capability that works pretty well. You don't have to do 
any coding.

[web2py] Re: problem with updating Form with writable=False Fields

2011-09-17 Thread Alex
actually it's now working, I don't know exactly what was the reason
(I'm using record = db.auth_user(id))

when I output db._lastsql after form.accepts I see that all fields are
updated, not just the password field. How can I change it that only
the password field is updated in the sql statement?

On 17 Sep., 17:54, Alex  wrote:
> I forgot to mention the following: I create the row myself because I
> simply want to change the password:
> id = auth.user_id
> record = Row()
> record.id = id
> record.password = ''
>
> this row is then passed to SQLForm. If I do this instead:
> id = auth.user_id
> record = db.auth_user(id)
> record.password = ''
>
> the form.accepts tries to update all fields. But I would only like to
> update the password field and not modify any other fields.
>
> On 17 Sep., 17:46, Alex  wrote:
>
>
>
> > Hi,
>
> > first of all, many thanks to Massimo and all other contributers.
> > web2py is an amazing framework and exactly what I was looking for.
> > Keep up the excellent work!
>
> > I've got a couple of questions and problems so I'll start with the one
> > which is bugging me the most:
> > I've defined the auth_user table, added username, password and some
> > other fields. So far everything works fine. Now I want to create a
> > form where the user can change the password. In this form I do not
> > want to modify any of the other fields. So I'm doing the following
> > before creating the SQLForm (user_table == db.auth_user):
>
> > for field in user_table.fields:
> >   if field == 'password':
> >     user_table[field].readable = user_table[field].writable = True
> >   else:
> >     user_table[field].readable = user_table[field].writable =
> > False
>
> > this works fine, the form only contains the password field. But when I
> > submit the form, I end up with the following error:
> > File "C:\Tools\web2py_src\gluon\sqlhtml.py", line 1202, in accepts
> >     fields[field.name] = self.record[field.name]
> >   File "C:\Tools\web2py_src\gluon\dal.py", line 3777, in __getitem__
> >     return dict.__getitem__(self, key)
> > KeyError: 'registration_key'
>
> > so its trying to update a field which is writable==False. When I look
> > into the code in sqlhtml.py (line 1200) this is confusing me a little
> > bit:
> > for field in self.table:
> >   if not field.name in fields and field.writable==False:
> >     if record_id:
> >       fields[field.name] = self.record[field.name]
> >     elif self.table[field.name].default!=None:
> >       fields[field.name] = self.table[field.name].default
>
> > why is it checking writable==False? shouldn't it test for
> > writable==True or do I get something wrong here?
>
> > Alex


[web2py] Re: Adding radio buttons to customised form in web2py

2011-09-17 Thread Anthony
It's not in stable yet, but in trunk, you can now specify ul or divs style 
rather than table style for the radio widget. I think it would be:

db.payment_bpay_step1.selection_type.widget = lambda f, v: 
SQLFORM.widgets.radio.widget(f, v, style='divs')

You can also create a custom widget, as described at the end of this 
section: http://web2py.com/book/default/chapter/07#Widgets.

When you say you want the "innerhtml" to be different from the value of the 
radio button, are you talking about the label next to the radio button? For 
that, the IS_IN_SET validator takes a 'labels' argument, which is a list of 
labels associated with the options in the set.

Anthony


On Saturday, September 17, 2011 1:15:18 PM UTC-4, Brent Jacobs wrote:
>
> I'm trying to display a field as a radio button group in a customised 
> form.  I want to place each radio button on a different row in a 
> table.  The problem is when I use `{{=form.custom.selection_type[0]}} 
> `, the widget is wrapped in unwanted `tr` and `td` tags. 
>
> Is there a way to add only the radio input field without the 
> additional tags? Also, is it possible to have the innerhtml different 
> from the value of the radio button? 
>
> Thanks. 
>
> My view: 
>
> {{extend 'layout.html'}} 
> {{=form.custom.begin}} 
>  
>
>  {{=form.custom.selection_type[0]}}: 
>  {{=form.custom.widget.biller_list}} 
>
>
>  {{=form.custom.widget.selection_type[1]}}: 
>  {{=form.custom.widget.biller_code}} 
>
>  
> {{=form.custom.end}} 
>
> Example of what's happening in the html source code: 
>
>  
>
>   value="From my biller list" />From my biller list: 
> ... 
>
> ... 
>  
>
> My model: 
>
> db.define_table('payment_bpay_step1', 
> Field('selection_type', 'list:string'), 
> Field('biller_list', db.biller, notnull=True), 
> Field('biller_code'), 
> Field('biller_name')) 
> db.payment_bpay_step1.selection_type.requires = IS_IN_SET(('From 
> my biller list', 'Search by biller code', 'Search by biller name')) 
> db.payment_bpay_step1.selection_type.widget = 
> SQLFORM.widgets.radio.widget 
>


Re: [web2py] Re: Ask Web2py Groups: Has anyone here used web2py with JQuery Mobile?

2011-09-17 Thread António Ramos
i have bee using it and it works nice !!


2011/9/17 Pystar 

> Thanks for the link to the plugin. But I am at loss of how to use it.
> I have removed the "extend layout.html" directive in all my layout
> files and included "plugin_jqmobile/layout.html". But whenever I visit
> any of those pages, I see just a barebones page that looks like a html
> page without any css. How do I display IOS like icons and GUI? is
> there any documentation about this plugin? or what other thing do I
> have to do?
> Thanks
>
> On Sep 17, 3:06 pm, Anthony  wrote:
> > Check outhttp://web2py.com/plugins/plugin_jqmobile/about.
> >
> >
> >
> >
> >
> >
> >
> > On Saturday, September 17, 2011 9:45:19 AM UTC-4, Pystar wrote:
> >
> > > I would like to know if anyone here has  used web2py with JQuery
> > > Mobile? And what the experience was.
>


[web2py] Re: Ask Web2py Groups: Has anyone here used web2py with JQuery Mobile?

2011-09-17 Thread Pystar
Thanks for the link to the plugin. But I am at loss of how to use it.
I have removed the "extend layout.html" directive in all my layout
files and included "plugin_jqmobile/layout.html". But whenever I visit
any of those pages, I see just a barebones page that looks like a html
page without any css. How do I display IOS like icons and GUI? is
there any documentation about this plugin? or what other thing do I
have to do?
Thanks

On Sep 17, 3:06 pm, Anthony  wrote:
> Check outhttp://web2py.com/plugins/plugin_jqmobile/about.
>
>
>
>
>
>
>
> On Saturday, September 17, 2011 9:45:19 AM UTC-4, Pystar wrote:
>
> > I would like to know if anyone here has  used web2py with JQuery
> > Mobile? And what the experience was.


Re: [web2py] Determine whether or not jquery-ui is loaded

2011-09-17 Thread Jim Steil
I've done that already.  I was just asking because of some ideas I had 
about how to resolve this.


-Jim

On 9/17/2011 8:37 AM, Anthony wrote:
It sounds like we should just make this easier in SQLFORM.grid -- 
maybe submit an issue about this on Google 
Code: http://code.google.com/p/web2py/issues/list


On Saturday, September 17, 2011 1:14:04 AM UTC-4, Jim S wrote:

The reason I'm asking is because I'm looking for a way to modify
SQLFORM.grid in sqlhtml.py to get the icons to show up on the buttons
properly whether or not jquery-ui is loaded or not.  By default
SQLFORM.grid tries to use jquery-ui for the user interface.
 base.css in
web2py has a number of icons in an image map that provide the
images on
the buttons if jquery-ui is not installed.  The jquery-ui has an
image
map with the same icons names (at different locations) that
provide the
images if jquery-ui is availalbe and ui='jquery-ui' (the default) is
provided on creation of SQLFORM.grid.  The image map name differs
in the
two scenarios, but the image names are the same.

So, if I could figure out in SQLFORM.grid if jquery-ui is
available to
the app, then I could provide the proper image map name and get
the icon
names/locations set properly.  In addition, it appears that the
text of
the A element needs to be formatted differently depending on
whether or
not jquery-ui is used (and some other css needs to be applied).

All of this is a long drawn out explanation of why I want to be
able to
figure out, in SQLFORM.grid in sqlhtml.py whether or not jquery-ui is
available for me to use.  I was kinda hoping there would be
something in
the request object that would help me out, but I haven't been able to
find anything.

Sorry if this is confusing, I'm up late again (yes, I'm an old
dog) and
need some sleep.

 -JIm

On 9/16/2011 7:12 PM, pbreit wrote:
> You would only be able to figure it out if you had the HTML page
> transmit that info to you via a form submission, querystring
field, etc.
>
> But why do you need to do this? Don't you know whether or not
you are
> serving the library? I'm confused.



No virus found in this message.
Checked by AVG - www.avg.com 
Version: 10.0.1410 / Virus Database: 1520/3899 - Release Date: 09/15/11



--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell


[web2py] Adding radio buttons to customised form in web2py

2011-09-17 Thread Brent Jacobs
I'm trying to display a field as a radio button group in a customised
form.  I want to place each radio button on a different row in a
table.  The problem is when I use `{{=form.custom.selection_type[0]}}
`, the widget is wrapped in unwanted `tr` and `td` tags.

Is there a way to add only the radio input field without the
additional tags? Also, is it possible to have the innerhtml different
from the value of the radio button?

Thanks.

My view:

{{extend 'layout.html'}}
{{=form.custom.begin}}

  
 {{=form.custom.selection_type[0]}}:
 {{=form.custom.widget.biller_list}}
  
  
 {{=form.custom.widget.selection_type[1]}}:
 {{=form.custom.widget.biller_code}}
  

{{=form.custom.end}}

Example of what's happening in the html source code:


  
 From my biller list:
...
  
...


My model:

db.define_table('payment_bpay_step1',
Field('selection_type', 'list:string'),
Field('biller_list', db.biller, notnull=True),
Field('biller_code'),
Field('biller_name'))
db.payment_bpay_step1.selection_type.requires = IS_IN_SET(('From
my biller list', 'Search by biller code', 'Search by biller name'))
db.payment_bpay_step1.selection_type.widget =
SQLFORM.widgets.radio.widget


Re: [web2py] Re: web2py with jython on linux

2011-09-17 Thread Vasile Ermicioi
>
> Can you do import cPickle form a regular jython shell?

yes


steps to reproduce:
1)
install latest jython (2.5.2)
2)
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
jython web2py.py


Re: [web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Jonathan Lundell
On Sep 17, 2011, at 8:46 AM, Massimo Di Pierro wrote:

> The basic use case is this:
> User clicks on a link that requires_login and gets redirected to the
> login page. After login the user is redirected to the original
> requested page.
> Exceptions:
> - the login is outsourced to janrain
> - the login is outsourced to cas or other open-id
> - the login is not possible and the user must first register
> - after login is redirected to the intended page but the app logic
> finds this user has incomplete profile and redirects to profile
> editing (*)
> - what if the user is impersonating another user? (?)
> - the user is visiting a page that does not require login but LOADs a
> component that does (?)
> - the user is visiting a page that does not require login but IFRAMEs
> a  component that does
> - the user has another window open (**)
> (*) is not currently supported. (?) not sure if it works (**) worked
> with _next but not not with session._auth_next.

The old logic saves a next link in session in Auth(). What's that for?


[web2py] Re: problem with updating Form with writable=False Fields

2011-09-17 Thread Alex
I forgot to mention the following: I create the row myself because I
simply want to change the password:
id = auth.user_id
record = Row()
record.id = id
record.password = ''

this row is then passed to SQLForm. If I do this instead:
id = auth.user_id
record = db.auth_user(id)
record.password = ''

the form.accepts tries to update all fields. But I would only like to
update the password field and not modify any other fields.

On 17 Sep., 17:46, Alex  wrote:
> Hi,
>
> first of all, many thanks to Massimo and all other contributers.
> web2py is an amazing framework and exactly what I was looking for.
> Keep up the excellent work!
>
> I've got a couple of questions and problems so I'll start with the one
> which is bugging me the most:
> I've defined the auth_user table, added username, password and some
> other fields. So far everything works fine. Now I want to create a
> form where the user can change the password. In this form I do not
> want to modify any of the other fields. So I'm doing the following
> before creating the SQLForm (user_table == db.auth_user):
>
> for field in user_table.fields:
>   if field == 'password':
>     user_table[field].readable = user_table[field].writable = True
>   else:
>     user_table[field].readable = user_table[field].writable =
> False
>
> this works fine, the form only contains the password field. But when I
> submit the form, I end up with the following error:
> File "C:\Tools\web2py_src\gluon\sqlhtml.py", line 1202, in accepts
>     fields[field.name] = self.record[field.name]
>   File "C:\Tools\web2py_src\gluon\dal.py", line 3777, in __getitem__
>     return dict.__getitem__(self, key)
> KeyError: 'registration_key'
>
> so its trying to update a field which is writable==False. When I look
> into the code in sqlhtml.py (line 1200) this is confusing me a little
> bit:
> for field in self.table:
>   if not field.name in fields and field.writable==False:
>     if record_id:
>       fields[field.name] = self.record[field.name]
>     elif self.table[field.name].default!=None:
>       fields[field.name] = self.table[field.name].default
>
> why is it checking writable==False? shouldn't it test for
> writable==True or do I get something wrong here?
>
> Alex


[web2py] problem with updating Form with writable=False Fields

2011-09-17 Thread Alex
Hi,

first of all, many thanks to Massimo and all other contributers.
web2py is an amazing framework and exactly what I was looking for.
Keep up the excellent work!

I've got a couple of questions and problems so I'll start with the one
which is bugging me the most:
I've defined the auth_user table, added username, password and some
other fields. So far everything works fine. Now I want to create a
form where the user can change the password. In this form I do not
want to modify any of the other fields. So I'm doing the following
before creating the SQLForm (user_table == db.auth_user):

for field in user_table.fields:
  if field == 'password':
user_table[field].readable = user_table[field].writable = True
  else:
user_table[field].readable = user_table[field].writable =
False

this works fine, the form only contains the password field. But when I
submit the form, I end up with the following error:
File "C:\Tools\web2py_src\gluon\sqlhtml.py", line 1202, in accepts
fields[field.name] = self.record[field.name]
  File "C:\Tools\web2py_src\gluon\dal.py", line 3777, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'registration_key'

so its trying to update a field which is writable==False. When I look
into the code in sqlhtml.py (line 1200) this is confusing me a little
bit:
for field in self.table:
  if not field.name in fields and field.writable==False:
if record_id:
  fields[field.name] = self.record[field.name]
elif self.table[field.name].default!=None:
  fields[field.name] = self.table[field.name].default

why is it checking writable==False? shouldn't it test for
writable==True or do I get something wrong here?

Alex


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
Fixed a typo:

The basic use case is this:
User clicks on a link that requires_login and gets redirected to the
login page. After login the user is redirected to the original
requested page.
Exceptions:
- the login is outsourced to janrain
- the login is outsourced to cas or other open-id
- the login is not possible and the user must first register
- after login is redirected to the intended page but the app logic
finds this user has incomplete profile and redirects to profile
editing (*)
- what if the user is impersonating another user? (?)
- the user is visiting a page that does not require login but LOADs a
component that does (?)
- the user is visiting a page that does not require login but IFRAMEs
a  component that does
- the user has another window open (**)
(*) is not currently supported. (?) not sure if it works (**) worked
with _next but not not with session._auth_next.


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
The basic use case is this:

User clicks on a link that requires_login and gets redirected to the
login page. After login the user is redirected to the original
requested page.

Exceptions:
- the login is outsourced to janrain
- the login is outsourced to cas or other open-id
- the login is not possible and the user must first register
- after login is redirected to the intended page but the app logic
finds this user has incomplete profile and redirects to profile
editing (*)
- what if the user is impersonating another user? (?)
- the user is visiting a page that does not require login but LOADs a
component that does (?)
- the user is visiting a page that does not require login but LOADs a
component that does
- the user has another window open (**)

(*) is not currently supported. (?) not sure if it works (**) worked
with _next but not not with session._auth_next.



On Sep 17, 10:06 am, Jonathan Lundell  wrote:
> On Sep 17, 2011, at 7:51 AM, Massimo Di Pierro wrote:
>
> >> I also don't entirely understand this:
>
> >>     def pop_next(self):
> >>         next = current.session._auth_next
> >>         if next and next.startswith(URL()):
> >>             next = current.session._auth_next = None
> >>         return next
>
> >> The startswith test: are we simply saying that if the startswith test is 
> >> met, then we're already at the destination, so don't redirect?
>
> > I guess it go both ways.
>
> > I am worried the new session mechanism may break when multiple windows
> > are open, or when IFRAME and LOAD are used. I may have to revert this.
>
> It seems to me that there are two issues here. One is cleaning up the logic 
> to make it uniform, DRY and understandable. The other is deciding where to 
> put the next link (and doing proper validation of the URL).
>
> I understand (I think) the basic use case for @requires_login, I think.
>
> What's the use case for saving the return link in Auth()?
>
> Does it make sense to try to save a next link in cases like change-password? 
> Profile editing?
>
> I'm fine with reverting for now, but I really think that this logic is due 
> for a review and cleanup. Maybe starting with a spec: what are we really 
> trying to do? And how do these dynamic _next links relate to the various 
> next-URL links in auth.settings?


[web2py] Re: markmin vs. reST

2011-09-17 Thread Gour-Gadadhara Dasa
On Sat, 17 Sep 2011 08:37:45 -0700 (PDT)
Massimo Di Pierro
 wrote:

> Footnotes can be added easily
> and sublists too. It is on the todo list.

That's great. Thank you.

btw, hearing that markmin is more powerful than markdown, maybe it should be
renamed to MarkUp, or, at least, markmax. ;)


Sincerely,
Gour


-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature


[web2py] Re: markmin vs. reST

2011-09-17 Thread Massimo Di Pierro
More complex tables are not possible. Footnotes can be added easily
and sublists too. It is on the todo list.

On Sep 17, 10:05 am, Gour-Gadadhara Dasa  wrote:
> On Sat, 17 Sep 2011 07:59:44 -0700 (PDT)
> Massimo Di Pierro
>
>  wrote:
>
> > Our goals were:
> > - simpler then reST, similar to Markdown but more powerful
>
> That's good one...I like markdown as well.
>
> > - extensible
>
> Any more info about it?
>
> Do you find markmin semantically rich-enough for writing books like web2py 
> one?
>
> I wonder about footnotes, more complex tables, more subsubsections...
>
> Sincerely,
> Gour
>
> --
> “In the material world, conceptions of good and bad are
> all mental speculations…” (Sri Caitanya Mahaprabhu)
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
> It seems to me that there are two issues here. One is cleaning up the logic 
> to make it uniform, DRY and understandable. The other is deciding where to 
> put the next link (and doing proper validation of the URL).
>
> I understand (I think) the basic use case for @requires_login, I think.
>
> What's the use case for saving the return link in Auth()?
>
> Does it make sense to try to save a next link in cases like change-password? 
> Profile editing?
>
> I'm fine with reverting for now, but I really think that this logic is due 
> for a review and cleanup.

I agree with that. I think we may have to release 1.99.1 with the
_next solution and then try improve it.

> Maybe starting with a spec: what are we really trying to do? And how do these 
> dynamic _next links relate to the various next-URL links in auth.settings?

I will try write more about this later today.

Massimo


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread weheh
@sagar: FWIW, this is what I usually do:

def login():
 return dict(form=auth.login(next=request.vars._next or
auth.settings.login_next))

My site combines pages that don't require login with those that do.


[web2py] SmartGrid and authentization required for view and edit actions ... why?

2011-09-17 Thread David Marko
I'm  testing SQLFORM.smartgrid() feature ... I can see the list of items but 
when clicking on view or edit links, I can just see flash message 'not 
authorized' . Why is this? How can I avoid this or even how to handle 
autorization correctly ... where to define it. I can imagine many different 
scenarios like user can view item but can't edit etc.

[web2py] Re: Ask Web2py Groups: How to implement infinite login session

2011-09-17 Thread pbreit
Unsafe and unnecessary. Wouldn't 10 or 20 or 50 years be ok?

[web2py] Re: Data stored in memory

2011-09-17 Thread Anthony
Also, note that your 'results' dict will only persist for the duration of a 
single request. Each request is handled by a new thread (from a thread 
pool).

Anthony

On Saturday, September 17, 2011 11:06:14 AM UTC-4, Massimo Di Pierro wrote:
>
> On Sep 17, 6:31 am, Chris Rowson  wrote: 
> > Hi folks, 
> > 
> > I'm trying to get my head around what happens to data stored in memory 
> when 
> > it isn't needed anymore. 
> > 
> > Let me give you an example. Let's say I create a function which returns a 
>
> > dict called 'results' populated with data from an external source each 
> time 
> > a user registers (for instance let's say it has data returned from 
> geocoding 
> > the users postcode and providing info about the area). 
> > 
> > So the 'results' dict holds that data, it is used, and then what? Is the 
> > memory automatically freed up again when we finish with the data or does 
> it 
> > hang around in memory? 
>
> Yes. Python uses reference counting. Every variable is a pointer to a 
> memory location. It keeps tracks of how many pointers point to the 
> same location. 
>
> a = A() # one pointer 
> b = a # two pointers 
> c = a # three pointers 
>
> when you delete one the counter is decreased 
>
> b = 4 # now two variables (a,c) point to A() 
>
> when the counter is zero the object is freed. 
>
> This works great UNLESS the objects have circular references (a.x=a) 
> AND the object has a destructor (A.__del__). As long a you do not use 
> destructors (who needs them?) everything works great. 
>
>
>
>
>

[web2py] Re: markmin vs. reST

2011-09-17 Thread Gour-Gadadhara Dasa
On Sat, 17 Sep 2011 07:59:44 -0700 (PDT)
Massimo Di Pierro
 wrote:

> 
> Our goals were:
> - simpler then reST, similar to Markdown but more powerful

That's good one...I like markdown as well.

> - extensible

Any more info about it?

Do you find markmin semantically rich-enough for writing books like web2py one?

I wonder about footnotes, more complex tables, more subsubsections...


Sincerely,
Gour


-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature


Re: [web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Jonathan Lundell
On Sep 17, 2011, at 7:51 AM, Massimo Di Pierro wrote:

>> I also don't entirely understand this:
>> 
>> def pop_next(self):
>> next = current.session._auth_next
>> if next and next.startswith(URL()):
>> next = current.session._auth_next = None
>> return next
>> 
>> The startswith test: are we simply saying that if the startswith test is 
>> met, then we're already at the destination, so don't redirect?
> 
> I guess it go both ways.
> 
> I am worried the new session mechanism may break when multiple windows
> are open, or when IFRAME and LOAD are used. I may have to revert this.

It seems to me that there are two issues here. One is cleaning up the logic to 
make it uniform, DRY and understandable. The other is deciding where to put the 
next link (and doing proper validation of the URL).

I understand (I think) the basic use case for @requires_login, I think. 

What's the use case for saving the return link in Auth()? 

Does it make sense to try to save a next link in cases like change-password? 
Profile editing? 

I'm fine with reverting for now, but I really think that this logic is due for 
a review and cleanup. Maybe starting with a spec: what are we really trying to 
do? And how do these dynamic _next links relate to the various next-URL links 
in auth.settings? 

[web2py] Re: Data stored in memory

2011-09-17 Thread Massimo Di Pierro
On Sep 17, 6:31 am, Chris Rowson  wrote:
> Hi folks,
>
> I'm trying to get my head around what happens to data stored in memory when
> it isn't needed anymore.
>
> Let me give you an example. Let's say I create a function which returns a
> dict called 'results' populated with data from an external source each time
> a user registers (for instance let's say it has data returned from geocoding
> the users postcode and providing info about the area).
>
> So the 'results' dict holds that data, it is used, and then what? Is the
> memory automatically freed up again when we finish with the data or does it
> hang around in memory?

Yes. Python uses reference counting. Every variable is a pointer to a
memory location. It keeps tracks of how many pointers point to the
same location.

a = A() # one pointer
b = a # two pointers
c = a # three pointers

when you delete one the counter is decreased

b = 4 # now two variables (a,c) point to A()

when the counter is zero the object is freed.

This works great UNLESS the objects have circular references (a.x=a)
AND the object has a destructor (A.__del__). As long a you do not use
destructors (who needs them?) everything works great.






[web2py] Re: web2py with jython on linux

2011-09-17 Thread Massimo Di Pierro
Can you do import cPickle form a regular jython shell?

On Sep 17, 4:35 am, Vasile Ermicioi  wrote:
> gluon.storage line 15


[web2py] Re: markmin vs. reST

2011-09-17 Thread Massimo Di Pierro
Good question.

Our goals were:
- simpler then reST, similar to Markdown but more powerful
- support for HTML 5
- extensible
- avoid conflits with natural language as much as possible

In reST:
.. image:: images/biohazard.png
In Markmin
[[description  images/biohazard.png center 200px]]

In reST you cannot specify resize and location, works only for images,
there are weird .. :: all over the place. The Markmin syntax works
also for embedded videos.



On Sep 17, 3:24 am, Gour-Gadadhara Dasa  wrote:
> Hello!
>
> I see that markmin is kind of 'standard' markup supported in web2py, but I use
> reST markup and lot (even submitted feature request to Instant Press to 
> support
> it), but I wonder how does markmin, in general, compare with reST?
>
> I noticed that there is no support for footnotes, tables look pretty simple...
>
> Otoh, the web2py book is written in markmin...
>
> I read 'Why?' (http://web2py.com/examples/static/markmin.html), but wonder 
> what
> was e.g. wrong with reST which is quite strongly tied with Python community?
>
> Sincerely,
> Gour
>
> --
> “In the material world, conceptions of good and bad are
> all mental speculations…” (Sri Caitanya Mahaprabhu)
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


[web2py] Re: How to redirect user to original url he asked after login

2011-09-17 Thread Massimo Di Pierro
> I also don't entirely understand this:
>
>     def pop_next(self):
>         next = current.session._auth_next
>         if next and next.startswith(URL()):
>             next = current.session._auth_next = None
>         return next
>
> The startswith test: are we simply saying that if the startswith test is met, 
> then we're already at the destination, so don't redirect?

I guess it go both ways.

I am worried the new session mechanism may break when multiple windows
are open, or when IFRAME and LOAD are used. I may have to revert this.


[web2py] Re: Ask Web2py Groups: Has anyone here used web2py with JQuery Mobile?

2011-09-17 Thread Anthony
Check out http://web2py.com/plugins/plugin_jqmobile/about.

On Saturday, September 17, 2011 9:45:19 AM UTC-4, Pystar wrote:
>
> I would like to know if anyone here has  used web2py with JQuery 
> Mobile? And what the experience was.



[web2py] Ask Web2py Groups: Has anyone here used web2py with JQuery Mobile?

2011-09-17 Thread Pystar
I would like to know if anyone here has  used web2py with JQuery
Mobile? And what the experience was.


Re: [web2py] Determine whether or not jquery-ui is loaded

2011-09-17 Thread Anthony
It sounds like we should just make this easier in SQLFORM.grid -- maybe 
submit an issue about this on Google 
Code: http://code.google.com/p/web2py/issues/list

On Saturday, September 17, 2011 1:14:04 AM UTC-4, Jim S wrote:
>
> The reason I'm asking is because I'm looking for a way to modify 
> SQLFORM.grid in sqlhtml.py to get the icons to show up on the buttons 
> properly whether or not jquery-ui is loaded or not.  By default 
> SQLFORM.grid tries to use jquery-ui for the user interface.  base.css in 
> web2py has a number of icons in an image map that provide the images on 
> the buttons if jquery-ui is not installed.  The jquery-ui has an image 
> map with the same icons names (at different locations) that provide the 
> images if jquery-ui is availalbe and ui='jquery-ui' (the default) is 
> provided on creation of SQLFORM.grid.  The image map name differs in the 
> two scenarios, but the image names are the same.
>
> So, if I could figure out in SQLFORM.grid if jquery-ui is available to 
> the app, then I could provide the proper image map name and get the icon 
> names/locations set properly.  In addition, it appears that the text of 
> the A element needs to be formatted differently depending on whether or 
> not jquery-ui is used (and some other css needs to be applied).
>
> All of this is a long drawn out explanation of why I want to be able to 
> figure out, in SQLFORM.grid in sqlhtml.py whether or not jquery-ui is 
> available for me to use.  I was kinda hoping there would be something in 
> the request object that would help me out, but I haven't been able to 
> find anything.
>
> Sorry if this is confusing, I'm up late again (yes, I'm an old dog) and 
> need some sleep.
>
>  -JIm
>
> On 9/16/2011 7:12 PM, pbreit wrote:
> > You would only be able to figure it out if you had the HTML page 
> > transmit that info to you via a form submission, querystring field, etc.
> >
> > But why do you need to do this? Don't you know whether or not you are 
> > serving the library? I'm confused.
>
>

Re: [web2py] Data stored in memory

2011-09-17 Thread Chris Rowson
I had read a little about that already, but found myself a little confused
as to when an object does or does not continue to refer to another object as
described in reference counts. At least you've confirmed I'm on the right
track. I'll go back to the books.

Thank-you

Chris
On Sep 17, 2011 2:08 PM, "Vasile Ermicioi"  wrote:
> google for python garbage collection


Re: [web2py] Data stored in memory

2011-09-17 Thread Vasile Ermicioi
google for python garbage collection


[web2py] Python Exceptions: how to show in View

2011-09-17 Thread Vineet
Regarding user data validation, I am comfortble with client-side
validation.
I also have server-side customized validation routines.
I am aware that a token is issued for an error.
Whenever an exception is raised server-side, what is the simplest way
to show it in a messagebox or a DIV (maybe in "flash")?

Regards,
Vineet


[web2py] Data stored in memory

2011-09-17 Thread Chris Rowson
Hi folks,

I'm trying to get my head around what happens to data stored in memory when
it isn't needed anymore.

Let me give you an example. Let's say I create a function which returns a
dict called 'results' populated with data from an external source each time
a user registers (for instance let's say it has data returned from geocoding
the users postcode and providing info about the area).

So the 'results' dict holds that data, it is used, and then what? Is the
memory automatically freed up again when we finish with the data or does it
hang around in memory?

I'm pretty new to python and web2py, can anyone help me understand?

Thank you!

Chris


[web2py] My Journey to web2py

2011-09-17 Thread binaryghost
Before anything else, I would like to introduce myself.

I am a passionate computer programmer.  I started to learn programming
thru Turbo Pascal and learned the essential concepts in C.

I learned C++ and Java in school but sad to say, I haven’t got a firm
grip on those languages even thinking in object-oriented Manner.

I have basic knowledge in RPG, VB.NET and SAP ABAP.

I’ve decided to be more serious in my craft and upgrade my skills and
learn most of technologies used to day.

I decided to focus on learning python before learning Java and C++/
directive C.

So I am here to seek your help and assistance in learning web2py.  I
will be working on a mini-project to create a simple project
management tool for our team.

To give you a basic idea of our requirement, our metrics database (in
excel format) is coming from a website.  We download the excel file
and extract data to it to come up with a meaningful information.  Our
team also update excel files which are stored in a shared network
drive to put updates on the development assigned to each one of and
submit it to our clients.  So my basic requirements can be summarized
into two:

1.  Download excel file from a website and extract and move the records
in a RDBMS database (for easy report generation ).  I’m planning to
solve this using irobotsoft and let python do the data extraction and
database updates.  Is there a better idea?
2.  A website that will let users meaningful information from this
database such as charts and excel grids.
3.  A website that will allow each use enter data in forms (like
creating an inventory system)

I only put the basic requirements since if I made these 3, the other
features will not a problem.

I made a research and decided to put my trust in web2py.  However,
this is my first time to create a useful website and I have no
knowledge in Python as well.  I’ve tried to skim the web2py book but
can’t think how to put things together to create a full working
website.

I’m here to ask for you help how can I get started building this
website.  I have basic knowledge in HTML only and know C.  Starting
today, I will be learning python by reading Wesley Chun’s Core python
book and will try to read some books related to OOP (most of them are
Java books).  I’m giving myself 2 weeks to learn python and will start
to work on this website and October and planning to finish it in a
month.
Any help and suggestions is highly appreciated.  In this thread, I’ll
be sending updates on the progress and ask questions in case I get
stuck.

Thank you in advance for all your support! 




Re: [web2py] Re: web2py with jython on linux

2011-09-17 Thread Vasile Ermicioi
gluon.storage line 15


[web2py] markmin vs. reST

2011-09-17 Thread Gour-Gadadhara Dasa
Hello!

I see that markmin is kind of 'standard' markup supported in web2py, but I use
reST markup and lot (even submitted feature request to Instant Press to support
it), but I wonder how does markmin, in general, compare with reST?

I noticed that there is no support for footnotes, tables look pretty simple...

Otoh, the web2py book is written in markmin...

I read 'Why?' (http://web2py.com/examples/static/markmin.html), but wonder what
was e.g. wrong with reST which is quite strongly tied with Python community?


Sincerely,
Gour

-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature