[web2py] record representation using a non-id column?

2011-07-09 Thread niknok
I have another unique column in my table that I would like to use as
index for record representation.  How do I tell web2py to use another
index?

Ttrying to use like:
db.mytable.thisfield.represent = lambda id:
db.other(myidx).thatfield


[web2py] Re: PowerFormWizard 0.1.4 - Bug Fixes and auto_validation (+ a new plugin for grids)

2011-07-09 Thread niknok
Any suggestion how to make this work with multiple tables (ie. one-to-
many relationships)?

For example, auth_user and is linked to other tables which I would
like to view in other tabs?


On Jul 7, 5:27 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 UPDATE:

 auto_validate renamed to .validate()

 Now we have another method that allows this:

 return dict(form=PowerFormWizard(db.table).process(messages=['Sucess!','Fail
 try again']))

 which creates and auto validate the form returning the form itsef.

 Other thing I guess no one tought about is the use for single step forms:

 http://labs.blouweb.com/powerformwizard/default/singlestep

 You can use the plugin for one step (normal) forms, use the client side
 validation and layout!

 More comming...









 On Tue, Jul 5, 2011 at 6:53 AM, Bruno Rocha rochacbr...@gmail.com wrote:
  HI,

  I just finished the refactoring for PFWizard plugin, major bug fixes
  (thanks everyone testing and reporting)

  *# NOTES*
  - It works only wih web2py 1.97+
  - It works only for SQLFORM based forms, you have to pass a db.table
  - It does not works for Crud() , does not allows editing or delete yet (can
  you contribute?)
  - It receives any arg that SQLFORM receives

  *# FIXES*
  - Fixed Issue #2 - Now it works with tables which has '_' or '__' in
  fieldnames.
  - Fixed Issue #1 - Now it works with Python  2.6 - removed enumerate()
  - Ommit fields - Fixed issue, now you cam ommit fields with no break in
  validation (client and server side)
  - Code cleanup, PEP8 checkups # But I really does not matter about it :P

  *# FEATURES*
  - Added form.auto_validation method
  Now you don t need to always write if form.accepts()elif
  form.errors.
  Just use in this way:

   form = PowerFormWizard(db, steps)
  form.auto_validate()
  return dict(form=form)

  or
  # define flash message
  form.auto_validate(messages=['Yeah it works', 'Ops, error'])

  or

  #execute a function after validation
  def myfunction(success, x,y,z):
       #first argument receives True or False
  

  form.auto_validate(flash=my_function, args=[x, y, z])

  DEMO  DOWNLOAD :http://labs.blouweb.com/powerformwizard
  REPO:https://bitbucket.org/rochacbruno/powerformwizard

  *# Whats next?*
  working on a new plugin for the 'Power' family, it is a JSON based
  tableless grid (which is much more than a grid)
  hope to release with examples, by the end of the week, preview -
 http://labs.blouweb.com/PowerGrid

  Need help, contribution, test..

  []'s
  --
  Bruno Rocha
  [ About me:http://zerp.ly/rochacbruno]

 --

 --
 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: Demystifying some web2py magic

2011-07-09 Thread Iceberg
Good to know that.

One thing though. If track_changes() is that good, how about we always
put it in every app's db.py? Any pros and cons?

Thanks in advance.

Regards,
Iceberg

On Jul 9, 3:20 am, Anthony abasta...@gmail.com wrote:
 local_import should work, but you should now use regular import statements
 instead. If you want your modules reloaded automatically, do the following:

 from gluon.custom_import import track_changes
 track_changes()

 That will reload your modules, but only when they change (which is an
 improvement over local_import, which will reload whether or not there are
 changes). Note, I believe the above will affect all applications. To turn
 off reloading, do:

 track_changes(track=False)

 And to test whether changes are currently being tracked:

 from gluon.custom_import import track_changes, is_tracking_changes
 if not is_tracking_changes():
     track_changes()

 Anthony







 On Friday, July 8, 2011 3:06:07 PM UTC-4, Jim S wrote:
  Hi

  I have a utility module that I use regularly where I put some of my
  application-specific helper functions.  What is the proper way to import
  this to make it available in my controllers and views?

  I've tried the local_import in db.py but have seen references on this list
  that recommend against using that.  This method had the reload=True option
  that allowed me to make changes to my utility module and not have to restart
  the web2py server to make the changes visible.  

  If I recall correctly (and I certainly could be wrong), the preferred
  method is to now use import.  But, using this method I have to restart
  web2py every time I make a change so I can see the results.

  Can someone please tell me how I can import a module and have it reload
  automatically like local_import('module', reload=True) does?  Or, should I
  still be using local_import when I want reloading to occur?

  Thanks

      -Jim


[web2py] Google app engine and DAL

2011-07-09 Thread Shark
I need help in updating list field can anyone give example of how to
update list field ?

also I have problem in uploading files in GAE as web2py store them in
files and google app engine need to store them in big table

thanks in advance




[web2py] login problem

2011-07-09 Thread LightOfMooN
Hello.
I'm trying to make a login viewlet.

So, I have function in controller default:
def login():
return dict(form=auth.login())

And view:
div id=log_menu
{{if not auth.user:}}
form action= enctype=multipart/form-data method=POST
div
Logininput name=username type=text value= /
/div
div
Passwordinput name=password type=password value= /
/div
div
input name=remember type=checkbox value=on
checked=checkedremember me
/div
{{=form.hidden_fields()}}
div
input class=formbutton type=submit value=login
/div
/form
{{else:}}
a href={{=URL('default','user',args='logout')}}logout/a
{{pass}}
/div

By url /default/login it works fine, but when I include it in
layout.html with
{{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}}
it doesn't log user in.

How to make it works? thx


[web2py] Re: login problem

2011-07-09 Thread Anthony
Try adding ajax_trap=True to your LOAD call. Without that, your form will be 
posted to the action of the parent page, which is not prepared to process 
the login submission. ajax_trap=True will post the form submission back to 
the login() action. Or you can just use ajax=True for the login component.
 
Anthony

On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote:

 Hello. 
 I'm trying to make a login viewlet. 

 So, I have function in controller default: 
 def login(): 
 return dict(form=auth.login()) 

 And view: 
 div id=log_menu 
 {{if not auth.user:}} 
 form action= enctype=multipart/form-data method=POST 
 div 
 Logininput name=username type=text value= / 
 /div 
 div 
 Passwordinput name=password type=password value= / 
 /div 
 div 
 input name=remember type=checkbox value=on 
 checked=checkedremember me 
 /div 
 {{=form.hidden_fields()}} 
 div 
 input class=formbutton type=submit value=login 
 /div 
 /form 
 {{else:}} 
 a href={{=URL('default','user',args='logout')}}logout/a 
 {{pass}} 
 /div 

 By url /default/login it works fine, but when I include it in 
 layout.html with 
 {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}} 
 it doesn't log user in. 

 How to make it works? thx



[web2py] Re: Google app engine and DAL

2011-07-09 Thread Anthony
On Saturday, July 9, 2011 8:07:48 AM UTC-4, Shark wrote: 

 I need help in updating list field can anyone give example of how to 
 update list field ? 

 also I have problem in uploading files in GAE as web2py store them in 
 files and google app engine need to store them in big table

 
web2py is supposed to store uploaded files in the datastore -- are you 
saying that's not happening? See 
http://web2py.com/book/default/chapter/11#Avoid-the-Filesystem.
 
Anthony


[web2py] Re: login problem

2011-07-09 Thread LightOfMooN
So, I changed LOAD to {{=LOAD('default','login', vars=request.vars,
ajax_trap=True, ajax=False)[0][0]}}
but it stays not to log in.
I add {{=BEAUTIFY(request.vars)}} in the default/login.html
When I click on submit, I see, that vars contains just password,
remember and username.
There are no vars from {{=form.hidden_fields()}}


On 9 июл, 19:29, Anthony abasta...@gmail.com wrote:
 Try adding ajax_trap=True to your LOAD call. Without that, your form will be
 posted to the action of the parent page, which is not prepared to process
 the login submission. ajax_trap=True will post the form submission back to
 the login() action. Or you can just use ajax=True for the login component.

 Anthony







 On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote:
  Hello.
  I'm trying to make a login viewlet.

  So, I have function in controller default:
  def login():
      return dict(form=auth.login())

  And view:
  div id=log_menu
  {{if not auth.user:}}
      form action= enctype=multipart/form-data method=POST
      div
          Logininput name=username type=text value= /
      /div
      div
          Passwordinput name=password type=password value= /
      /div
      div
          input name=remember type=checkbox value=on
  checked=checkedremember me
      /div
      {{=form.hidden_fields()}}
      div
          input class=formbutton type=submit value=login
      /div
      /form
  {{else:}}
      a href={{=URL('default','user',args='logout')}}logout/a
  {{pass}}
  /div

  By url /default/login it works fine, but when I include it in
  layout.html with
  {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}}
  it doesn't log user in.

  How to make it works? thx


[web2py] Re: Command-line support

2011-07-09 Thread Cliff
I appreciate the way Web2py initializes projects.  I don't have to
learn Yet Another Command Set.

On Jul 6, 2:48 pm, (m) mithatko...@gmail.com wrote:
 Massimo, thanks for the post -- it clarifies some of what you said on
 09 Nov 2010. I actually revived this thread to see if anyone had
 collected these under one interface, e.g.:

 web2py_manage --newapp=APPNAME
   Makes a new directory applications/APPNAME and copies scaffolding
 there.

 web2py_manage --newcontroller=CONTROLLER_NAME [--appname=APPNAME]
   Makes a new file CONTROLLER_NAME.py in applications/$APPNAME/
 controllers
   (or . if APPNAME isn't given) and places template code in the new
   file consisting of an index action.
   Makes a new dir applications/APPNAME/views/CONTROLLER_NAME and
 places
   a template index.html file in it.

 web2py_manage --newmodel=MODEL_NAME [--appname APPNAME]
   Makes a new file MODEL_NAME.py in applications/APPNAME/models
   (or . if APPNAME isn't given) and maybe sticks some template code in
 there
   with CRUD and authorization imports.

 etc.

 I can bash something together in an evening (or py it out as a
 learning exercise), but if the wheel already exists ...


[web2py] Datatables, jqgrid

2011-07-09 Thread Roberto Perdomo
Hi, i need know how is your experience in the use of javascript tables.

I like to do a system and need a good table that can update and delete record 
from the client size.

the table must be localizated in jquery ui tabs. I do tabs with powertables, 
but when put the table in  a tab inside other tab, the table lost the column 
size, somebosy knows why?

Thanks

Enviado de Samsung Mobile

[web2py] Re: login problem

2011-07-09 Thread Anthony
Not sure what the problem is. Is your login view login.html or login.load? 
If the latter, your LOAD call should include 'login.load' (otherwise it will 
default to 'load.html').
 
You might also consider using the form.custom elements to build your form 
rather than doing everything manually, as described here: 
http://web2py.com/book/default/chapter/07#Custom-forms. For example, 
form.custom.end will do the same thing as form.hidden_fields(), but will 
also add the closing /form tag.
 
Anthony

On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote:

 So, I changed LOAD to {{=LOAD('default','login', vars=request.vars, 
 ajax_trap=True, ajax=False)[0][0]}} 
 but it stays not to log in. 
 I add {{=BEAUTIFY(request.vars)}} in the default/login.html 
 When I click on submit, I see, that vars contains just password, 
 remember and username. 
 There are no vars from {{=form.hidden_fields()}} 


 On 9 июл, 19:29, Anthony abas...@gmail.com wrote: 
  Try adding ajax_trap=True to your LOAD call. Without that, your form will 
 be 
  posted to the action of the parent page, which is not prepared to process 

  the login submission. ajax_trap=True will post the form submission back 
 to 
  the login() action. Or you can just use ajax=True for the login 
 component. 
  
  Anthony 
  
  
  
  
  
  
  
  On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote: 
   Hello. 
   I'm trying to make a login viewlet. 
  
   So, I have function in controller default: 
   def login(): 
   return dict(form=auth.login()) 
  
   And view: 
   div id=log_menu 
   {{if not auth.user:}} 
   form action= enctype=multipart/form-data method=POST 
   div 
   Logininput name=username type=text value= / 
   /div 
   div 
   Passwordinput name=password type=password value= / 
   /div 
   div 
   input name=remember type=checkbox value=on 
   checked=checkedremember me 
   /div 
   {{=form.hidden_fields()}} 
   div 
   input class=formbutton type=submit value=login 
   /div 
   /form 
   {{else:}} 
   a href={{=URL('default','user',args='logout')}}logout/a 
   {{pass}} 
   /div 
  
   By url /default/login it works fine, but when I include it in 
   layout.html with 
   {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}} 
   it doesn't log user in. 
  
   How to make it works? thx



Re: [web2py] Re: URL() unexpectedly including app name in URLs

2011-07-09 Thread Jonathan Lundell
On Jul 8, 2011, at 6:06 PM, Bruno Rocha wrote:
 On Fri, Jul 8, 2011 at 8:01 PM, Jonathan Lundell jlund...@pobox.com wrote:
 It depends on your configuration. If apache/nginx is handling static files 
 directly, then web2py never sees it. Otherwise it does.
 
 question:
 i
 How is the best way for testing if nginx is really handling /static directly 
 and web2py is not being loaded for it?
 
 may be:
 
 if request.function == 'static':
 #do something
 
 then request some static files and watch if #something is processed?
 
 or is there a better way?  
 

That might be the easiest way, but not in an app, since static requests never 
get that far. Do something in the

 if static_file:

clause in gluon.main.

It's possible that you could detect who's serving the file from the headers, 
too. Try turning nginx's handling of static files off and see if the response 
headers change.



[web2py] Re: login problem

2011-07-09 Thread LightOfMooN
ajax=True doesn't work too

I make it clear:
layout.html
{{=LOAD('default','login2',vars=request.vars, ajax=True)}}

default/login.html:
div id=log_menu
{{=BEAUTIFY(request.vars)}}
{{if not auth.user:}}
{{=form}}
{{else:}}
a href={{=URL('default','user',args='logout')}}logout/a
{{pass}}
/div

default.py:
def login2():
form=auth.login()
return dict(form=form)

And it doesn't work with LOAD()(doesn't matter ajax=False/True,
ajax_trap=False/True, I tried all)
Even if I click on submit, there are no vars from form.hidden_fields()
displayed.

On 9 июл, 20:47, Anthony abasta...@gmail.com wrote:
 Not sure what the problem is. Is your login view login.html or login.load?
 If the latter, your LOAD call should include 'login.load' (otherwise it will
 default to 'load.html').

 You might also consider using the form.custom elements to build your form
 rather than doing everything manually, as described 
 here:http://web2py.com/book/default/chapter/07#Custom-forms. For example,
 form.custom.end will do the same thing as form.hidden_fields(), but will
 also add the closing /form tag.

 Anthony







 On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote:
  So, I changed LOAD to {{=LOAD('default','login', vars=request.vars,
  ajax_trap=True, ajax=False)[0][0]}}
  but it stays not to log in.
  I add {{=BEAUTIFY(request.vars)}} in the default/login.html
  When I click on submit, I see, that vars contains just password,
  remember and username.
  There are no vars from {{=form.hidden_fields()}}

  On 9 июл, 19:29, Anthony abas...@gmail.com wrote:
   Try adding ajax_trap=True to your LOAD call. Without that, your form will
  be
   posted to the action of the parent page, which is not prepared to process

   the login submission. ajax_trap=True will post the form submission back
  to
   the login() action. Or you can just use ajax=True for the login
  component.

   Anthony

   On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote:
Hello.
I'm trying to make a login viewlet.

So, I have function in controller default:
def login():
    return dict(form=auth.login())

And view:
div id=log_menu
{{if not auth.user:}}
    form action= enctype=multipart/form-data method=POST
    div
        Logininput name=username type=text value= /
    /div
    div
        Passwordinput name=password type=password value= /
    /div
    div
        input name=remember type=checkbox value=on
checked=checkedremember me
    /div
    {{=form.hidden_fields()}}
    div
        input class=formbutton type=submit value=login
    /div
    /form
{{else:}}
    a href={{=URL('default','user',args='logout')}}logout/a
{{pass}}
/div

By url /default/login it works fine, but when I include it in
layout.html with
{{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}}
it doesn't log user in.

How to make it works? thx


[web2py] Re: Demystifying some web2py magic

2011-07-09 Thread pbreit
I have a 0.py file that is versioned for production and development (mainly 
to use postgres on prod and sqlite in dev). I put track_changes() in my dev 
file.

[web2py] Re: Apache, Wsgi problem

2011-07-09 Thread pbreit
That's fine. But it makes your opinion irrelevant. Very few program in 
isolation.

[web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jim Karsten
When controller2 is called it redirects to controller1. The session.flash 
message is lost. Any suggestions for how to prevent the response.flash from 
clobbering the session.flash?

def controller1():
form = 
SQLFORM.factory(Field('myfield'))
if 
form.accepts(request.vars,session):  
response.flash = 'Record 
updated'   
elif 
form.errors:   
response.flash = 'Form contains 
errors' 

else:   
response.flash = 'Please fill in the 
form'  
return 
dict(form=form)  


def 
controller2():  
session.flash = 'Message from session 
flash.'   
redirect(URL('controller1'))


Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jonathan Lundell
On Jul 9, 2011, at 10:46 AM, Jim Karsten wrote:
 When controller2 is called it redirects to controller1. The session.flash 
 message is lost. Any suggestions for how to prevent the response.flash from 
 clobbering the session.flash?
 
 def controller1():
 form = SQLFORM.factory(Field('myfield'))  
   
 if form.accepts(request.vars,session):
   
 response.flash = 'Record updated' 
   
 elif form.errors: 
   
 response.flash = 'Form contains errors'   
   
 else: 
   
 response.flash = 'Please fill in the form'
   
 return dict(form=form)
   
   
   
 def controller2():
   
 session.flash = 'Message from session flash.' 
   
 redirect(URL('controller1'))

Try removing the else: clause in controller1. 

[web2py] Re: New Plugin: plugin_ckeditor

2011-07-09 Thread cjrh
Very nice. I'm thinking how this is going to be immediately useful in a blog 
context for non-technical authors.

Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jim Karsten
Yeah, I'm aware of that. However, what if I want that message when 
controller1 is called on its own, not as a redirect from controller2. In the 
example I provided the message isn't very useful, but in some case the
message can be.


[web2py] Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread weheh
I've been running python 2.5 with web2py forever. Now, for good
reason, I am trying to upgrade to python 2.7. However, when invoking
web2py thus:

c:/Program Files (x86)/Python27/python.exe web2py.py -a password -i
127.0.0.1 -p 8000

I get a traceback:

Traceback (most recent call last):
  File web2py.py, line 20, in module
import gluon.widget
  File N:\web2py\gluon\widget.py, line 19, in module
import socket
  File c:\Program Files (x86)\Python27\lib\socket.py, line 47, in
module
import _socket
ImportError: Module use of python25.dll conflicts with this version of
Python.


Can someone suggest how to get past this issue? Thanks.


Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jonathan Lundell
On Jul 9, 2011, at 11:52 AM, Jim Karsten wrote:
 Yeah, I'm aware of that. However, what if I want that message when 
 controller1 is called on its own, not as a redirect from controller2. In the 
 example I provided the message isn't very useful, but in some case the
 message can be.

When would it be useful? If you need user instructions, why not just put them 
somewhere on the page, and not commandeer flash for the purpose?

(Before the controller is called, session.flash is copied to response.flash and 
session.flash is set to None. You could check whether there's something in 
response.flash and not clobber it, if you liked.)

[web2py] Re: Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread cjrh
I am guessing you are using the binary version of web2py for windows, but 
you should use the source distribution if you want to execute the web2py 
file directly?

[web2py] Re: Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread weheh
Sounds reasonable. I'll give it a try.

On Jul 9, 3:20 pm, cjrh caleb.hatti...@gmail.com wrote:
 I am guessing you are using the binary version of web2py for windows, but
 you should use the source distribution if you want to execute the web2py
 file directly?


[web2py] Re: Google app engine and DAL

2011-07-09 Thread Shark
Ok thank very much Anthony

On Jul 9, 4:32 pm, Anthony abasta...@gmail.com wrote:
 On Saturday, July 9, 2011 8:07:48 AM UTC-4, Shark wrote:

  I need help in updating list field can anyone give example of how to
  update list field ?

  also I have problem in uploading files in GAE as web2py store them in
  files and google app engine need to store them in big table

 web2py is supposed to store uploaded files in the datastore -- are you
 saying that's not happening? 
 Seehttp://web2py.com/book/default/chapter/11#Avoid-the-Filesystem.

 Anthony


[web2py] Re: Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread weheh
I gave it a try. Almost, but no cigar:

ERROR:root:missing ldap, try easy_install python-ldap
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql
Starting hardcron...


Then I ran into trouble with easy_install not working:
python c:\Program Files (x86)\Python27\lib\site-packages\easy_install.py 
python-ldap
Searching for python-ldap
Reading http://pypi.python.org/simple/python-ldap/
Reading http://www.python-ldap.org/
Best match: python-ldap 2.4.1
Downloading http://pypi.python.org/packages/source/p/python-ldap/python-ldap-2.4
.1.tar.gz#md5=be20381013b28679b57a0285e053f8ef
Processing python-ldap-2.4.1.tar.gz
Running python-ldap-2.4.1\setup.py -q bdist_egg --dist-dir c:\users
\weheh\appdat
a\local\temp\easy_install-hvyccy\python-ldap-2.4.1\egg-dist-tmp-ovjtnf
extra_compile_args: -g
extra_objects:
include_dirs: /opt/openldap-RE24/include /usr/include/sasl
library_dirs: /opt/openldap-RE24/lib
libs: ldap_r lber sasl2 ssl crypto
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\controls.py (for module ldap.controls) not found
file Lib\ldap\extop.py (for module ldap.extop) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules\LICENSE'
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\controls.py (for module ldap.controls) not found
file Lib\ldap\extop.py (for module ldap.extop) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\controls.py (for module ldap.controls) not found
file Lib\ldap\extop.py (for module ldap.extop) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
error: Setup script exited with error: Python was built with Visual
Studio 2003;

extensions must be built with a compiler than can generate compatible
binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin
installed,
you can try compiling with MingW32, by passing -c mingw32 to
setup.py.


I think that's the end of the line for me unless someone has a better
idea. I'm going to try to backtrack to python 2.5.4.


On Jul 9, 3:23 pm, weheh richard_gor...@verizon.net wrote:
 Sounds reasonable. I'll give it a try.

 On Jul 9, 3:20 pm, cjrh caleb.hatti...@gmail.com wrote:







  I am guessing you are using the binary version of web2py for windows, but
  you should use the source distribution if you want to execute the web2py
  file directly?


[web2py] Re: Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread cjrh
Use the binary installer for python-ldap rather:

http://pypi.python.org/pypi/python-ldap/2.4.0

(for your version of Python, i.e. 2.7).

easy_install quite often doesn't work on Windows because libs that use 
C-extensions require compiling and there isn't usually a C compiler around.


[web2py] Re: login problem

2011-07-09 Thread Anthony
What happens if you remove vars=request.vars from LOAD()?

On Jul 9, 11:52 am, LightOfMooN vladsale...@yandex.ru wrote:
 ajax=True doesn't work too

 I make it clear:
 layout.html
 {{=LOAD('default','login2',vars=request.vars, ajax=True)}}

 default/login.html:
 div id=log_menu
 {{=BEAUTIFY(request.vars)}}
 {{if not auth.user:}}
     {{=form}}
 {{else:}}
     a href={{=URL('default','user',args='logout')}}logout/a
 {{pass}}
 /div

 default.py:
 def login2():
     form=auth.login()
     return dict(form=form)

 And it doesn't work with LOAD()    (doesn't matter ajax=False/True,
 ajax_trap=False/True, I tried all)
 Even if I click on submit, there are no vars from form.hidden_fields()
 displayed.

 On 9 июл, 20:47, Anthony abasta...@gmail.com wrote:



  Not sure what the problem is. Is your login view login.html or login.load?
  If the latter, your LOAD call should include 'login.load' (otherwise it will
  default to 'load.html').

  You might also consider using the form.custom elements to build your form
  rather than doing everything manually, as described 
  here:http://web2py.com/book/default/chapter/07#Custom-forms. For example,
  form.custom.end will do the same thing as form.hidden_fields(), but will
  also add the closing /form tag.

  Anthony

  On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote:
   So, I changed LOAD to {{=LOAD('default','login', vars=request.vars,
   ajax_trap=True, ajax=False)[0][0]}}
   but it stays not to log in.
   I add {{=BEAUTIFY(request.vars)}} in the default/login.html
   When I click on submit, I see, that vars contains just password,
   remember and username.
   There are no vars from {{=form.hidden_fields()}}

   On 9 июл, 19:29, Anthony abas...@gmail.com wrote:
Try adding ajax_trap=True to your LOAD call. Without that, your form 
will
   be
posted to the action of the parent page, which is not prepared to 
process

the login submission. ajax_trap=True will post the form submission back
   to
the login() action. Or you can just use ajax=True for the login
   component.

Anthony

On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote:
 Hello.
 I'm trying to make a login viewlet.

 So, I have function in controller default:
 def login():
     return dict(form=auth.login())

 And view:
 div id=log_menu
 {{if not auth.user:}}
     form action= enctype=multipart/form-data method=POST
     div
         Logininput name=username type=text value= /
     /div
     div
         Passwordinput name=password type=password value= /
     /div
     div
         input name=remember type=checkbox value=on
 checked=checkedremember me
     /div
     {{=form.hidden_fields()}}
     div
         input class=formbutton type=submit value=login
     /div
     /form
 {{else:}}
     a href={{=URL('default','user',args='logout')}}logout/a
 {{pass}}
 /div

 By url /default/login it works fine, but when I include it in
 layout.html with
 {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}}
 it doesn't log user in.

 How to make it works? thx


Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jim Karsten
You could check whether there's something in response.flash and not clobber 
it, if you liked. Do this in a models file, for example? 

Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jonathan Lundell
On Jul 9, 2011, at 1:50 PM, Jim Karsten wrote:
 You could check whether there's something in response.flash and not clobber 
 it, if you liked. Do this in a models file, for example?

No, it's done before the models. When the request comes in, the core logic does:

response.flash = session.flash  # normally None
session.flash = None

Something like this:

def controller1():
form = SQLFORM.factory(Field('myfield'))
if form.accepts(request.vars,session):  
response.flash = 'Record updated'   
elif form.errors:   
response.flash = 'Form contains errors' 
elif not response flash:
   
response.flash = 'Please fill in the form'  
return dict(form=form)  

def controller2():  
session.flash = 'Message from session flash.'   
redirect(URL('controller1'))

Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jim Karsten
Ah, I see. Ok, i'll give that some thought.


Re: [web2py] Reponse.flash clobbers session.flash

2011-07-09 Thread Jonathan Lundell
On Jul 9, 2011, at 2:01 PM, Jim Karsten wrote:
 Ah, I see. Ok, i'll give that some thought.

Also, ask: what are you really trying to do? In particular, in the case where 
you've got incoming session.flash text, and you're also setting your own new 
text into response.flash, what do you want to happen on the screen?



[web2py] Error in pypy web2py.py but not in python web2py.py something about __builtins__ type dict not module

2011-07-09 Thread cjrh
Hi group

In gluon/compileapp.py, around line 240, this line:

__builtins__['__import__'] = __builtin__.__import__

is causing problems with pypy, seemingly all of a sudden.  I haven't 
backtracked to see which version it was still working in, but the weird 
thing is that when web2py is started with python web2py.py (2.7) then 
print type(__builtins__) says dict (but only in certain units??), but 
starting with pypy web2py.py then print type(__builtins__) says 
module.   module is obviously correct, and I don't know how it becomes a 
dict in the context of compileapp.py. 

Has anyone a quick hint to solve this puzzle for me, before I try to figure 
this out in more detail?  Is anything special about what happens to 
__builtins__?  For one thing, if __builtins__ really is of type module, 
then it can't have dict-like key access, and that is the bit that fails when 
launching the code with pypy, but I can't seem to find anywhere in the code 
where anything special is done to a reference of __builtins__.


[web2py] Re: Python 2.5 and python 2.7 conflict within web2py?

2011-07-09 Thread weheh
Thanks cjrh. I'm back on 2.5.4 and will probably sit here for awhile
longer since I got going what I wanted to get going. Your help is much
appreciated but I won't be able to test this out 'til a little later.
Cheers.

On Jul 9, 4:15 pm, cjrh caleb.hatti...@gmail.com wrote:
 Use the binary installer for python-ldap rather:

 http://pypi.python.org/pypi/python-ldap/2.4.0

 (for your version of Python, i.e. 2.7).

 easy_install quite often doesn't work on Windows because libs that use
 C-extensions require compiling and there isn't usually a C compiler around.


[web2py] web2py with vbulletin authentication

2011-07-09 Thread Ben W.
Has anyone setup a web2py site using an existing vbulletin forum
authentication scheme?
Just figured would ask before I re-invent the wheel.
The Googles provided nothing useful when I did some searching.

Thanks.


[web2py] question about service

2011-07-09 Thread weheh
Let's say I wanted to build myapp that enabled someone else POST a
jpeg to myapp and get back a jpeg stream or a URL where the jpeg
stream could be gotten? Or both, if possible. What would be the most
efficient way of doing that?

Is this the sort of thing that services are good at? I re-read the
services section of the manual but didn't see anything that would lead
me to believe that a service is the way to go here. Can someone give
me a pointer?

Thanks.


[web2py] auth with OpenID - auth.environment.URL(...) error

2011-07-09 Thread Brian M
So I thought I'd mess around with using OpenID for authentication and 
followed the info Will provided in an older 
posthttps://groups.google.com/forum/#!topic/web2py/So79E4FDWLk. 
 Unfortunately, I'm getting an error:

Traceback (most recent call last):

File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
v1.97.1\web2py_src\web2py\gluon\restricted.py, line 192, in restricted

exec ccode in environment

  File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
v1.97.1/web2py_src/web2py/applications/myapp/models/db.py 
http://localhost:8000/admin/default/edit/update_checking/models/db.py, line 
55, in module

openid_login_form = OpenIDAuth(auth)

*  *

File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
v1.97.1\web2py_src\web2py\gluon\contrib\login_methods\openid_auth.py, line 
95, in __init__

self.login_url = auth.environment.URL(r=request, f='user', args=['login'])

AttributeError: 'thread._local' object has no attribute 'URL' 


Does anyone know what's going wrong? I'm running the latest stable web2py 
from source with Python 2.7 (windows) and sqlite. 


[web2py] Re: auth with OpenID - auth.environment.URL(...) error

2011-07-09 Thread Anthony
With 1.96.1, Auth was rewritten to use the new thread local 'current' object 
as the environment instead of passing globals() to Auth. However, the 
'current' object does not include URL (and other web2py global objects), so 
auth.environment.URL doesn't exist.
 
It looks like openid_auth.py already imports everything from gluon.html 
(which includes URL), though, so in openid_auth.py, try replacing 
all occurrences of auth.environment.URL, self.environment.URL, and 
environment.URL with just URL, and see if that fixes the problem. If so, 
please submit the updated openid_auth.py as a patch.
 
Anthony
 

On Saturday, July 9, 2011 11:28:55 PM UTC-4, Brian M wrote:

 So I thought I'd mess around with using OpenID for authentication and 
 followed the info Will provided in an older 
 posthttps://groups.google.com/forum/#!topic/web2py/So79E4FDWLk. 
  Unfortunately, I'm getting an error: 

 Traceback (most recent call last):

 File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 v1.97.1\web2py_src\web2py\gluon\restricted.py, line 192, in restricted

 exec ccode in environment

   File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
 v1.97.1/web2py_src/web2py/applications/myapp/models/db.py 
 http://localhost:8000/admin/default/edit/update_checking/models/db.py, line 
 55, in module

 openid_login_form = OpenIDAuth(auth)

 *  *

 File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 v1.97.1\web2py_src\web2py\gluon\contrib\login_methods\openid_auth.py, line 
 95, in __init__

 self.login_url = auth.environment.URL(r=request, f='user', args=['login'])

 AttributeError: 'thread._local' object has no attribute 'URL' 


 Does anyone know what's going wrong? I'm running the latest stable web2py 
 from source with Python 2.7 (windows) and sqlite.