[web2py] Re: crud.settings.update_onaccept = StorageList()

2011-09-15 Thread annet
This is what I got so far,

row=db(db.function.bedrijf_id==id).select().first()
form=crud.update(table=db.functions,record=row)
crud.settings.update_onaccept = StorageList()

return dict(form=form)


counter=1
for field in db[functions]:
if field:
counter=counter+1
row.update_record(counter=counter)


How do I link these two together? i.e how do I use StorageList() to
set row.counter.


Kind regards,

Annet.


[web2py] Re: html layout for retrieve_username and reset_password?

2011-09-15 Thread annet
I don't get this to work, because I don't know how to set
some_context.

Kind regards,

Annet.


Re: [web2py] Re: billing app

2011-09-15 Thread Kenneth Lundström

> db = DAL('mysql://testing_user:testing_pass@localhost/ testing_db')
> RuntimeError: Failure to connect, tried 5 times: (1045, u"Access 
denied for user 'testing_user'@'localhost' (using password: YES)")


>Is there something I am supposed to do before launching it?

As stated in my mail this application does not work directly out of box. 
I will during the weekend find some time and create some default for all 
missing data in database.


I´m a little surprised that Massimo is asking about this error. You have 
to change the login settings for you database.



Kenneth


Source can be found at:http://web2py.nudata.fi/em/static/em.tar.gz

I first used the Pack command i Admin but it packed a little to much,
e.g. uploads.

There is an small problem when starting with an empty database. You have
to insert some values into database to be able to start using this
application. If I find some time I´ll fix this bug in the near future.

If you find any security holes please let me know.

Kenneth








Kenneth;
Well done.
Can you post the code somewhere public for download?
I think many people would be interested in it.
Thanks.
On 9/13/11 1:25 AM, Gour-Gadadhara Dasa wrote:

On Tue, 13 Sep 2011 00:07:30 +0300
Kenneth Lundström
wrote:

if you want a copy of the code I can send it, or if somebody else
wants a copy let me know.

+1
gour at atmarama dot net
Sincerely,
Gour




[web2py] Re: Web2py LAN

2011-09-15 Thread Anthony
Either way should work. With 0.0.0.0, you don't need to know your machine's 
exact IP address.

Anthony

On Friday, September 16, 2011 2:06:47 AM UTC-4, JavierQQ wrote:
>
> Thank you, I found another that says 
>
> web2py.exe -i 192.168.0.1 -p 8000 -a 'password' 
>
>
> http://groups.google.com/group/web2py/browse_thread/thread/b33c44007871c0e2/f19fd80de8043f64?lnk=gst&q=web2py+lan#f19fd80de8043f64
>  
>
> I finally solved it 
>
> On Sep 16, 1:00 am, Anthony  wrote: 
> > When you start web2py, specify IP address 0.0.0.0 and port 80 to make it 
> > publicly accessible (the default 127.0.0.1:8000 is only available on the 
>
> > local machine). 
> > 
> > Seehttp://web2py.com/book/default/chapter/03#Startup. 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Friday, September 16, 2011 1:45:42 AM UTC-4, JavierQQ wrote: 
> > 
> > > Hello, 
> > 
> > > I found web2py recently and its an awesome framework, and what I'm 
> > > going to ask may be something that someone has asked before 
> > > but I want to see my web2py application in a computer that its on my 
> > > LAN but I can't. 
> > > I've been using wamp and it worked with everything I've done in the 
> > > past, but when I start web2py server on my laptop that has IP: 
> > > 192.168.1.100 on my LAN and I want to access from another computer I 
> > > can't 
> > > I've tried different things such as: 
> > > - 192.168.1.100:8000 
> > > - 192.168.1.100/welcome/default/index 
> > > and also deactivating the firewall/ adding port 8000 but none of those 
> > > things seem to work. 
> > > Should I change to apache? (because in web2py homepage says that works 
> > > with it too) or is there a file that I have to modify? 
> > 
> > > Thanks



[web2py] Re: Web2py LAN

2011-09-15 Thread Anthony
0.0.0.0 also enables you to access web2py via http://localhost or 
http://127.0.0.1 from the local machine.

Anthony

On Friday, September 16, 2011 2:20:13 AM UTC-4, Anthony wrote:
>
> Either way should work. With 0.0.0.0, you don't need to know your machine's 
> exact IP address.
>
> Anthony
>
> On Friday, September 16, 2011 2:06:47 AM UTC-4, JavierQQ wrote:
>>
>> Thank you, I found another that says 
>>
>> web2py.exe -i 192.168.0.1 -p 8000 -a 'password' 
>>
>>
>> http://groups.google.com/group/web2py/browse_thread/thread/b33c44007871c0e2/f19fd80de8043f64?lnk=gst&q=web2py+lan#f19fd80de8043f64
>>  
>>
>> I finally solved it 
>>
>> On Sep 16, 1:00 am, Anthony  wrote: 
>> > When you start web2py, specify IP address 0.0.0.0 and port 80 to make it 
>>
>> > publicly accessible (the default 127.0.0.1:8000 is only available on 
>> the 
>> > local machine). 
>> > 
>> > Seehttp://web2py.com/book/default/chapter/03#Startup. 
>> > 
>> > Anthony 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > On Friday, September 16, 2011 1:45:42 AM UTC-4, JavierQQ wrote: 
>> > 
>> > > Hello, 
>> > 
>> > > I found web2py recently and its an awesome framework, and what I'm 
>> > > going to ask may be something that someone has asked before 
>> > > but I want to see my web2py application in a computer that its on my 
>> > > LAN but I can't. 
>> > > I've been using wamp and it worked with everything I've done in the 
>> > > past, but when I start web2py server on my laptop that has IP: 
>> > > 192.168.1.100 on my LAN and I want to access from another computer I 
>> > > can't 
>> > > I've tried different things such as: 
>> > > - 192.168.1.100:8000 
>> > > - 192.168.1.100/welcome/default/index 
>> > > and also deactivating the firewall/ adding port 8000 but none of those 
>>
>> > > things seem to work. 
>> > > Should I change to apache? (because in web2py homepage says that works 
>>
>> > > with it too) or is there a file that I have to modify? 
>> > 
>> > > Thanks
>
>

Re: [web2py] Web2py LAN

2011-09-15 Thread Bruno Rocha
python web2py.py -i 0.0.0.0 -p 8000 -a password


[web2py] Re: Web2py LAN

2011-09-15 Thread JavierQQ
Thank you, I found another that says

web2py.exe -i 192.168.0.1 -p 8000 -a 'password'

http://groups.google.com/group/web2py/browse_thread/thread/b33c44007871c0e2/f19fd80de8043f64?lnk=gst&q=web2py+lan#f19fd80de8043f64

I finally solved it

On Sep 16, 1:00 am, Anthony  wrote:
> When you start web2py, specify IP address 0.0.0.0 and port 80 to make it
> publicly accessible (the default 127.0.0.1:8000 is only available on the
> local machine).
>
> Seehttp://web2py.com/book/default/chapter/03#Startup.
>
> Anthony
>
>
>
>
>
>
>
> On Friday, September 16, 2011 1:45:42 AM UTC-4, JavierQQ wrote:
>
> > Hello,
>
> > I found web2py recently and its an awesome framework, and what I'm
> > going to ask may be something that someone has asked before
> > but I want to see my web2py application in a computer that its on my
> > LAN but I can't.
> > I've been using wamp and it worked with everything I've done in the
> > past, but when I start web2py server on my laptop that has IP:
> > 192.168.1.100 on my LAN and I want to access from another computer I
> > can't
> > I've tried different things such as:
> > - 192.168.1.100:8000
> > - 192.168.1.100/welcome/default/index
> > and also deactivating the firewall/ adding port 8000 but none of those
> > things seem to work.
> > Should I change to apache? (because in web2py homepage says that works
> > with it too) or is there a file that I have to modify?
>
> > Thanks


[web2py] Re: Web2py LAN

2011-09-15 Thread Anthony
When you start web2py, specify IP address 0.0.0.0 and port 80 to make it 
publicly accessible (the default 127.0.0.1:8000 is only available on the 
local machine).

See http://web2py.com/book/default/chapter/03#Startup.

Anthony

On Friday, September 16, 2011 1:45:42 AM UTC-4, JavierQQ wrote:
>
> Hello, 
>
> I found web2py recently and its an awesome framework, and what I'm 
> going to ask may be something that someone has asked before 
> but I want to see my web2py application in a computer that its on my 
> LAN but I can't. 
> I've been using wamp and it worked with everything I've done in the 
> past, but when I start web2py server on my laptop that has IP: 
> 192.168.1.100 on my LAN and I want to access from another computer I 
> can't 
> I've tried different things such as: 
> - 192.168.1.100:8000 
> - 192.168.1.100/welcome/default/index 
> and also deactivating the firewall/ adding port 8000 but none of those 
> things seem to work. 
> Should I change to apache? (because in web2py homepage says that works 
> with it too) or is there a file that I have to modify? 
>
> Thanks



Re: [web2py] Re: Tricky query

2011-09-15 Thread Johann Spies
> try
> query1 = "regexp_replace(lower(us2006_2010.title),
>  '([^[:alnum:]_])', '', 'g') =
>  regexp_replace(lower($a$%s$a$), '(
> [^[:alnum:]_])', '',
>  'g')" % some_string
>
>
> Thanks DenesL and Harry.  I forgot about the raw string option and did not
know about the $a$ option.

Regards
Johann

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


[web2py] Web2py LAN

2011-09-15 Thread JavierQQ
Hello,

I found web2py recently and its an awesome framework, and what I'm
going to ask may be something that someone has asked before
but I want to see my web2py application in a computer that its on my
LAN but I can't.
I've been using wamp and it worked with everything I've done in the
past, but when I start web2py server on my laptop that has IP:
192.168.1.100 on my LAN and I want to access from another computer I
can't
I've tried different things such as:
- 192.168.1.100:8000
- 192.168.1.100/welcome/default/index
and also deactivating the firewall/ adding port 8000 but none of those
things seem to work.
Should I change to apache? (because in web2py homepage says that works
with it too) or is there a file that I have to modify?

Thanks


[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-15 Thread DJ
Congratulations to Massimo and the rest of the team! Incredible work!!!


-Sebastian


[web2py] Re: http get requests for google search api

2011-09-15 Thread Anaconda

I missed Anthony's message, thanks I understand it now!
On Sep 15, 7:15 pm, Anaconda  wrote:
> thanks for the reply Eric,I will take a look at the python client
> libraries. Is there any web2py examples of making a request to an API
> and parsing the returned json?
>
>  Sep 15, 2:55 pm, Eric  wrote:
>
>
>
>
>
>
>
> > I've not used any of the google api, but if you just need to access
> > and parse a json formatted api, you would need to use urllib or
> > urllib2 to make the request, then use simplejson or json or parse the
> > results:
>
> > import urllib
> > import simplejson
>
> > req = urllib.urlopen("http://google.com/api.json";) ##<-example only
> > my_vars = simplejson.load(req)
>
> > Atom should be similar -- urllib to access, then some Atom library to
> > parse the data.
> > Google offers their own Python client libraries, so you may want to
> > look into one of those.  The basic procedure should be the same,
> > however.
>
> > On Sep 15, 5:26 pm, Anaconda  wrote:
>
> > > Its my first time trying to access a webservice/api, would i use
> > > feedparser in web2py to to make http requests to a google api. They
> > > return their results in atom and json? I just need some
> > > guidance...thanks in advance guys.
>
> > > Regards


Re: [web2py] Process a file received via xmlrpc

2011-09-15 Thread Bruno Rocha
is your file stored as a BLOB or a regular file under /uploads folder?

2011/9/15 António Ramos 

> hello,
> i receive a file via   xmlrpc
> this is my function
>
> @service.xmlrpc
> def checkflow(file,name):
>
> db.image.insert(file=db.image.file.store(cStringIO.StringIO(file.data),name))
> return "ok"
>
> It is working as expected.
>
> Now i want to open the file and process every line
>
> how do i code the opening of the file ?
>
>
> thank you
>



-- 



--
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: Trying to implement token authentication for web service

2011-09-15 Thread Massimo Di Pierro
Looking at your code again:

@auth.requires_login()
def call(token):
row = db(db.subscription.token == token).select().first()
my_number = row.my_calls
if my_number > 0 & my_token == token:
db(db.subscription.token ==
my_token).update(my_calls=db.subscription.my_calls-1)
return service()
else:
raise Exception()

I see two problems:
1)
you have both @auth.requires_login() which only works if you enable
auth.allow_basic_login = True
and you have token authentication. Are you sure you want two
authentications one on top of the other?
2)
call is a method and cannot take arguments.

