[web2py] Re: Possible bug in trunk dal.py

2011-07-09 Thread cjwebb
I have encountered this too. Are there any suggestions/fixes to solve
this issue?

On Jun 2, 9:54 am, Oskari  wrote:
> Yes I did. Dal seems to try to put 0 in database but MySQL rejects the
> value, since there is no row with index 0. I think the proper way to
> indicate None in MySQL would be NULL.
>
> On Jun 1, 7:14 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Did you try:
> > db.define_table("tags",
> >     Field("name","string"),
> >     Field("parent", "reference tags",default=None),
> >     format="%(name)s")
>
> > On Jun 1, 9:30 am, Oskari  wrote:
>
> > > Hi,
>
> > > I'm reporting a possible bug with trunk version of dal.py. I'm having
> > > the traceback:
>
> > > Traceback (most recent call last):
> > >   File "/home/www-data/web2py/gluon/restricted.py", line 184, in
> > > restricted
> > >     exec ccode in environment
> > >   File "/home/www-data/web2py/applications/backend/controllers/
> > > appadmin.py", line 411, in 
> > >   File "/home/www-data/web2py/gluon/globals.py", line 135, in 
> > >     self._caller = lambda f: f()
> > >   File "/home/www-data/web2py/applications/backend/controllers/
> > > appadmin.py", line 127, in insert
> > >     if form.accepts(request.vars, session):
> > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1205, in accepts
> > >     self.vars.id = self.table.insert(**fields)
> > >   File "/home/www-data/web2py/gluon/dal.py", line 4634, in insert
> > >     return self._db._adapter.insert(self,self._listify(fields))
> > >   File "/home/www-data/web2py/gluon/dal.py", line 814, in insert
> > >     raise e
> > > IntegrityError: (1452, u'Cannot add or update a child row: aforeign
> > >keyconstraintfails(`tuubiodb`.`tags`,CONSTRAINT`tags_ibfk_1`
> > >FOREIGNKEY(`parent`) REFERENCES `tags` (`id`) ON DELETE CASCADE)')
>
> > > with table definition
>
> > > db.define_table("tags",
> > >     Field("name","string"),
> > >     Field("parent", "reference tags",required=False),
> > >     format="%(name)s")
>
> > > Web2py tries to insert parent with value 0, while mySQL only accepts
> > > "null" as a reference to non-existing table.


[web2py] Re: Linking directly to an uploaded image

2011-07-09 Thread IK
Hi Massimo,

When "uploadseparate" is set to True, previously mentioned solution
will not work, at least not for me.

Although, Bruno gave us one suggestion, I would prefer to use explicit
image location rather than image ID.

To explain:

###model:

db.define_table("image",
...
Field('file',"upload",uploadseparate=True,required=True,uploadfolder=request.folder
+'static/' ),
...


###view

{{url = URL('static',image.file)}}
{{=A(IMG(_src=url), _href=url)}}


This would give invalid file location:
"

"
while correct url is
127.0.0.1/app/static/image.file/91/image.file.
9197cf1918d6a0fa.6b617374656c61352e6a7067.jpg


In attempt to find a solution, I was playing with SUBSTR, but I'm not
getting clean output (I'm not sure if this is good approach, specially
from portability point of view)


###contr
...
img_folder= dbselect(db.image.file [11:13])
return dict(img_folder=img_folder)

###view
{{=img_folder}}



and output is
"
SUBSTR(image.file,12,(14 - 12))
91
"

If you could give me some pointers, that would be greatly appreciated.

Thanks
IK

On Jun 17, 3:18 pm, Massimo Di Pierro 
wrote:
> This is fine:
>
> db.define_table('announce',
> Field('picture','upload',uploadfolder=request.folder+'static/
> pictures'),
>                         )
>
> but why do you need an action to download from the static folder? Why
> not simply use
>
> URL('static',record.picture)
>
> On Jun 17, 5:56 am, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > For security reasons, web2py does not expose the 'uploads' folder to the
> > user, this folder can be accessed only by the 'download' function.
>
> > The best way is to set the upload path pointing to /static not to /upload
> > and you will have youruploadedfiles to be served as static files,
> > bypassing download function.
>
> > under /static create a folder called 'picture'
>
> > *Go to the table definition and do this:*
>
> > **
> > db.define_table('announce',
>
> > Field('picture','upload',uploadfolder=request.folder+'static/pictures'),
> >                         )
> > **
>
> > You are saying DAL to store uploades files in to that folder under static
> > and store the ath in the field.
>
> > Now in your controller create a function do handle that (different from
> > download, it is a kind of viewer)
>
> > **
> > def viewer():
> >     row = db(db.announce.id
> > ==request.args(0)).select(db.announce.picture).first()
> >     redirect(URL('static','pictures',args=row.picture))
> > **
>
> > *Now you can fo this:*
>
> >http://server/app/default/viewer/3#record id
>
> > then you got redirected to theimage(no html page)
>
> > example:http://127.0.0.1:8000/app/static/pictures/announce.picture.aaf5d3f777...
>
> > you can always referdirectlyto theimagepath (not using the viewer
> > function) but you always need to fetch the picture name from db.
>
> > Hope it helps.
>
> > Should go on the book?
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
> > [ Aprenda a programar:http://CursoDePython.com.br]
>
> > On Thu, Jun 16, 2011 at 6:09 AM, Vinicius Assef 
> > wrote:
>
> > > Hi guys.
>
> > > I have a table (called anuncio) with an upload field (called foto), so
> > > anuncio.foto is my upload field.
>
> > > I'm showing andlinkingit with this piece of code in my view :
> > >    {{url = URL(c='anuncios',f='download', args=['uploads', 
> > > anuncio.foto])}}
> > >    {{=A(IMG(_src=url), _href=url)}}
>
> > > My /contollers/anuncios.py/download() function is the default, as seen
> > > below:
> > > def download():
> > >    return response.download(request,db)
>
> > > When user clicks on thisimage, browser shows the download dialog,
> > > asking him/her where to save theimage.
> > > But I'd like to simply show theimage, not present the download
> > > dialog. All these images will be public.
>
> > > How I solved it:
> > > 1) I entered in /myapp/static/images and created a symbolic link
> > > called 'uploads' pointing to /myapp/uploads.
> > > 2) In my view, I changed the: {{url = URL(...}} stuff by this: {{url =
> > > URL(c='static', f='images', args=['uploads', anuncio.foto])}}
>
> > > I think this isn't the best choice because I'm pointing URL() to a
> > > fake controller and function, and I'm counting on an external
> > > resource: a symbolic link in my filesystem.
>
> > > How would be the "web2pythonic" way to do this?
>
> > > --
> > > Vinicius Assef.


[web2py] dal trying to insert 0 instead of null?

2011-07-09 Thread cjwebb
Hello, this has been annoying me all day - any suggestions welcome.

I am receiving an IntegrityError from web2py when trying to insert a
record into a table named Foods. The table has a foreign key to
Recipes, but I would like to add a row without a recipe_id.

I receive this sql error:
((1452, u'Cannot add
or update a child row: a foreign key constraint fails
(`pymeals`.`foods`, CONSTRAINT `foods_ibfk_1` FOREIGN KEY
(`recipe_id`) REFERENCES `recipes` (`id`) ON DELETE CASCADE)'))

This is my table

+---+--+--+-+-++
| Field | Type | Null | Key | Default | Extra  |
+---+--+--+-+-++
| id| int(11)  | NO   | PRI | NULL| auto_increment |
| name  | varchar(255) | YES  | | NULL||
| recipe_id | int(11)  | YES  | MUL | NULL||
+---+--+--+-+-++

I have defined the tables in web2py using the following code:

db.define_table('recipes',
Field('name')
)

db.define_table('foods',
Field('name'),
Field('recipe_id', db.recipes, requires=None,
default=None)


Traceback (most recent call last):
  File "c:\web2py\gluon\restricted.py", line 192, in restricted
exec ccode in environment
  File "c:/web2py/applications/pymeals/controllers/foods.py", line 14,
in 
  File "c:\web2py\gluon\globals.py", line 137, in 
self._caller = lambda f: f()
  File "c:/web2py/applications/pymeals/controllers/foods.py", line 10,
in add
return dict(form=crud.create(db.foods))
  File "c:\web2py\gluon\tools.py", line 3120, in create
formname=formname,
  File "c:\web2py\gluon\tools.py", line 3061, in update
detect_record_change = self.settings.detect_record_change):
  File "c:\web2py\gluon\sqlhtml.py", line 1205, in accepts
self.vars.id = self.table.insert(**fields)
  File "c:\web2py\gluon\dal.py", line 4703, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "c:\web2py\gluon\dal.py", line 838, in insert
raise e
IntegrityError: (1452, u'Cannot add or update a child row: a foreign
key constraint fails (`pymeals`.`foods`, CONSTRAINT `foods_ibfk_1`
FOREIGN KEY (`recipe_id`) REFERENCES `recipes` (`id`) ON DELETE
CASCADE)')


I suspect the problem to be that it tries to insert 0 into recipe_id.
The recipes table is empty at the moment, so that obviously doesn't
exist. When I add a recipe with id=0, I don't receive any errors. When
I remove the recipe with id=0 then the error returns.

Function argument list
(self=, table=, 'id': }>, fields=[(, 0), (, 'Lettuce')])


I also attempted to get help here, but so far, no responses :(
http://stackoverflow.com/questions/6635428/integrityerror-when-adding-null-value-to-foreign-key-using-web2py


[web2py] Re: question about file upload service

2011-07-09 Thread weheh
And more links:
http://groups.google.com/group/web2py/browse_thread/thread/ab2cb938413e7be/23df7270902aa957?lnk=gst&q=how+to+post+a+file+to+a+service#23df7270902aa957

Seems like things have changed over time. So question of what's the
latest approach seems OK. Basically, how to POST a file to a service
and how to catch it on the server side.


[web2py] Re: question about file upload service

2011-07-09 Thread weheh
Looks like CJ and I are on the same wavelength here as well:
http://groups.google.com/group/web2py/browse_thread/thread/67912959c7f021e1/9d3418deff7558b4?lnk=gst&q=how+to+post+a+file#9d3418deff7558b4

So the underlying question is whether this has changed circa 2011 or
should I follow the threads?


[web2py] question about file upload service

2011-07-09 Thread weheh
This looks relevant:
http://groups.google.com/group/web2py/browse_thread/thread/fbc8d2ff40430d92/b1c6d74aead0a401?lnk=gst&q=file+upload+service#b1c6d74aead0a401


[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 
> post. 
>  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" 
> , line 
> 55, in 
>
> 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] 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 
post. 
 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" 
, line 
55, in 

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] 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] 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] 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  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] 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__.


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?



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 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
"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? 

[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  wrote:
> ajax=True doesn't work too
>
> I make it clear:
> layout.html
> {{=LOAD('default','login2',vars=request.vars, ajax=True)}}
>
> default/login.html:
> 
> {{=BEAUTIFY(request.vars)}}
> {{if not auth.user:}}
>     {{=form}}
> {{else:}}
>     logout
> {{pass}}
> 
>
> 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  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  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  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:
> > > > > 
> > > > > {{if not auth.user:}}
> > > > >     
> > > > >     
> > > > >         Login
> > > > >     
> > > > >     
> > > > >         Password
> > > > >     
> > > > >     
> > > > >          > > > > checked="checked">remember me
> > > > >     
> > > > >     {{=form.hidden_fields()}}
> > > > >     
> > > > >         
> > > > >     
> > > > >     
> > > > > {{else:}}
> > > > >     logout
> > > > > {{pass}}
> > > > > 
>
> > > > > 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: 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: 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  wrote:
> Sounds reasonable. I'll give it a try.
>
> On Jul 9, 3:20 pm, cjrh  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  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
Sounds reasonable. I'll give it a try.

On Jul 9, 3:20 pm, cjrh  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
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?

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] 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 
import gluon.widget
  File "N:\web2py\gluon\widget.py", line 19, in 
import socket
  File "c:\Program Files (x86)\Python27\lib\socket.py", line 47, in

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 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] 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 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] 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'))