If your intention is passing the token as request.args(0) simply do:

def call():
token = request.args(0) # grab the token
row = db(db.subscription.token == token).select().first()
my_number = row.my_calls
if my_number > 0 & my_token == token:
db(db.subscription.token ==
my_token).update(my_calls=db.subscription.my_calls-1)
del request.args[0] # make sure you remove the token else you
may mess-up some services.
return service()
else:
raise Exception()








On Sep 15, 2:46 pm, Eric  wrote:
> OK, here's where my background as a non-CS/humanities major starts to
> hurt.  I'm trying to implement a token authentication for a web
> service using RPC.  I've also developed a sign-up/payment website for
> the web service that uses web2py with auth.  I had the service working
> fine using basic authentication, but then I realized that my target
> audience may not always use a client with basic authentication
> enabled, plus a token authentication system offers me other advantages
> that I would like.
>
> Anyway, I need advice on where exactly is best to check for the
> token.  Intuitively, it seems reasonable to check for the token in the
> call function that I've exposed, but what is confusing me is the fact
> that all the arguments passed by the call go to the decorated RPC
> function that is called.  Indeed, when I check the token in the
> exposed call action and use curl to make the call using a valid token,
> I get a "invalid function (api/call)" error.
>
> So how would I should I pass a token to the exposed call action in
> addition to passing other arguments to the various linked actions?
>
> Or do I need to check for the token inside each of my remote
> procedures?  Also, is there a good way to cache the token, or will I
> need to check it on every call?
>
> Finally, I had a counter working well with basic authentication to
> limit calls to a certain number per month.  I guess if I have to check
> for the token inside each of my remote procedures, then that's also
> where I´ll need to put the counter.  This would seem to make for messy
> and repetitive code, but I'm not sure what else to do.
>
> Would anyone like to jump in or point me to a pertinent resource?  I'd
> be very grateful.  Django has a token API plugin 
> at:https://github.com/jpulgarin/django-tokenapi/tree/master/tokenapi but
> I'm not able to extrapolate from their plugin to my app.
>
> ###
> #model##
> ##
> db.define_table('subscription',
>     Field('id','id'),
>     Field('token',
>           label=T('User Token')),
>     Field('my_calls', type='integer', default=100,
>           label=T('User Calls'),writable=False,readable=False),
>     Field('subscription_method', 'reference method', required=True,
>           label=T('Subscription Method')),
>     Field('is_active','boolean',default=False,
>           label=T('Active'),writable=False,readable=False),
>     Field('created_on','datetime',default=request.now,
>           label=T('Created On'),writable=False,readable=False),
>     Field('modified_on','datetime',default=request.now,
>           label=T('Modified On'),writable=False,readable=False,
>           update=request.now),
>     Field('created_by',db.auth_user,default=auth.user_id,
>           label=T('Created By'),writable=False,readable=False),
>     Field('modified_by',db.auth_user,default=auth.user_id,
>           label=T('Modified By'),writable=False,readable=False,
>           update=auth.user_id),
>     format='%(plan)s',
>     migrate=settings.migrate)
>
> 
> ##controller
> # coding: utf8
> from gluon.tools import Service
> service = Service(globals())
>
> @service.run
> def my_function1(foo,bar):
>     ...
>     return response.body.getvalue()
>
> @service.run
> def my_function2(foo,bar):
>     ...
>     return response.body.getvalue()
>
> @auth.requires_login()
> def call(token):
>     row = db(db.subscription.token == token).select().first()
>     my_number = row.my_calls
>     if my_number > 0 & my_token == token:
>         db(db.subscription.token ==
> my_token).update(my_calls=db.subscription.my_calls-1)
>         return service()
>     else:
>         raise Exception()


[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread Ray (a.k.a. Iceberg)
Hi Ian,

You mentioned "After using the online web2py ide to do some
development, I
cloned my fluxflex git repository only to find that it's empty".

If you developed your web2py app via your fluxflex's web2py's admin
interface, I am afraid all your app source code only exists as "on
site data" but not as "code inside repo". In this case there is still
easy way to get your code. Go to your fluxflex web2py 's admin, and
"pack" (then download) your app. That is the native web2py way to
handle your app. (I havn't tried that on fluxflex but it should work.)

Regards,
Ray

On Sep 16, 4:20 am, monotasker  wrote:
> Hi,
>
> I realize this is really a support issue for fluxflex, but their customer
> service has been really slow (days) to respond. Since a few people on here
> seem to have tried out fluxflex I'm hoping someone can help.
>
> I've deployed web2py using the one-click install on fluxflex, and it's
> working well. After using the online web2py ide to do some development, I
> cloned my fluxflex git repository only to find that it's empty. No web2py
> files. Does anyone know where the web2py files would be and how to get them
> out using git?
>
> Thanks,
>
> Ian


[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Anthony
On Thursday, September 15, 2011 6:29:04 PM UTC-4, Lennon wrote:
>
> I guess ideally they should be able to submit from either but if that 
> opens the app up to double submission than the most recent is fine as 
> long as I have a way to handle the old form gracefully as far as user 
> experience is concerned.  I'm open to ideas.
>

If there were two different forms in two different windows, I don't think 
that would be a double submission risk because each form could still only be 
submitted once (i.e., in order to submit the second form, the user would 
still have to manually fill it out and submit it -- there would be no danger 
that the same form data could be submitted twice). If you want to allow 
that, you would need to do something to ensure the name of the _formkey 
stored in the session is unique for each version of the form, so when a new 
form is created, it doesn't overwrite the value of the _formkey in the 
session but simply adds a new one. When a new form is created, something 
like the following is added to the session:

_formkey[form_name]='the_form_key' 

The problem is, by default, form.accepts() creates a standard form name 
(which is added to the form as a hidden field). Every time the form is 
created, the name will be the same, so _formkey[form_name] will be the same 
and will therefore get overwritten in the session. To avoid this, I suppose 
you could give the form a unique name every time it is created -- that 
should result in a separate session entry for each version of the form. When 
a form is submitted, you would then have to check request.vars for the 
_formname, and if found, assign that as the current form name so it will 
find the matching session key. Something like:

import uuid
formname=request.vars._formname or uuid.uuid4()
if form.accepts(request,session,formname=formname):
etc.

Of course, I may be overlooking something, but I think something along those 
lines would work.

Anthony





[web2py] Re: http get requests for google search api

2011-09-15 Thread Anaconda
thanks for the reply Eric,I will take a look at the python client
libraries. Is there any web2py examples of making a request to an API
and parsing the returned json?

 Sep 15, 2:55 pm, Eric  wrote:
> I've not used any of the google api, but if you just need to access
> and parse a json formatted api, you would need to use urllib or
> urllib2 to make the request, then use simplejson or json or parse the
> results:
>
> import urllib
> import simplejson
>
> req = urllib.urlopen("http://google.com/api.json";) ##<-example only
> my_vars = simplejson.load(req)
>
> Atom should be similar -- urllib to access, then some Atom library to
> parse the data.
> Google offers their own Python client libraries, so you may want to
> look into one of those.  The basic procedure should be the same,
> however.
>
> On Sep 15, 5:26 pm, Anaconda  wrote:
>
>
>
>
>
>
>
> > Its my first time trying to access a webservice/api, would i use
> > feedparser in web2py to to make http requests to a google api. They
> > return their results in atom and json? I just need some
> > guidance...thanks in advance guys.
>
> > Regards


[web2py] Re: http get requests for google search api

2011-09-15 Thread Anthony
On Thursday, September 15, 2011 5:55:30 PM UTC-4, Eric wrote:
>
> I've not used any of the google api, but if you just need to access 
> and parse a json formatted api, you would need to use urllib or 
> urllib2 to make the request, then use simplejson or json or parse the 
> results: 
>
> import urllib 
> import simplejson 
>
> req = urllib.urlopen("http://google.com/api.json";) ##<-example only
>

Also, note that web2py includes its own fetch() function in gluon.tools to 
fetch a url -- the difference from the above is that it works on GAE as well 
(the above does not). See 
http://web2py.com/book/default/chapter/12#Fetching-an-external-URL (note, 
the book incorrectly refers to google.tools, but should be gluon.tools).

Anthony 


[web2py] Re: web2py - Best Practice

2011-09-15 Thread Daniel Aguayo
maybe we could add to this project: http://pyforum.org (afaik author is also 
in this forum :))


[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread Ross Peoples
Eric, I may have found a way to do it, but it's not pretty.

Create a controller that only has login / logout methods. The login method 
will return your token that is saved somewhere (cache or database).

Then in other controllers where you need to enforce token authentication, 
put this into your call() method:

if 'token' in request.vars:
token = request.vars.token
if token != 'test':   # you would put your own token checking logic 
here
raise HTTP(401, 'Supplied token was not valid.')
else:
raise HTTP(401, 'Token must supplied as a variable in the query 
string.')

return service()


Now, to get a token, call your login method (that is in another controller):

x = 
xmlrpclib.ServerProxy('http://127.0.0.1:8000/rpc_test/auth/login/xmlrpc')

try:
token = x.login(username, password) 
except:
print 'Login failed'

x = 
xmlrpclib.ServerProxy('http://127.0.0.1:8000/rpc_test/my_controller/call/xmlrpc?token=%s'
 
% token)

try:
x.my_method(a, b)
x.add(1,2)
except:
print 'Not authorized'

What happens here is you login, get the token, then make a new connection 
with the token, which is checked for every call you make to my_controller. 
You do not need to include the token in the API at all with this method, but 
again, it's kind of a hacky way to do it. I'm not sure how X509 works, but 
if Massimo says that's the way to go, then I'm going to wait before 
implementing it the way described here. I have a couple of weeks before I 
have to worry about this, I'm just doing preliminary research right now.


[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread monotasker
Well, I tried a new test install in a separate project and I'm getting the 
same result. Very strange. The one thing I notice is that in your log you 
are prompted for the passphrase for your ssh key. I'm not, even though I 
have a passphrase set. Could that be blocking some of the files? (But I 
suppose in that case I just wouldn't be able to connect at all). Really 
frustrating!

Ian


[web2py] Re: web2py with Mongrel2 web server

2011-09-15 Thread Massimo Di Pierro
P.S. The handler I used:

https://github.com/berry/Mongrel2-WSGI-Handler

does not support streaming and chunked encoding. Apparently this one
does:

http://pypi.python.org/pypi/m2wsgi/0.4.1

Massimo

On Sep 15, 7:47 pm, Massimo Di Pierro 
wrote:
> I just added support in anyserver but I did not test it. perhaps with your 
> help we can make it better.
>
> On Sep 15, 2011, at 7:02 PM, Aaron Yoshitake wrote:
>
>
>
>
>
>
>
> > I see that this file connects web2py with other web servers, but I don't 
> > see how we could tell it to connect with mongrel2, or with an arbitrary 
> > server using WSGI. Is doing so documented somewhere?
>
> > Thanks,
> > Aaron
>
> > On Thu, Sep 15, 2011 at 4:35 PM, Massimo Di Pierro 
> >  wrote:
> > web2y ships with this file:
>
> >http://code.google.com/p/web2py/source/browse/anyserver.py
>
> > run it with -h
>
> > On Sep 15, 6:13 pm, Aaron  wrote:
> > > We're trying to link the Mongrel2 web server to web2py. We're making
> > > some headway, and it may be premature to post details here while my
> > > colleague is working on the current problem. So instead, can anyone
> > > tell me whether instructions exist for deploying web2py on a web
> > > server other than Apache, using WSGI?
>
> > > Thanks,
> > > Aaron


[web2py] Re: web2py with Mongrel2 web server

2011-09-15 Thread Massimo Di Pierro
I just added support in anyserver but I did not test it. perhaps with your help 
we can make it better.

On Sep 15, 2011, at 7:02 PM, Aaron Yoshitake wrote:

> I see that this file connects web2py with other web servers, but I don't see 
> how we could tell it to connect with mongrel2, or with an arbitrary server 
> using WSGI. Is doing so documented somewhere?
> 
> Thanks,
> Aaron
> 
> On Thu, Sep 15, 2011 at 4:35 PM, Massimo Di Pierro 
>  wrote:
> web2y ships with this file:
> 
> http://code.google.com/p/web2py/source/browse/anyserver.py
> 
> run it with -h
> 
> 
> 
> On Sep 15, 6:13 pm, Aaron  wrote:
> > We're trying to link the Mongrel2 web server to web2py. We're making
> > some headway, and it may be premature to post details here while my
> > colleague is working on the current problem. So instead, can anyone
> > tell me whether instructions exist for deploying web2py on a web
> > server other than Apache, using WSGI?
> >
> > Thanks,
> > Aaron
> 



[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread Omi Chiba
For trouble shooting purpose, how about create new project, install
web2py and do the git clone ?

Like you said, I can access your site so it should download all the
files with your command and I'm sure you're doing correct. There is
something wrong with your project...

https://paideia.fluxflex.com/welcome/default/index

The below is my log.

$ git clone ssh://g...@git.fluxflex.com:443/ochiba
Cloning into ochiba...
Enter passphrase for key (*secret) :
remote: Counting objects: 1160, done.
remote: Compressing objects: 100% (676/676), done.
remote: Total 1160 (delta 458), reused 1146 (delta 450)
Receiving objects: 100% (1160/1160), 5.71 MiB | 157 KiB/s, done.
Resolving deltas: 100% (458/458), done.


On 9月15日, 午後6:41, monotasker  wrote:
> Thanks Omi. But that's what I did, on two different machines. From the
> command line: git clone ssh://g...@git.fluxflex.com:443/paideia
>
> This is the response I get:
>
> Cloning into paideia...
> Warning: Permanently added the RSA host key for IP address
> '[107.20.223.252]:443' to the list of known hosts.
> remote: Counting objects: 23, done.
> remote: Compressing objects: 100% (14/14), done.
> remote: Total 23 (delta 8), reused 23 (delta 8)
> Receiving objects: 100% (23/23), 6.79 KiB, done.
> Resolving deltas: 100% (8/8), done.
>
> But the /paideia folder that results doesn't have any
> public_html/applications folder. public_html only contains two files:
> dispatch.fcgi and .htaccess. What's weird is that the site is working
> online. It's just that the files aren't there!
>
> Ian


[web2py] Re: web2py with Mongrel2 web server

2011-09-15 Thread Massimo Di Pierro
web2py ships with this:

http://code.google.com/p/web2py/source/browse/anyserver.py

try run with -h

On Sep 15, 6:13 pm, Aaron  wrote:
> We're trying to link the Mongrel2 web server to web2py. We're making
> some headway, and it may be premature to post details here while my
> colleague is working on the current problem. So instead, can anyone
> tell me whether instructions exist for deploying web2py on a web
> server other than Apache, using WSGI?
>
> Thanks,
> Aaron


[web2py] Re: billing app

2011-09-15 Thread Massimo Di Pierro
I am getting

Traceback (most recent call last):
  File "/Users/mdipierro/web2py/gluon/restricted.py", line 194, in
restricted
exec ccode in environment
  File "/Users/mdipierro/web2py/applications/em/models/1_db.py", line
15, in 
db = DAL('mysql://testing_user:testing_pass@localhost/
testing_db')   # if not, use SQLite or other DB
  File "/Users/mdipierro/web2py/gluon/dal.py", line 4149, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
(1045, u"Access denied for user 'testing_user'@'localhost' (using
password: YES)")

Is there something I am supposed to do before launching it?


On Sep 13, 4:40 am, Kenneth Lundström 
wrote:
> Source can be found at:http://web2py.nudata.fi/em/static/em.tar.gz
>
> I first used the Pack command i Admin but it packed a little to much,
> e.g. uploads.
>
> There is an small problem when starting with an empty database. You have
> to insert some values into database to be able to start using this
> application. If I find some time I´ll fix this bug in the near future.
>
> If you find any security holes please let me know.
>
> Kenneth
>
>
>
>
>
>
>
> > Kenneth;
>
> > Well done.
>
> > Can you post the code somewhere public for download?
>
> > I think many people would be interested in it.
>
> > Thanks.
>
> > On 9/13/11 1:25 AM, Gour-Gadadhara Dasa wrote:
> >> On Tue, 13 Sep 2011 00:07:30 +0300
> >> Kenneth Lundström
> >>   wrote:
>
> >>> if you want a copy of the code I can send it, or if somebody else
> >>> wants a copy let me know.
> >> +1
>
> >> gour at atmarama dot net
>
> >> Sincerely,
> >> Gour


[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread monotasker
Thanks Omi. But that's what I did, on two different machines. From the 
command line: git clone ssh://g...@git.fluxflex.com:443/paideia

This is the response I get:

Cloning into paideia...
Warning: Permanently added the RSA host key for IP address 
'[107.20.223.252]:443' to the list of known hosts.
remote: Counting objects: 23, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 23 (delta 8), reused 23 (delta 8)
Receiving objects: 100% (23/23), 6.79 KiB, done.
Resolving deltas: 100% (8/8), done.

But the /paideia folder that results doesn't have any 
public_html/applications folder. public_html only contains two files: 
dispatch.fcgi and .htaccess. What's weird is that the site is working 
online. It's just that the files aren't there!

Ian


[web2py] web2py with Mongrel2 web server

2011-09-15 Thread Aaron
We're trying to link the Mongrel2 web server to web2py. We're making
some headway, and it may be premature to post details here while my
colleague is working on the current problem. So instead, can anyone
tell me whether instructions exist for deploying web2py on a web
server other than Apache, using WSGI?

Thanks,
Aaron


[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread Eric
That's great to hear.  Any chance that a token-based API
authentication module would be included in the trunk, if someone were
to create one?  Or would that be better as a plugin?  I'd be happy to
do the grunt work of adapting one of the modules available for the
other frameworks (I've found one for Django and TG) if a more
experienced programmer would advise me on how to approach the problem.

By the way, I'm totally impressed with web2py's new RESTful API.  I've
been learning and thinking a lot about RESTful approach to APIs, and
it's going to totally change how I approach web apps from now on.
I'll use web2py to build RESTful APIs, then use Ajax for my web
frontends, and then I'll have a nice restful API available for other
programmers or if I decide to commission a native Android or iPhone
client for a given app.


On Sep 15, 4:33 pm, Massimo Di Pierro 
wrote:
> Michele has created a x509 authentication module. Part his code is in
> web2py trunk, part is pending waiting for Tim to include it in Rocket.
> It will be available soon.
>
> On Sep 15, 3:01 pm, Ross Peoples  wrote:
>
>
>
>
>
>
>
> > I am very interested in token-based authentication and authorization using
> > web services because I'm about to have to start getting in to that. I do
> > have a question though, because I was wondering this: can you make a
> > login(username, password) function that does the authentication, then saves
> > something like logged_in=True to the session?
>
> > I only ask because I don't know if web service clients (like XML-RPC and
> > JSON-RPC) observe sessions. It would be interesting to see, because then you
> > wouldn't need to worry about tokens and it would work more like the
> > traditional web-based login from a browser.


[web2py] Re: web2py - Best Practice

2011-09-15 Thread pbreit
How about a PHPBB/Vbulletin clone...but better?

[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Lennon
I guess ideally they should be able to submit from either but if that
opens the app up to double submission than the most recent is fine as
long as I have a way to handle the old form gracefully as far as user
experience is concerned.  I'm open to ideas.

On Sep 15, 4:51 pm, Anthony  wrote:
> Actually, now that I think about it, by default, web2py sessions don't
> expire (except that the browser will expire the cookie at the end of the
> browser session). There is an auth setting that expires logins, but if your
> form page requires a login and the login had expired, I would expect the
> user to get redirected to the login page instead of the form page simply
> reloading. If you're using something like sessions2trash.py to expire
> sessions, that could cause the session to expire (i.e., get deleted) on the
> server side.
>
> Regardless of whether there's a session expiration problem, there could also
> be a problem with opening the form in multiple tabs/windows. I suppose there
> are workarounds in that case, but it depends on what you want to happen --
> should the user be allowed to submit the form from any and all open windows,
> just the first window, just the most recent window (which is the default
> behavior)?
>
> Anthony
>
>
>
>
>
>
>
> On Thursday, September 15, 2011 2:36:30 PM UTC-4, Lennon wrote:
>
> > So in that case it looks to me like web2py's timeout defaults to 3600
> > seconds (1 hour).
>
> > If a user had a form opened for over an hour and then attempted to
> > submit the form, would that cause the form to be returned without
> > errors just like the double form window would cause?
>
> > If so, that's probably what was happening as that seems much more
> > likely than having two form windows open.
>
> > If that is the case, starting a JS timer on each page that alerted and
> > redirected after an hour would solve this problem correct?
>
> > On Sep 15, 2:14 pm, Anthony  wrote:
> > > On Thursday, September 15, 2011 2:03:24 PM UTC-4, Lennon wrote:
>
> > > > In that case does anybody have any ideas about how to gracefully
> > > > handle this Session problem without removing session from
> > > > form.accepts?
>
> > > > Anthony suggested having a javascript pop-up when the session times
> > > > out but don't web2py sessions not timeout while the browser remains
> > > > open be default?
>
> > > If the browser is open but not sending any requests back to the server,
> > the
> > > server has no way of knowing it is still open, so the session can still
> > time
> > > out.
>
> > > Anthony


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
Ovidio,

Do you mean if I can connect to db2 with wsgi ? If so, the answer is
no. It's also using pyodbc just like mssql.

You can connect from console and web2py under rocket for sure.

On 9月15日, 午後5:19, Ovidio Marinho  wrote:
> Is can facilitate
>
> http://ochiba77.blogspot.com/2011/09/how-to-connect-db2-with-python-p...
>
>        Ovidio Marinho Falcao Neto
>              ovidio...@gmail.com
>                83   8826 9088 - Oi
>              83   9334 0266 - Claro
>                    Paraiba-Brasil
>
> 2011/9/15 Omi Chiba 
>
>
>
>
>
>
>
> > I'm having a exactly the same problem with this. Just like Adam describe, I
> > can connect mssql if I run web2py with rocket.
> > Pyodbc error with web2py under Apache and mod_wsgi
> > 
>
> > I tried with two different PC (Windows XP and 7) but the same error
> > happens.
> > Is there anyone who are connecting mssql with Apache and mod_wsgi ?
>
> > Error ticket on web2py:
> > It simply says failed to connect five times
>
> > (Failure to connect, tried 5 times:
> > 'NoneType' object has no attribute 'connect')
>
> > My setting is:
>
> >    - Windows XP/7 32bit
> >    - Python:  2.7.2
> >    - web2py: 1.98.2
> >    - pyodbc-2.1.11.win32-py2.7
> >    - mod_wsgi-win32-ap22py27-3.3.so
> >    - pywin32-216.win32-py2.7
> >    - httpd-2.2.21-win32-x86-openssl-0.9.8r
>
> > I tried Adam's way but encountered so many errors to build. I did built it
> > by visual C++ 2008 Express compiler but the same error.


[web2py] please sign your google code isse...

2011-09-15 Thread Massimo Di Pierro
... if you want to be acknowledged when the issue is closed. I cannot
always guess your names.


Re: [web2py] Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Ovidio Marinho
Is can facilitate

http://ochiba77.blogspot.com/2011/09/how-to-connect-db2-with-python-pyodbc.html



   Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
   83   8826 9088 - Oi
 83   9334 0266 - Claro
   Paraiba-Brasil



2011/9/15 Omi Chiba 

> I'm having a exactly the same problem with this. Just like Adam describe, I
> can connect mssql if I run web2py with rocket.
> Pyodbc error with web2py under Apache and mod_wsgi
> 
>
> I tried with two different PC (Windows XP and 7) but the same error
> happens.
> Is there anyone who are connecting mssql with Apache and mod_wsgi ?
>
>
> Error ticket on web2py:
> It simply says failed to connect five times
>
> (Failure to connect, tried 5 times:
> 'NoneType' object has no attribute 'connect')
>
>
> My setting is:
>
>- Windows XP/7 32bit
>- Python:  2.7.2
>- web2py: 1.98.2
>- pyodbc-2.1.11.win32-py2.7
>- mod_wsgi-win32-ap22py27-3.3.so
>- pywin32-216.win32-py2.7
>- httpd-2.2.21-win32-x86-openssl-0.9.8r
>
> I tried Adam's way but encountered so many errors to build. I did built it
> by visual C++ 2008 Express compiler but the same error.
>
>
>
>
>


[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread Eric
Thank you all for your answers.  Yes, I can pass the token in the
querystring if I put the token check in each and every function of the
API.  But when I put the token check in the exposed call action,
passing the token in the querystring does not work.  I'd like to find
a way to do a token check without checking in each and every API
function (i.e., by doing the check in the exposed API call), but I'm
guessing this will involve extending the Service module.

On Sep 15, 4:55 pm, pbreit  wrote:
> Can you just pass the token in the querystring?
>
> Once you start worrying about performance you can cache the token lookup
> query.


[web2py] Re: http get requests for google search api

2011-09-15 Thread Eric
I've not used any of the google api, but if you just need to access
and parse a json formatted api, you would need to use urllib or
urllib2 to make the request, then use simplejson or json or parse the
results:

import urllib
import simplejson

req = urllib.urlopen("http://google.com/api.json";) ##<-example only
my_vars = simplejson.load(req)

Atom should be similar -- urllib to access, then some Atom library to
parse the data.
Google offers their own Python client libraries, so you may want to
look into one of those.  The basic procedure should be the same,
however.

On Sep 15, 5:26 pm, Anaconda  wrote:
> Its my first time trying to access a webservice/api, would i use
> feedparser in web2py to to make http requests to a google api. They
> return their results in atom and json? I just need some
> guidance...thanks in advance guys.
>
> Regards


[web2py] Re: web2py - Best Practice

2011-09-15 Thread nic
I apologise to the group that I have not been able to pursue this over the 
past few weeks.

My idea to get the ball rolling was to try and create a google groups like 
'forum' on gae or fluxflex using the comments widget from the plugin_wiki as 
a base.

(Whilst it would be easy to just start a new google group it seems to me a 
simple web2py based app would be a much better way to start. Indeed the 
forum could be our first application)

>From there we could discuss the way forward as I believe this overall 
project is as much about co-ordination of the functionality, look and feel, 
documentation, installation process, plugin options, hosting, version 
control, etc. as it is about the actual code itself.

There have been some excellent new initiatives since my first message 
including instant press 2.0, instant admin and simple cms.

I was unable to create the 'forum' mostly due to lack of technical 
confidence and now a new job.

So rather than abandon the project, I was wondering if there was anyone else 
out there that may be interested in creating a 'forum' (ie google groups 
clone) on gae or flexflux or somewhere appropriate.

If there is no one but there is still interest in the project, then in a few 
weeks I will look at creating a google group, something like 
web2py-applications.

Cheers,
nic


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
Thank you both ! I really appreciate for your help!!!

I will start looking for alternative like mod_proxy from tomorrow
while we're waiting for super hero.

On 9月15日, 午後4:38, Willoughby  wrote:
> Sorry, I'm just starting out so I'm afraid that question is above my head at
> this point...
>
> As Ross said, maybe someone with deep WSGI understanding will chime in.


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Willoughby
Sorry, I'm just starting out so I'm afraid that question is above my head at 
this point...

As Ross said, maybe someone with deep WSGI understanding will chime in.


[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread Omi Chiba


lan, 

You can select your project, go to setup - Git and try the one under How to 
use 1. Download the repository.

Your application is under public_html - applications.






[web2py] http get requests for google search api

2011-09-15 Thread Anaconda
Its my first time trying to access a webservice/api, would i use
feedparser in web2py to to make http requests to a google api. They
return their results in atom and json? I just need some
guidance...thanks in advance guys.

Regards


[web2py] Re: PhoneGap, JqueryMobile and login/session management

2011-09-15 Thread pbreit
Any ideas?

[web2py] Re: background operations on upload-field

2011-09-15 Thread pbreit
Not exactly what you are looking for but might give you some ideas. I use 
this to create thumbnails of the uploaded image.


Field('image', 'upload', uploadfolder=request.folder+'static/uploads',
requires=IS_EMPTY_OR(IS_IMAGE())),
Field('image_thumb', 'upload', 
uploadfolder=request.folder+'static/uploads',
compute=lambda r: resize_image(r['image'], (150,130), 'thumb'),
readable=False, writable=False),


import os.path
from PIL import Image

def resize_image(image, size, path, rotate=0):
if image:
try:
img = Image.open('%sstatic/uploads/%s' % (request.folder, 
image))
img = img.convert("RGB")
img.thumbnail(size, Image.ANTIALIAS)
img = img.rotate(rotate)
root, ext = os.path.splitext(image)
filename = '%s_%s%s' %(root, path, ext)
img.save('%sstatic/uploads/%s' % (request.folder, filename))
return filename
except Exception, e:
return e
else:
return None


[web2py] Re: More Details on RESTful web2py?

2011-09-15 Thread Joseph.Piron
Hmm quite the same question as David G: I use the auto pattern feature
(really nice) but I don't see how to provide an index for a resource.
Am I missing something ?

Thanks !

On Aug 9, 12:11 am, David G  wrote:
> I have a similar question as Web2py Newbie.  I want to return all the
> rows from a table using a pattern like:
>
> /myapp/api/table
>
> I'm wondering if your answer for Newbie is specific to returning a
> single comment with the id of bookmark.id?  How would you code the GET
> method to get all the comments?
>
> Thanks!
>
> On Jun 16, 6:43 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Then you need to call
>
> > /myapp/api/as_rest/1.json
>
> > where "api" is the controller, "as_rest" is your function, "1" is the
> > {bookmark.id}.
>
> > On Jun 16, 12:51 am, Web2py Newbie
>
> >  wrote:
> > > At the moment it is:
>
> > > @request.restful()
> > > def as_rest():
> > >     def GET(*args,**vars):
> > >       patterns = ['/{bookmarks.id}',
> > >                   '']
> > >       parsed = db.parse_as_rest(patterns,args,vars)
> > >       if parsed.status==200: return parsed.response.json()
> > >       else:
> > >         posts = db().select(db.bookmarks.ALL)
> > >         return response.render('posts/index.html', locals())
>
> > > On Jun 16, 12:58 pm, Massimo Di Pierro 
> > > wrote:
>
> > > > please show us your code.
>
> > > > On Jun 15, 2:25 am, Web2py Newbie
>
> > > >  wrote:
> > > > > As a follow up:
>
> > > > > I want to use something like:
> > > > > /myapp/api/show_comment/id
> > > > > to show comment at id
> > > > > and
> > > > > /myapp/api/show_comment/
> > > > > To show all comments
>
> > > > > However, when I try this it complains ("invalid arguments").  I try to
> > > > > test id against None, but id is apparently a server object.
> > > > > Any ideas or do I just have to define all_comments?- Hide quoted text 
> > > > > -
>
> > - Show quoted text -


[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread pbreit
Can you just pass the token in the querystring?

Once you start worrying about performance you can cache the token lookup 
query.


[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Anthony
Actually, now that I think about it, by default, web2py sessions don't 
expire (except that the browser will expire the cookie at the end of the 
browser session). There is an auth setting that expires logins, but if your 
form page requires a login and the login had expired, I would expect the 
user to get redirected to the login page instead of the form page simply 
reloading. If you're using something like sessions2trash.py to expire 
sessions, that could cause the session to expire (i.e., get deleted) on the 
server side.

Regardless of whether there's a session expiration problem, there could also 
be a problem with opening the form in multiple tabs/windows. I suppose there 
are workarounds in that case, but it depends on what you want to happen -- 
should the user be allowed to submit the form from any and all open windows, 
just the first window, just the most recent window (which is the default 
behavior)?

Anthony

On Thursday, September 15, 2011 2:36:30 PM UTC-4, Lennon wrote:
>
> So in that case it looks to me like web2py's timeout defaults to 3600 
> seconds (1 hour). 
>
> If a user had a form opened for over an hour and then attempted to 
> submit the form, would that cause the form to be returned without 
> errors just like the double form window would cause? 
>
> If so, that's probably what was happening as that seems much more 
> likely than having two form windows open. 
>
> If that is the case, starting a JS timer on each page that alerted and 
> redirected after an hour would solve this problem correct? 
>
> On Sep 15, 2:14 pm, Anthony  wrote: 
> > On Thursday, September 15, 2011 2:03:24 PM UTC-4, Lennon wrote: 
> > 
> > > In that case does anybody have any ideas about how to gracefully 
> > > handle this Session problem without removing session from 
> > > form.accepts? 
> > 
> > > Anthony suggested having a javascript pop-up when the session times 
> > > out but don't web2py sessions not timeout while the browser remains 
> > > open be default? 
> > 
> > If the browser is open but not sending any requests back to the server, 
> the 
> > server has no way of knowing it is still open, so the session can still 
> time 
> > out. 
> > 
> > Anthony



[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread Massimo Di Pierro
Michele has created a x509 authentication module. Part his code is in
web2py trunk, part is pending waiting for Tim to include it in Rocket.
It will be available soon.

On Sep 15, 3:01 pm, Ross Peoples  wrote:
> I am very interested in token-based authentication and authorization using
> web services because I'm about to have to start getting in to that. I do
> have a question though, because I was wondering this: can you make a
> login(username, password) function that does the authentication, then saves
> something like logged_in=True to the session?
>
> I only ask because I don't know if web service clients (like XML-RPC and
> JSON-RPC) observe sessions. It would be interesting to see, because then you
> wouldn't need to worry about tokens and it would work more like the
> traditional web-based login from a browser.


[web2py] Re: Tricky query

2011-09-15 Thread HarryE
For Postgres you may try to enclose the string within $a$  instead of
''

try
query1 = "regexp_replace(lower(us2006_2010.title),
 '([^[:alnum:]_])', '', 'g') =
 regexp_replace(lower($a$%s$a$), '(
[^[:alnum:]_])', '',
 'g')" % some_string


HTH

On 15 sep., 12:48, Johann Spies  wrote:
> This might be more a python problem than Web2Py:
>
> I am using the following query:
>
>  query1 = "regexp_replace(lower(us2006_2010.title),
> '([^[:alnum:]_])', '', 'g') =
> regexp_replace(lower('%s'), '([^[:alnum:]_])', '',
> 'g')" % some_string
>
> It works OK until query1 expands to the following (see the '2,2'-...)
>
> "regexp_replace(lower(us2006_2010.title),
> '([^[:alnum:]_])', '', 'g') =
> regexp_replace(lower('2,2'-(Butane-1,4-diyl)dibenzimidazolium dichloride
> dihydrate'), '([^[:alnum:]_])', '', 'g')"
>
> How do I escape the ' after the second '2' in this query?
>
> I am using postgresql as database.
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
I see the lines when I run under rocket just like you did from console
but not sure how to check what's happening under wsgi.

Look like you're using windows. Are you able to connect mssql under
wsgi ??


On 9月15日, 午後3:16, Willoughby  wrote:
> That indicates to me that web2py is running without the mssql driver.
> When you start web2py, your window should list MSSQL/DB2 driver under the
> "Database drivers available" line...
>
>  Clipboard01.jpg
> 43K表示ダウンロード


[web2py] file locations once web2py is deployed on fluxflex

2011-09-15 Thread monotasker
Hi,

I realize this is really a support issue for fluxflex, but their customer 
service has been really slow (days) to respond. Since a few people on here 
seem to have tried out fluxflex I'm hoping someone can help.

I've deployed web2py using the one-click install on fluxflex, and it's 
working well. After using the online web2py ide to do some development, I 
cloned my fluxflex git repository only to find that it's empty. No web2py 
files. Does anyone know where the web2py files would be and how to get them 
out using git?

Thanks,

Ian


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Willoughby
That indicates to me that web2py is running without the mssql driver.
When you start web2py, your window should list MSSQL/DB2 driver under the 
"Database drivers available" line...
<>

Re: [web2py] Re: Process a file received via xmlrpc

2011-09-15 Thread António Ramos
I have only one file to process per day, so its not that important the
eficiency of the code.



Em 15 de setembro de 2011 20:44, António Ramos escreveu:

> My problem is that i need this woking in the next 2,3 days.
> While you work on that service, how do i solve my problem using mi code
> ASAP?
>
>
> Sorry and thank you
>
>
> 2011/9/15 Massimo Di Pierro 
>
>> You should not pass a file using xmlrpc. It is possible but not
>> efficient. Use a different service to upload files. I have some code
>> for this but need to clean it up.
>>
>> On Sep 15, 12:12 pm, António Ramos  wrote:
>> > hello,
>> > i receive a file via   xmlrpc
>> > this is my function
>> >
>> > @service.xmlrpc
>> > def checkflow(file,name):
>> >
>> db.image.insert(file=db.image.file.store(cStringIO.StringIO(file.data),name
>> ))
>> > return "ok"
>> >
>> > It is working as expected.
>> >
>> > Now i want to open the file and process every line
>> >
>> > how do i code the opening of the file ?
>> >
>> > thank you
>>
>
>


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
This is my Traceback. (Changed id, password..etc to 'x')

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 192, in restricted
exec ccode in environment
  File "C:/web2py/applications/Pricelist/models/db.py", line 8, in

db = DAL("mssql2://x:x@xx/xxx")
  File "C:\web2py\gluon\dal.py", line 3981, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
'NoneType' object has no attribute 'connect'


On 9月15日, 午後2:49, Willoughby  wrote:
> Can you post your Traceback?


[web2py] Re: Trying to implement token authentication for web service

2011-09-15 Thread Ross Peoples
I am very interested in token-based authentication and authorization using 
web services because I'm about to have to start getting in to that. I do 
have a question though, because I was wondering this: can you make a 
login(username, password) function that does the authentication, then saves 
something like logged_in=True to the session?

I only ask because I don't know if web service clients (like XML-RPC and 
JSON-RPC) observe sessions. It would be interesting to see, because then you 
wouldn't need to worry about tokens and it would work more like the 
traditional web-based login from a browser.


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Ross Peoples
Sounds like there's a problem with wsgihandler.py or main.py's wsgibase() 
function. I've never really gotten too involved with this part of web2py. My 
guess would be that you would somehow need to add pyodbc to the sys.path. 
But again, I don't know much about how WSGI works.

Is there more of a WSGI expert that can weigh in here? 


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Willoughby
Can you post your Traceback?


[web2py] Trying to implement token authentication for web service

2011-09-15 Thread Eric
OK, here's where my background as a non-CS/humanities major starts to
hurt.  I'm trying to implement a token authentication for a web
service using RPC.  I've also developed a sign-up/payment website for
the web service that uses web2py with auth.  I had the service working
fine using basic authentication, but then I realized that my target
audience may not always use a client with basic authentication
enabled, plus a token authentication system offers me other advantages
that I would like.

Anyway, I need advice on where exactly is best to check for the
token.  Intuitively, it seems reasonable to check for the token in the
call function that I've exposed, but what is confusing me is the fact
that all the arguments passed by the call go to the decorated RPC
function that is called.  Indeed, when I check the token in the
exposed call action and use curl to make the call using a valid token,
I get a "invalid function (api/call)" error.

So how would I should I pass a token to the exposed call action in
addition to passing other arguments to the various linked actions?

Or do I need to check for the token inside each of my remote
procedures?  Also, is there a good way to cache the token, or will I
need to check it on every call?

Finally, I had a counter working well with basic authentication to
limit calls to a certain number per month.  I guess if I have to check
for the token inside each of my remote procedures, then that's also
where I´ll need to put the counter.  This would seem to make for messy
and repetitive code, but I'm not sure what else to do.

Would anyone like to jump in or point me to a pertinent resource?  I'd
be very grateful.  Django has a token API plugin at:
https://github.com/jpulgarin/django-tokenapi/tree/master/tokenapi  but
I'm not able to extrapolate from their plugin to my app.

###
#model##
##
db.define_table('subscription',
Field('id','id'),
Field('token',
  label=T('User Token')),
Field('my_calls', type='integer', default=100,
  label=T('User Calls'),writable=False,readable=False),
Field('subscription_method', 'reference method', required=True,
  label=T('Subscription Method')),
Field('is_active','boolean',default=False,
  label=T('Active'),writable=False,readable=False),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
Field('created_by',db.auth_user,default=auth.user_id,
  label=T('Created By'),writable=False,readable=False),
Field('modified_by',db.auth_user,default=auth.user_id,
  label=T('Modified By'),writable=False,readable=False,
  update=auth.user_id),
format='%(plan)s',
migrate=settings.migrate)


##controller
# coding: utf8
from gluon.tools import Service
service = Service(globals())

@service.run
def my_function1(foo,bar):
...
return response.body.getvalue()

@service.run
def my_function2(foo,bar):
...
return response.body.getvalue()

@auth.requires_login()
def call(token):
row = db(db.subscription.token == token).select().first()
my_number = row.my_calls
if my_number > 0 & my_token == token:
db(db.subscription.token ==
my_token).update(my_calls=db.subscription.my_calls-1)
return service()
else:
raise Exception()


Re: [web2py] Re: Process a file received via xmlrpc

2011-09-15 Thread António Ramos
My problem is that i need this woking in the next 2,3 days.
While you work on that service, how do i solve my problem using mi code
ASAP?


Sorry and thank you


2011/9/15 Massimo Di Pierro 

> You should not pass a file using xmlrpc. It is possible but not
> efficient. Use a different service to upload files. I have some code
> for this but need to clean it up.
>
> On Sep 15, 12:12 pm, António Ramos  wrote:
> > hello,
> > i receive a file via   xmlrpc
> > this is my function
> >
> > @service.xmlrpc
> > def checkflow(file,name):
> >
> db.image.insert(file=db.image.file.store(cStringIO.StringIO(file.data),name
> ))
> > return "ok"
> >
> > It is working as expected.
> >
> > Now i want to open the file and process every line
> >
> > how do i code the opening of the file ?
> >
> > thank you
>


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
Ross,

Yes, I can connect from console and web2py under rocket.
It only fails to connect under wsgi on Apache. There are some post says it 
happens because it fails (cannot find) to "import pyodbc" and we can change 
Apache config to recognize the path just like environment setting on windows 
pc but I'm not sure. 


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Ross Peoples
There should be an extra { in there, sorry:

>>> import pyodbc
>>> conn = pyodbc.connect("DRIVER={SQL 
Server};SERVER=dns_or_ip_of_server;UID=username;PWD=password;DATABASE=database_name")


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Ross Peoples
According to the pyodbc's connection strings 
info: http://code.google.com/p/pyodbc/wiki/ConnectionStrings you will 
probably have to use a different driver than FreeTDS, since that's a 
*nix-only driver (I think). Microsoft has their own driver you can use on 
Windows machines.

Can you manually connect to MSSQL from a Python console session?

>>> import pyodbc
>>> conn = pyodbc.connect("DRIVER=SQL 
Server};SERVER=dns_or_ip_of_server;UID=username;PWD=password;DATABASE=database_name")

If you can, then you will probably need to update your DAL initialization 
with the name "SQL Server" for DRIVER.


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
I just tried python setup.py install and it finished without any error, 
reboot apache, but I still see the same error.
So, it's not binary but pyodbc itself doesn't support running under wsgi for 
windows ??




[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
> just download the source and run that.

I downloaded 
"pyodbc-2.1.11.zip"
 
and extracted. Can you explain how to "run that" ? 



[web2py] Re: Best way to quickly display formatted record from a table

2011-09-15 Thread howesc
have you tried:

row = db(...).select().first()

and in your view:

{{=row}}

and/or

{{=BEAUTIFY(row)}}

do either of those get you good enough?

so often people want to customize the display of just a single result so 
there is not a ton of tools to try and create a generic rendering.


Re: [web2py] Re: Comments/issues with SQLFORM.smartgrid

2011-09-15 Thread Ross Peoples
You'll get there Jim, just keep digging. I don't know all the pieces yet, 
but just like anything else, once you spend enough time with it, you'll know 
it like the back of your hand.

[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Willoughby
You don't have to build anything - just download the source and run that.

The windows binary doesn't support MSSQL - you instead run the source file 
and it will pull in the proper driver:
http://www.web2py.com/book/default/chapter/06#Dependencies



Re: [web2py] Best way to quickly display formatted record from a table

2011-09-15 Thread Jim Steil
Have you tried the readonly=True parm?  I haven't used it but seems like 
it should work...


-Jim


On 9/15/2011 1:16 PM, Eric wrote:

I'm sure I'm missing something, but I keep reading over the
documentation and I don't see how to easily display the readable,
writable fields of the current user's table record(s) as pre-formated,
non-form data.  It seems like there would be an easy way to display a
record as a table or div or list, similar to how forms are displayed
with SQLFORM but without the form elements.  The closest I can find is
to use SQLFORM and readonly=True, and then pre-populate each field
manually, setting each form.var using a db query.

Is there an easy way to do this?  Is there not a "pre-populate=True"
argument for SQLFORM or something?  I'm probably missing something
obvious.

To be clear, I'm not simply asking how to display some field pulled
from the db -- there are multiple easy ways to do that.  I'm asking if
there is a way to display all the fields of a record and display them
in a pre-formatted manner -- one that is as simple and quick as using
form=SQLFORM(db.foo) and {{=form}} when I create a form.

Is there a short, easy way to do this?

Thank you in advance for your help.



[web2py] anytime date+time picker

2011-09-15 Thread Massimo Di Pierro
web2py trunk dumped calendar.js for anytime.js

caveats:
- anytime uses a different convention (%i) than calendar (%M) for
minutes. I like the calendar notation better because it is the same as
Python. I changed the source of anytime to use the same syntax as
calendar. Is this is a good idea? I have emailed the author to see if
he is willing to change it too.
- anytime has lots more text on the popup that may need to be
internationalized. This it not done at the moment and the text "Day"
"Month", "Year", etc. is English only. Not clear what's an easy way to
do it.

Massimo


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

2011-09-15 Thread Massimo Di Pierro
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: Process a file received via xmlrpc

2011-09-15 Thread Massimo Di Pierro
You should not pass a file using xmlrpc. It is possible but not
efficient. Use a different service to upload files. I have some code
for this but need to clean it up.

On Sep 15, 12:12 pm, António Ramos  wrote:
> hello,
> i receive a file via   xmlrpc
> this is my function
>
> @service.xmlrpc
> def checkflow(file,name):
> db.image.insert(file=db.image.file.store(cStringIO.StringIO(file.data),name ))
> return "ok"
>
> It is working as expected.
>
> Now i want to open the file and process every line
>
> how do i code the opening of the file ?
>
> thank you


Re: [web2py] Re: Comments/issues with SQLFORM.smartgrid

2011-09-15 Thread Jim Steil
Thanks Ross, I will do that.  I wish I could be more help in resolving 
some of the small issues, but at this point I haven't jumped deep enough 
into the code.


-Jim

On 9/15/2011 1:19 PM, Ross Peoples wrote:

Jim,

I have also been working on finding ways to improve the grid. Massimo 
has encouraged me to submit tickets so that these can be tracked 
easier and don't get lost in discussion. I have already created a 
couple of issues myself: http://code.google.com/p/web2py/issues/list


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
Oh my god, I just gave up using IIS and now I need to give up my OS.
You're probably correct because some people mention about windows binary 
file and they tried to build by themself.

I hope someone share right binary file.

>Does it give more information about what object it's trying to call 
'connect' on?
Not really. 



[web2py] Response.stream problem with zip files

2011-09-15 Thread Deidre
I am using response.stream to download zip files, chunk size 4096. The
files appear to download fine but refuse to unzip. The response.header
content type is set for zip files. Is there a bug?
Peter


Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Jonathan Lundell
On Sep 15, 2011, at 10:49 AM, Ross Peoples wrote:

> That is correct. I removed Auth from the model, and just added one dummy 
> table, and this table definition had the same effect of auth.define_tables(). 
> Then when I added "migrate=False" to my dummy table, the times for XML 
> dropped back down to 20 ms. During all of this, the JSON times remained 
> between 60 ms and 65 ms.
> 
> I will submit a patch to Massimo for the updated files for preferring C json 
> libraries, using 'json' as the reference instead of simplejson.

I wonder if we should switch to the alternative jsonrpclib as well. It seems 
like the simplest approach, and it's nice in that it seems to parallel the 
xmlrpclib logic.

I don't like the way the functionality is getting layered. Seems like the 
proper handling of SSL and persistent connections ought to be independent of 
the RPC layer; seems dumb to have to re-implement it for both XML-RPC and 
JSON-RPC.

I'm running into the same thing with iOS. There's a good third-party library 
that handles all the high-level transport stuff--persistent connections, auth, 
proxies--and it's easy enough to implement JSON-RPC on top of that.

But the "standard" third-party XML-RPC library is like the Python one, wrapping 
the RPC and transport functionality into one piece. Why it's not in the native 
libraries I have no idea.



Anyway, I think it might be a good idea to do some micro-timing. Take a series 
of timestamps during the request and measure directly where the time is going. 
As Anthony says, the real mystery is why the JSON timings are so damned stable.

Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Jonathan Lundell
On Sep 15, 2011, at 11:31 AM, Ross Peoples wrote:

> Well, the jsonrpclib you had me download is that one that I was using for all 
> of the testing, as it is certainly faster than the simplejsonrpc.py file. I 
> also like the fact that it follows the xmlrpclib logic. I have found it to be 
> more consistent. I also like that it is mature. It is licensed under the 
> Apache license, so I don't think that including it will be a problem mixing 
> it with web2py's LGPL license.

Mariano, do you have a view on this? The issue is that the json-rpc client in 
contrib is very slow when it's using SSL because it doesn't use persistent 
connections.

[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Lennon
So in that case it looks to me like web2py's timeout defaults to 3600
seconds (1 hour).

If a user had a form opened for over an hour and then attempted to
submit the form, would that cause the form to be returned without
errors just like the double form window would cause?

If so, that's probably what was happening as that seems much more
likely than having two form windows open.

If that is the case, starting a JS timer on each page that alerted and
redirected after an hour would solve this problem correct?

On Sep 15, 2:14 pm, Anthony  wrote:
> On Thursday, September 15, 2011 2:03:24 PM UTC-4, Lennon wrote:
>
> > In that case does anybody have any ideas about how to gracefully
> > handle this Session problem without removing session from
> > form.accepts?
>
> > Anthony suggested having a javascript pop-up when the session times
> > out but don't web2py sessions not timeout while the browser remains
> > open be default?
>
> If the browser is open but not sending any requests back to the server, the
> server has no way of knowing it is still open, so the session can still time
> out.
>
> Anthony


Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Ross Peoples
I forgot to mention that I submitted a patch for preferring the C libraries 
in web2py: http://code.google.com/p/web2py/issues/detail?id=426

Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Ross Peoples
Well, the jsonrpclib you had me download is that one that I was using for 
all of the testing, as it is certainly faster than the simplejsonrpc.py 
file. I also like the fact that it follows the xmlrpclib logic. I have found 
it to be more consistent. I also like that it is mature. It is licensed 
under the Apache license, so I don't think that including it will be a 
problem mixing it with web2py's LGPL license.

[web2py] Re: Comments/issues with SQLFORM.smartgrid

2011-09-15 Thread Ross Peoples
Jim,

I have also been working on finding ways to improve the grid. Massimo has 
encouraged me to submit tickets so that these can be tracked easier and 
don't get lost in discussion. I have already created a couple of issues 
myself: http://code.google.com/p/web2py/issues/list


[web2py] Re: Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Ross Peoples
Strangely, I haven't had issues connecting to MSSQL using Linux, but I have 
never tried on a Windows machine. Usually, the problem lies with pyodbc (or 
ODBC specifically). Does it give more information about what object it's 
trying to call 'connect' on?

[web2py] Best way to quickly display formatted record from a table

2011-09-15 Thread Eric
I'm sure I'm missing something, but I keep reading over the
documentation and I don't see how to easily display the readable,
writable fields of the current user's table record(s) as pre-formated,
non-form data.  It seems like there would be an easy way to display a
record as a table or div or list, similar to how forms are displayed
with SQLFORM but without the form elements.  The closest I can find is
to use SQLFORM and readonly=True, and then pre-populate each field
manually, setting each form.var using a db query.

Is there an easy way to do this?  Is there not a "pre-populate=True"
argument for SQLFORM or something?  I'm probably missing something
obvious.

To be clear, I'm not simply asking how to display some field pulled
from the db -- there are multiple easy ways to do that.  I'm asking if
there is a way to display all the fields of a record and display them
in a pre-formatted manner -- one that is as simple and quick as using
form=SQLFORM(db.foo) and {{=form}} when I create a form.

Is there a short, easy way to do this?

Thank you in advance for your help.



[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Anthony
On Thursday, September 15, 2011 2:03:24 PM UTC-4, Lennon wrote:
>
> In that case does anybody have any ideas about how to gracefully 
> handle this Session problem without removing session from 
> form.accepts? 
>
> Anthony suggested having a javascript pop-up when the session times 
> out but don't web2py sessions not timeout while the browser remains 
> open be default?
>

If the browser is open but not sending any requests back to the server, the 
server has no way of knowing it is still open, so the session can still time 
out.

Anthony 


[web2py] Re: Comments/issues with SQLFORM.smartgrid

2011-09-15 Thread Anthony
On Thursday, September 15, 2011 1:52:02 PM UTC-4, Jim S wrote:
>
> 4.  In the grid first displayed by the smartgrid I'd like a way to 
> control the text that appears on the memberTag button.
>
There was this proposal to create singular and plural labels for DAL tables: 
https://groups.google.com/d/topic/web2py-developers/_roKOmGV10w/discussion. 
If that gets implemented, maybe the singular label could be used by default.

Anthony 


[web2py] Apache and mod_wsgi: cannot connect mssql by pyodbc

2011-09-15 Thread Omi Chiba
I'm having a exactly the same problem with this. Just like Adam describe, I 
can connect mssql if I run web2py with rocket.
Pyodbc error with web2py under Apache and mod_wsgi 


I tried with two different PC (Windows XP and 7) but the same error happens.
Is there anyone who are connecting mssql with Apache and mod_wsgi ?


Error ticket on web2py:
It simply says failed to connect five times

(Failure to connect, tried 5 times:
'NoneType' object has no attribute 'connect')


My setting is:

   - Windows XP/7 32bit
   - Python:  2.7.2
   - web2py: 1.98.2
   - pyodbc-2.1.11.win32-py2.7
   - mod_wsgi-win32-ap22py27-3.3.so
   - pywin32-216.win32-py2.7
   - httpd-2.2.21-win32-x86-openssl-0.9.8r
   
I tried Adam's way but encountered so many errors to build. I did built it 
by visual C++ 2008 Express compiler but the same error.






[web2py] Re: Forms working as expected most of the time but occasionally they simply clears

2011-09-15 Thread Lennon
In that case does anybody have any ideas about how to gracefully
handle this Session problem without removing session from
form.accepts?

Anthony suggested having a javascript pop-up when the session times
out but don't web2py sessions not timeout while the browser remains
open be default?  It seems like the cause must be the double form or
something else.

On Sep 14, 10:47 pm, Anthony  wrote:
> Also, cross-site request forgery
> attacks:https://www.owasp.org/index.php/Top_10_2010-A5
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, September 14, 2011 10:36:41 PM UTC-4, Cliff wrote:
>
> > Double submits can happen.
>
> > On Sep 14, 9:16 pm, Lennon  wrote:
> > > Thanks you!  Thanks to this info I was able to recreate the exact form
> > > clearing problem by loading another instance of the form in another
> > > tab/window.
>
> > > I have taken out the session from form.accepts in those forms and now
> > > everything is fine.
>
> > > Can anybody forsee any problems with my removing that?
>
> > > ~Lennon
>
> > > On Sep 14, 12:44 am, Massimo Di Pierro 
> > > wrote:
>
> > > > Is it possible they had two windows open on the same form? Passing the
> > > > session to accepts(...) uses a mechanism to prevent double form
> > > > submission that assume once a form is open, it is only opened one
> > > > (within the session) until it is submitted.
>
> > > > On Sep 13, 11:34 pm, Lennon  wrote:
>
> > > > > I have a few forms in a web2py shopping cart that I built from
> > > > > scratch. Most of the time the forms are working fine but once in
> > > > > awhile on submission a form will neither submit and redirect to the
> > > > > next page of the cart nor return any form errors as it usually does
> > > > > when there is a form error.
>
> > > > > Instead it simply refreshes the page and clears the form. What's
> > > > > really frustrating about this bug is that the same user will have
> > this
> > > > > bug and when they try again with the same browser and same data it
> > > > > will work fine.
>
> > > > > In fact, none of my team has been able to reproduce it but three of
> > > > > our users have reported it so I'm inclined to think something is
> > > > > wrong.
>
> > > > > One thing the forms all in common is that they all add session as an
> > > > > argument for form.accepts:
>
> > > > > if form.accepts(request.vars, session):
>
> > > > > Perhaps if something was screwy in my session it might cause this
> > > > > behavior? Although when I looked in the gluon/sqlhtml web2py file it
> > > > > didn't seem to use session for much of anything.
>
> > > > > The various forms and models are all very long so before posting all
> > > > > of that code, I was wondering if anybody simply had some thoughts on
> > > > > what might be causing this and/or could point me in the right
> > > > > direction.
>
> > > > > I'll be happy to post any part of the code that would help shed some
> > > > > light on the matter. Let me know, thanks.


[web2py] Re: SQLFORM not handling hidden fields? Or do I have a bug?

2011-09-15 Thread Cliff
All is good.

I just wanted to make sure I was seeing the intended behavior.

On Sep 15, 9:30 am, Massimo Di Pierro 
wrote:
> After reading this again and again... this is the intended behavior.
>
> form = SQLFORM(,hidden=...) causes the hidden fields to be passed
> with the submission, no more, no less. form.accepts(...) is not
> intended to read the received hidden fields and move them into
> form.vars. The reason is security. hidden fields can be tampered with.
> So you have to do:
>
> form.vars.a = request.vars.a # this will move the hidden field a (if
> exists) into the form
> form = SQLFORM(..., hidden=dict(a='b'))
>
> In the future we may consider having digitally signed hidden fields.
>
> On Aug 30, 12:43 pm, Cliff  wrote:
>
>
>
> > Hmmm.
>
> > I'm on 1.98.2.
>
> > This needs more investigation, but I can't do it today.
>
> > On Aug 30, 8:39 am, DenesL  wrote:
>
> > > SQLFORM with hidden fields works fine in 1.98.2:
>
> > > # model
> > > db.define_table('dog',
> > >   Field('name'),
> > >   Field('age', 'integer')
> > >   )
>
> > > # controller
> > > def newdog():
> > >   form = SQLFORM(db.dog, fields=['name'], hidden={'age': 1})
> > >   if form.accepts(request, session):
> > >     response.flash = 'ok'
> > >   elif form.errors:
> > >     response.flash = 'not ok'
> > >   return dict(form = form)
>
> > > Any new entry in the dog table will have the age field set to 1.


[web2py] Comments/issues with SQLFORM.smartgrid

2011-09-15 Thread Jim Steil
I've been playing with SQLFORM.smartgrid for the past couple of days and 
have a few issues I'd like to talk about.  Some of them I consider bugs 
and others are just some nice things that I think could be added easily.


For the purpose of a couple of these explanations, you'd need to see my 
model/controller, so here are the relevant parts:


##  db.py

member = db.define_table('member',
Field('memberId', 'id'),
Field('firstName', length=100, required=True, label='First Name'),
Field('middleInitial', length=20, label='Middle Initial'),
Field('lastName', length=50, required=True, label='Last Name'),
Field('secondFirstName', length=50, label='Second First Name'),
Field('secondLastName', length=50, label='Second Last Name'),
Field('householdSalutation', length=50, label='Household Salutation'),
Field('householdFirstName', length=50, label='Household First Name'),
Field('businessName', length=128, label='Business Name'),
Field('address', 'text'),
Field('city', length=50),
Field('state', length=2),
Field('postalCode', length=10, label='Postal Code'),
Field('homePhone', length=25, label='Home Phone'),
Field('email', length=255),
Field('legaciesBequests', 'decimal(11,2)', label='Legacies and 
Bequests'),

Field('notes', 'text'),
Field('joinedOn', 'date', label='Joined On',
  default=datetime.date.today(),
  requires=IS_DATE(format='%m/%d/%Y'),
  represent=lambda value, x: value.strftime('%m/%d/%Y')),
Field('deceased', 'boolean', default=False), fake_migrate=True,
migrate=False, format='%(firstName)s %(lastName)s')

member.firstName.requires = IS_NOT_EMPTY()
member.lastName.requires = IS_NOT_EMPTY()

tag = db.define_table('tag',
Field('tagId', 'id'),
Field('name', length=50, required=True, unique=True),
format='%(name)s')

tag.name.requires = [IS_NOT_EMPTY(),
 IS_NOT_IN_DB(db, 'tag.name')]

memberTag = db.define_table('memberTag',
Field('memberTagId', 'id', label='ID'),
Field('memberId', db.member, required=True, label='Member'),
Field('tagId', db.tag, required=True, label='Tag'), migrate=True, 
fake_migrate=True)


memberTag.memberId.requires = IS_IN_DB(db, db.member.id,
'%(firstName)s %(lastName)s',
zero=('select member'))
memberTag.tagId.requires = IS_IN_DB(db, db.tag.id,
'%(name)s', zero=('select tag'))
memberTag.tagId.represent = lambda t, r: db.tag(t).name
memberTag.memberId.represent = lambda m, r: '%s %s' % 
(db.member(m).firstName, db.member(m).lastName)


##  default.py
def members():
response.view = 'list.html'
columns = ['member.firstName', 'member.lastName', 'member.city',
   'member.state', 'member.phone', 'member.joinedOn',
   'memberCampaign.campaignId',
   'memberCampaign.amount', 'memberCampaign.paidOn',
   'memberTag.tagId']
grid = SQLFORM.smartgrid(db.member, columns=columns, details=False)
return dict(grid=grid)


1.  When using jquery-ui (ui-lightness in my case) the icons on all of 
the buttons are lost.
2.  When clicking on the memberTag button in the member grid I go to a 
page to edit the member tags.  Above my grid are three buttons, labeled:


member
Jim Steil
memberTag

If I click on the member button it takes me back to the member grid.  If 
I click on the 'Jim Steil' button it will return me to the 'view' page 
unless it is disabled, then it returns me to the member grid page.  In 
my scenario I'd like it to return me to the member 'edit' page because I 
have the details=False set on my smartgrid.


3.  For these buttons that appear across the top I'd like to be able to 
control their names in some way.  It appears that I can override all of 
the buttons with the links parameter on the smartgrid setup, but I was 
hoping to find a way to more easily (less boilerplate code) accomplish that.
4.  In the grid first displayed by the smartgrid I'd like a way to 
control the text that appears on the memberTag button.
5.  Using jquery-ui (ui-lightness) I can't tell which page I'm currently 
on looking at the page navigation buttons at the bottom of the grid.  
The current page should be set off in some way to give an indication of 
the current page.
6.  Allow initial grid sort sequence to be applied to smartgrid via 
orderby parameter.  Also allow initial ordering of subsequent grid 
(memberTag).


The smartgrid is an incredibly powerful tool that will allow me to 
create web applications very quickly.  I'd like to get these items 
discussed to see if the community thinks they are worth while.


Thanks for taking the time to read through this long post.  If it would 
be helpful I could put together my entire app and put it out for others 
to use to comment on the smartgrid functionality as well.


-Jim




Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Ross Peoples
That is correct. I removed Auth from the model, and just added one dummy 
table, and this table definition had the same effect of 
auth.define_tables(). Then when I added "migrate=False" to my dummy table, 
the times for XML dropped back down to 20 ms. During all of this, the JSON 
times remained between 60 ms and 65 ms.

I will submit a patch to Massimo for the updated files for preferring C json 
libraries, using 'json' as the reference instead of simplejson.


Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Anthony
On Thursday, September 15, 2011 1:09:27 PM UTC-4, Ross Peoples wrote:
>
>
> So it looks like we've narrowed down the problem to migrations.
>

That sounds about right (it is usually suggested to turn off migrations in 
order to improve speed), but the real puzzle is why turning off migrations 
(or removing all table definitions) does not speed up the JSON calls.

Anthony


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

2011-09-15 Thread Cliff
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] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Jonathan Lundell
On Sep 15, 2011, at 10:09 AM, Ross Peoples wrote:

> I think we can rule out the json serializer. I just replaced the code in 
> tools.py and serializers.py and tried this. I also confirmed that the C json 
> library was installed. There wasn't any change. However, I wonder if I should 
> send those changes to Massimo as a patch anyways since it seems like we 
> should prefer the C libraries when possible.

I think that'd be a good idea. However, please covert it to using the name 
'json' instead of 'simplejson', if you haven't already done that. This is a 
good time to do it, because it's getting some good testing.


> 
> As for your other question, simply having "auth = Auth(db)" in there without 
> defining the tables seems to slow down XML by a few ms, but we are talking 
> 5ms at most. The define_tables call is what slows it down the other 20 ms. 

That makes sense. There's one table definition in the Auth(db) call. 

> 
> However, it may not be Auth at all. I just defined a dummy table just to see 
> what would happen, and the XML times went back up to 50 ms, so it looks like 
> the DAL is somehow causing the slowdown. And I just run a second test on the 
> dummy table with "migrate=False" and the numbers dropped back down to 20ms.
> 
> So it looks like we've narrowed down the problem to migrations.

And through all this the JSON timings stayed high?

[web2py] Process a file received via xmlrpc

2011-09-15 Thread António Ramos
hello,
i receive a file via   xmlrpc
this is my function

@service.xmlrpc
def checkflow(file,name):
db.image.insert(file=db.image.file.store(cStringIO.StringIO(file.data),name))
return "ok"

It is working as expected.

Now i want to open the file and process every line

how do i code the opening of the file ?


thank you


Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Ross Peoples
I think we can rule out the json serializer. I just replaced the code in 
tools.py and serializers.py and tried this. I also confirmed that the C json 
library was installed. There wasn't any change. However, I wonder if I 
should send those changes to Massimo as a patch anyways since it seems like 
we should prefer the C libraries when possible.

As for your other question, simply having "auth = Auth(db)" in there without 
defining the tables seems to slow down XML by a few ms, but we are talking 
5ms at most. The define_tables call is what slows it down the other 20 ms. 

However, it may not be Auth at all. I just defined a dummy table just to see 
what would happen, and the XML times went back up to 50 ms, so it looks like 
the DAL is somehow causing the slowdown. And I just run a second test on the 
dummy table with "migrate=False" and the numbers dropped back down to 20ms.

So it looks like we've narrowed down the problem to migrations.


Re: [web2py] Re: Suggestion: Input field alignment for decimal and integer

2011-09-15 Thread Martin Weissenboeck
+1
Martin

2011/9/15 Omi Chiba 

> Kenji san,
>
> The adjusting the length feature looks great !  : )
>
>
>


[web2py] improve your drop box with .chosen()

2011-09-15 Thread Richard
Hello all,

I discover Chosen recently thanks to Ramana and it new web2py instant
admin plugin

http://sramana.in/web2py-instant-admin/

http://harvesthq.github.com/chosen/

Richard


Re: [web2py] Re: widget for list:reference field in SQLFORM

2011-09-15 Thread Richard Vézina
No Anthony is rigth I miss read your description.

You get something like this :

see attach image

It the normal browser representation for multiselect field.

You can pick more then one item of you displayed list by combining Ctrl +
mouse clic

Now as you know you can use a jQuery plugin to make an other look and
feel...

Richard

On Thu, Sep 8, 2011 at 5:17 PM, Richard Vézina
wrote:

> Wich version of web2py version do you use... The problem you describe hab
> been a issue in the past that have been fixed now...
>
> Maybe you have a old version of web2py?
>
> Richard
>
> On Thu, Sep 8, 2011 at 4:16 PM, monotasker  wrote:
>
>> Thanks for the links. I'm still trying to figure out how much to look
>> for the framework to do and how much to look for client-side
>> solutions. This helps.
>>
>> Ian
>>
>> On Sep 7, 5:48 pm, Anthony  wrote:
>> > Since developers will have different preferences for multiselect widgets
>> and
>> > it is so easy to plug something in on the client side, I'm not sure the
>> > framework needs to commit to a particular widget. Here are a few good
>> > options:
>> >
>> >
>> http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/...http://www.quasipartikel.at/multiselect/http://jqueryui.com/demos/autocomplete/#multiple
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Wednesday, September 7, 2011 5:12:55 PM UTC-4, monotasker wrote:
>> >
>> > > OK. That description confused me in the book (I'm not used to
>> > > describing multi-select boxes as a 'drop-box' so I assumed it meant
>> > > drop-down). Thanks. I think it would be more usable if the default
>> > > widget were something like the one used in the app-creation wizard for
>> > > table and field creation:
>> >
>> > > 1) present a single text field with autocomplete based on the
>> > > referenced table, then
>> >
>> > > 2) when the user fills that field (or on ?) another field
>> > > appears below it.
>> >
>> > > A multi-select field doesn't seem to me very user-friendly if we're
>> > > trying to select multiple options from a long pre-populated set of
>> > > choices. The user has to use CTRL-LMB just to select a second option,
>> > > and has to scroll manually through the list. Do you think this is
>> > > something worth changing?
>> >
>> > > Ian
>> >
>> > > On Sep 7, 4:02 pm, Anthony  wrote:
>> > > > No, you should not get a series of select boxes, just a single
>> > > multi-select
>> > > > box, like
>> > > > this:
>> > >
>> http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple.
>> >
>> > > > The book states that a list:reference field "produces a
>> > > SELECT/OPTIONmultiple drop-box".
>> >
>> > > > Anthony
>> >
>> > > > On Wednesday, September 7, 2011 3:43:11 PM UTC-4, monotasker wrote:
>> >
>> > > > > In a form generated by SQLFORM I'm finding that a list:reference
>> field
>> > > > > is represented with a single list-box. What I expected based on
>> the
>> > > > > section on list: in the manual was a series of select boxes.
>> Was
>> > > > > I reading the manual wrong? If not, does anyone know why I might
>> be
>> > > > > getting the wrong widget presented?
>> >
>> > > > > Here is the relevant part of my model:
>> >
>> > > > > db.define_table('tags',
>> > > > > Field('tag', 'string'), format='%(tag)s')
>> >
>> > > > > db.tags.tag.requires = IS_NOT_IN_DB(db, db.tags.tag)
>> >
>> > > > > db.define_table('questions',
>> > > > > Field('question', 'text', required=True),
>> > > > > Field('answer', 'string', required=True),
>> > > > > Field('score', default=1, required=True),
>> > > > > Field('answer2', 'string', default='null'),
>> > > > > Field('score2', 'double', default=0.5),
>> > > > > Field('answer3', 'string', default='null'),
>> > > > > Field('score3', 'double', default=0.3),
>> > > > > Field('readable_answer', 'string', default='null'),
>> > > > > Field('tags', 'list:reference tags'),
>> > > > > Field('nt_frequency', 'double'))
>> >
>> > > > > db.questions.tags.requires = IS_IN_DB(db, 'tags.id',
>> db.tags._format,
>> > > > > multiple=True)
>> >
>> > > > > And here is the controller that creates the form:
>> >
>> > > > > def create_question():
>> > > > > form = SQLFORM(db.questions)
>> > > > > if form.accepts(request.vars, session):
>> > > > > response.flash = 'form accepted'
>> > > > > elif form.errors:
>> > > > > response.flash = 'form has errors'
>> > > > > else:
>> > > > > response.flash = 'please fill out the form'
>> > > > > return dict(form=form)
>>
>
>
<>

[web2py] Re: Apache + mod_wsgi: Allow http access for application

2011-09-15 Thread Omi Chiba
Ross,

It works great, Thank you !!


Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Jonathan Lundell
On Sep 15, 2011, at 8:45 AM, Ross Peoples wrote:

> The other big performance hit is that 2-3 places in web2py we do this:
> 
> import contrib.simplejson as simplejson
> 
> That really needs to change to something like this (with corresponding 
> changes to the code)
> 
> try:
> import json # try stdlib (py2.6)
> except ImportError:
> try:
> import simplejson as json   # try external module
> except:
> import gluon.contrib.simplejson as json   # fall back on pure-Python 
> module
> 
> The problem is that we need to be using the optimized C libraries when we can 
> (that's why XML is faster, I think). But the copy in contrib is pure Python. 
> It works, but it's slow.
> 
> 
> 
> I had a feeling this might have something to do with it. I wonder if 
> preferring the pure Python libraries is adding to Problem #1.

I can't think how, but it'd be interesting to find out. 

A temporary alternative would be to write this:

try:
import json as simplejson # try stdlib (py2.6)
except ImportError:
try:
import simplejson   # try external module
except:
import gluon.contrib.simplejson as simplejson   # fall back on 
pure-Python module

...so as not to disturb the existing naming. It'd need to be done in 
gluon.serializers and utils (I think--wherever Service is defined).

Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Jonathan Lundell
On Sep 15, 2011, at 8:45 AM, Ross Peoples wrote:

> > 1. Auth and JSON-RPC
> > -
> > 
> > This problem stems from enabling Auth:
> > 
> > auth = Auth(db)
> > auth.define_tables()
> > 
> > Whenever Auth is enabled, the average time per request for XML-RPC and 
> > JSON-RPC are about 45 ms and 65 ms, respectively. However, whenever Auth is 
> > not enabled, these times change dramatically, but only for XML-RPC. The 
> > average time per request for XML-RPC and JSON-RPC is now about 20 ms and 60 
> > ms, respectively. The time it takes for JSON-RPC requests to run drops 
> > about 5 ms per request, however, the time XML-RPC requests drops by 25 ms 
> > (more than half).
> 
> Am I correct that pretty much the same thing happens if you turn off the 
> define_tables call?
> 
> Yes, when I am 'disabling' auth, I am basically removing auth.define_tables() 
> and auth = Auth(db)
> 

What happens if you leave the auth = line but comment out the define_tables 
line?

Re: [web2py] RPC Performance Testing with Sessions and SSL

2011-09-15 Thread Ross Peoples


On Thursday, September 15, 2011 11:35:24 AM UTC-4, Jonathan Lundell wrote:
>
> On Sep 15, 2011, at 8:04 AM, Ross Peoples wrote:
>
> > The way it is now, the JSON runs first, then the XML. I never interleaved 
> the two because I wanted to keep it simple. I can make the XML run first 
> instead and do another test:
> > 
> > FINAL RESULTS
> > ==
> > JSON-RPC Average Time: 59.91 ms
> > JSON-RPC Total Time Taken: 10007.80 ms
> > XML-RPC Average Time: 21.84 ms
> > XML-RPC Total Time Taken: 6201.04 ms
> > Result: XML won by: 38.07 ms (274.3% faster)
> > 
> > No change when I made XML run first, before JSON.
>
> Thanks for the summary, Ross. Comments below.
>
> > 
> > 
> > SUMMARY OF THREE ISSUES
> > 
> > 
> > 1. Auth and JSON-RPC
> > -
> > 
> > This problem stems from enabling Auth:
> > 
> > auth = Auth(db)
> > auth.define_tables()
> > 
> > Whenever Auth is enabled, the average time per request for XML-RPC and 
> JSON-RPC are about 45 ms and 65 ms, respectively. However, whenever Auth is 
> not enabled, these times change dramatically, but only for XML-RPC. The 
> average time per request for XML-RPC and JSON-RPC is now about 20 ms and 60 
> ms, respectively. The time it takes for JSON-RPC requests to run drops about 
> 5 ms per request, however, the time XML-RPC requests drops by 25 ms (more 
> than half).
>
> Am I correct that pretty much the same thing happens if you turn off the 
> define_tables call?
>
Yes, when I am 'disabling' auth, I am basically removing 
auth.define_tables() and auth = Auth(db)
 

> A side note: one table (signatures) gets defined in the Auth() call 
> regardless. I didn't see anything else in Auth.__init__ that could account 
> for much time. The HMAC key logic by default reads a file from the file 
> system, but presumably that's thoroughly cached by the OS.
>
> It's not so surprising that bypassing the Auth logic speeds things up a 
> bit, though 25ms seems a bit high for what it's doing. But I can't see any 
> explanation for a differential effect between JSON and XML.
>
> > 
> > 2. Unicode and JSON-RPC
> > ---
> > 
> > As for the unicode issue, I noticed this as well. I also tried going back 
> to simplejsonrpc, but that also returns strings as unicode. Are unicode 
> strings a requirement of the JSON-RPC protocol?
>
> I don't actually see a problem with this. In contrib.simplejsonrpc we 
> specify a charset of utf8 on the content-type header. Just for idle 
> curiosity you could try that and get rid of the charset specifier and see if 
> that's the trigger. But we actually want that.
>
I removed the utf8 part of the content-type and it still returns as unicode. 
I don't have a problem with unicode, as I think this what it should be 
doing. I am equally interested in why XML doesn't do this.
 

> What I don't understand is why local strings like web2py_path are unicode 
> under JSON but not under XML. 
>
> > 
> > 
> > 3. SSL and web2py's simplejsonrpc
> > 
> > 
> > Finally, on a note about web2py's simplejsonrpc implementation, it runs 
> much slower over SSL, possibly because it makes a new connection for each 
> request, whereas jsonrpclib and xmlrpclib leave the connection open for 
> subsequent requests.
>
> Yes, that's certainly what's going on. 
>
>
> The other big performance hit is that 2-3 places in web2py we do this:
>
> import contrib.simplejson as simplejson
>
> That really needs to change to something like this (with corresponding 
> changes to the code)
>
> try:
> import json # try stdlib (py2.6)
> except ImportError:
> try:
> import simplejson as json   # try external module
> except:
> import gluon.contrib.simplejson as json   # fall back on 
> pure-Python module
>
> The problem is that we need to be using the optimized C libraries when we 
> can (that's why XML is faster, I think). But the copy in contrib is pure 
> Python. It works, but it's slow.
>

I had a feeling this might have something to do with it. I wonder if 
preferring the pure Python libraries is adding to Problem #1.


  1   2   >