[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] 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: 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:

{{=BEAUTIFY(request.vars)}}
{{if not auth.user:}}
{{=form}}
{{else:}}
logout
{{pass}}


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  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  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  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:
> > > > 
> > > > {{if not auth.user:}}
> > > >     
> > > >     
> > > >         Login
> > > >     
> > > >     
> > > >         Password
> > > >     
> > > >     
> > > >          > > > checked="checked">remember me
> > > >     
> > > >     {{=form.hidden_fields()}}
> > > >     
> > > >         
> > > >     
> > > >     
> > > > {{else:}}
> > > >     logout
> > > > {{pass}}
> > > > 
>
> > > > 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  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 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  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  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: 
> > >  
> > > {{if not auth.user:}} 
> > >  
> > >  
> > > Login 
> > >  
> > >  
> > > Password 
> > >  
> > >  
> > >  > > checked="checked">remember me 
> > >  
> > > {{=form.hidden_fields()}} 
> > >  
> > >  
> > >  
> > >  
> > > {{else:}} 
> > > logout 
> > > {{pass}} 
> > >  
> > 
> > > 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] 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: 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)"  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] 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  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:
> > 
> > {{if not auth.user:}}
> >     
> >     
> >         Login
> >     
> >     
> >         Password
> >     
> >     
> >          > checked="checked">remember me
> >     
> >     {{=form.hidden_fields()}}
> >     
> >         
> >     
> >     
> > {{else:}}
> >     logout
> > {{pass}}
> > 
>
> > 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 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: 
>  
> {{if not auth.user:}} 
>  
>  
> Login 
>  
>  
> Password 
>  
>  
>  checked="checked">remember me 
>  
> {{=form.hidden_fields()}} 
>  
>  
>  
>  
> {{else:}} 
> logout 
> {{pass}} 
>  
>
> 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] 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:

{{if not auth.user:}}


Login


Password


remember me

{{=form.hidden_fields()}}




{{else:}}
logout
{{pass}}


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] 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] 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  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