[web2py:23408] Documentation issue with Services

2009-06-06 Thread David Watson

Hi, in the services section on this page:

http://www.web2py.com/examples/default/tools

I believe the intent of the example is actually something closer to
the following:

def myfunction(a,b):
return int(a)+int(b)

As it stands, when called with the parameters encoded as demonstrated:

http://127.0.0.1:8000/sugar/default/call/run/myfunction/2/3

The return is:

23

I think this should be:

5

Cheers,
David

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26634] Re: Authentication for services

2009-07-16 Thread David Watson

I'm using web2py 1.65.5 with google app engine.

I've run into a problem with request.args in relation to my json
calls:

@service.json
def json_read_nologin():
return request.args[0]

or the same function defined sans the service decorator, both work
fine, as long as I don't pass something containing an @ sign, i.e.

http://localhost:8000/init/default/json_read_nologin/u...@domain.com

this generates an invalid request even if url encoded:

http://localhost:8000/init/default/json_read_nologin/user%40domain.com

I'm not sure what I'm doing wrong here but this behavior doesn't seem
like what I'd expect.

Thanks,
David

On Jun 23, 8:47 pm, mdipierro  wrote:
> You cannot mix authorization and services this way. It is complicated
> an there are many cases
>
> If you have
>
> @auth.requires_login()
> def acceptme():
>     return 'accepted'
>
> you can call "http:///acceptme.json"; and you will get aJSON
> response. You do not need the decorator.
>
> @auth.requires_login()
> @service.json()
> def acceptme():
>     return 'accepted'
> def run(): return service()
>
> exposes "http:///service/json/acceptme"; before requiring login.
>
> @service.json()
> def acceptme():
>     return 'accepted'
> @auth.requires_login()
> def run(): return service()
>
> this should work but will require login for all services
>
> @service.json()
> @auth.requires_login()
> def acceptme():
>     return 'accepted'
> def run(): return service()
>
> this is not completely clear to me why does not work but I see some
> logical problems.
>
> Massimo
>
> On Jun 23, 7:31 pm, Hasanat Kazmi  wrote:
>
> > Here is an interesting behavior.
> > i have following function
>
> > @auth.requires_login()
> > @service.json
> > @service.jsonrpc
> > def acceptme():
> >     return "accepted"
>
> > in this case, whatever username and password I give, I get returned
> > "accepted" but if I put @auth.requires_login() after @service.jsonrpc,
> > it always returns me "Object does not exist" .
>
> > I call it like 
> > this:http://hasanatkazmi%40gmail.com:**...@localhost:8000/sahana/admin/cal...
>
> > Anyone has an idea whats going on?
>
> > On Jun 4, 7:28 am, Alexei Vinidiktov 
> > wrote:
>
> > > I've tried this with the pyjamas tutorial and it didn't work. I've
> > > enabled user registration and registered a user whose credentials are
> > > used in the URL below. I got a server error when a function requiring
> > > user authentication was called.
>
> > > I changed the line
>
> > > JSONProxy.__init__(self, "../../default/call/jsonrpc", ["getTasks",
> > > "addTask","deleteTask"])
>
> > > to read
>
> > > JSONProxy.__init__(self,
> > > "http://myemail%40gmail.com%3amypassw...@127.0.0.1:8000/pyjamas/defaul...";,
> > > ["getTasks", "addTask","deleteTask"])
>
> > > What am I missing?
>
> > > Thanks.
>
> > > On Mon, Jun 1, 2009 at 12:51 PM, mdipierro  
> > > wrote:
>
> > > > OK. As you request since the latest version in trunk you can do
>
> > > > @auth.requires_login()
> > > > def index(): return 'hello world'
>
> > > > and access it with
>
> > > >   curl -u username:passwordhttp://127.0.0.1:8000/app/default/index
>
> > > > or
>
> > > >   curlhttp://username:passw...@127.0.0.1:8000/app/default/index
>
> > > > In the latter case username and password have to be encoded by
> > > > urllib.quote()
>
> > > > works for services too.
>
> > > > Massimo
>
> > > > On May 31, 10:43 pm, Dan  wrote:
> > > >> Since my last message on this thread, I came up with a patch to the
> > > >>Auth.login() code that lets me do what I need, so figured I should
> > > >> post it here. Let me know if you see any issues with this approach (or
> > > >> improvements to it).
>
> > > >> To recap, what I want to do is to let a script runing wget (not a
> > > >> browser)loginand then work with some parts of the app that require
> > > >> membership in groups. I want to pass the user's name and password to
> > > >> theloginformusing post variables in the URL. This is not normally
> > > >> possible with web2py'sAuth.login() function, so it needs to be
> > > >> modified, like this-
>
> > > >> referring to source code 
> > > >> here:http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc...
> > > >> Change these 3 lines ...
> > > >>  622          ifFORM.accepts(form, request.vars, session,
> > > >>  623                          formname='login',
> > > >>  624                          onvalidation=onvalidation):
>
> > > >> ... to be these 3 lines:
> > > >> if username in request.vars.keys() and request.vars.password and \
> > > >>        FORM.accepts(form, request.vars,
> > > >>             formname=None, onvalidation=onvalidation):
>
> > > >> This change lets theformtake the username and password from the
> > > >> URL's post variables (or theformitself - but not both of course).
> > > >> Then my script willloginusing wget's optional arguments "--keep-
> > > >> session-cookies --save-cookies=" when submitting the user name and
> > > >> password to the app'sloginfunction. These w

[web2py:26635] Authentication against a web2py hosted json function from python client

2009-07-16 Thread David Watson

Hi,

I'm trying to get authentication working for a python client talking
to a web2py json function. I'm using the @auth.requires_login()
decorator but I can't seem to get a successful login (works fine from
the user login web page). I'm using client code copied directly from
the last example on this page:

http://www.voidspace.org.uk/python/articles/authentication.shtml

Should the basic auth work here, or do I need more infrastructure for
either the redirect handler or the cookies? No matter what, it always
redirects to the login page even though I'm passing the properly
initialized credentials.

Thanks,
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26651] Re: Authentication against a web2py hosted json function from python client

2009-07-16 Thread David Watson

Fran,

What is this login_bare that you speak of? The page that you
reference, which I had previously read, makes no mention of it, and
google seems to know nothing of it.

I assume your example is server-side, if so, where do the username and
password come from? And are we talking about the basic auth client
encoding that I referenced?

Thanks,
David

On Jul 16, 5:54 am, Fran  wrote:
> On Jul 16, 8:18 am, David Watson  wrote:
>
> > I'm trying to get authentication working for a python client talking
> > to a web2py json function. I'm using the @auth.requires_login()
> > decorator but I can't seem to get a successful login (works fine from
> > the user login web page).
>
> Don't use @auth.requires_login() decorator with services.
> (See this 
> thread:http://groups.google.com/group/web2py/browse_thread/thread/6c7fe7cb5b...)
>
> Instead use:
>
> user = auth.login_bare(username, password)
> if not user:
>     return "authentication failed"
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26652] Re: Authentication for services

2009-07-16 Thread David Watson

Perhaps ironically, the case I'm talking about is machine-to-machine,
no humans involved. While I understand the need for human readability,
that restriction seems like throwing the baby out with the bathwater.
That said, I'll have a look at routes.py.

On Jul 16, 10:54 am, mdipierro  wrote:
> This is a big can of worms.
>
> @ is a reserved character and if used in urls, it should be encoded. I
> do not want encoded chars in the URL because this defies the all
> purpose: readability by humans.
>
> Massimo
>
> On Jul 16, 9:07 am, Jonathan Lundell  wrote:
>
> > On Jul 16, 2009, at 6:35 AM, Jonathan Lundell wrote:
>
> > > On Jul 16, 2009, at 6:18 AM, mdipierro wrote:
>
> > >> web2py validates the URL and does allow the @ sign in the URL, only
> > >> alphanumaric characters, _, - and non-consecutive . and /.
>
> > > Did you mean "does not allow"? Shouldn't the validation be more
> > > generous in the args section? There's nothing wrong with this as an
> > > http URL:
>
> > >http://localhost:8000/init/default/json_read_nologin/user%40domain.com
>
> > > (Where does the validation happen?)
>
> > OK, that last was a dumb question, since I just finished reformatting  
> > regex_url.
>
> > So here's the validation for args: ([\w\-][\=\./]?)+
>
> > I don't want to make a proposal here, since I have no idea what args  
> > consumers are assuming for validation. But it does seem reasonable in  
> > the abstract to allow a little more than this pattern permits.
>
> > (And I could see piggybacking on the IS_HTTP_URL validator for the  
> > first cut.)
>
> > >> On Jul 16, 2:07 am, David Watson  wrote:
> > >>> I'm using web2py 1.65.5 with google app engine.
>
> > >>> I've run into a problem with request.args in relation to my json
> > >>> calls:
>
> > >>> @service.json
> > >>> def json_read_nologin():
> > >>>    return request.args[0]
>
> > >>> or the same function defined sans the service decorator, both work
> > >>> fine, as long as I don't pass something containing an @ sign, i.e.
>
> > >>> http://localhost:8000/init/default/json_read_nologin/u...@domain.com
>
> > >>> this generates an invalid request even if url encoded:
>
> > >>>http://localhost:8000/init/default/json_read_nologin/user
> > >>> %40domain.com
>
> > >>> I'm not sure what I'm doing wrong here but this behavior doesn't  
> > >>> seem
> > >>> like what I'd expect.
>
> > >>> Thanks,
> > >>> David
>
> > >>> On Jun 23, 8:47 pm, mdipierro  wrote:
>
> > >>>> You cannot mix authorization and services this way. It is
> > >>>> complicated
> > >>>> an there are many cases
>
> > >>>> If you have
>
> > >>>> @auth.requires_login()
> > >>>> def acceptme():
> > >>>>    return 'accepted'
>
> > >>>> you can call "http:///acceptme.json"; and you will get aJSON
> > >>>> response. You do not need the decorator.
>
> > >>>> @auth.requires_login()
> > >>>> @service.json()
> > >>>> def acceptme():
> > >>>>    return 'accepted'
> > >>>> def run(): return service()
>
> > >>>> exposes "http:///service/json/acceptme"; before requiring login.
>
> > >>>> @service.json()
> > >>>> def acceptme():
> > >>>>    return 'accepted'
> > >>>> @auth.requires_login()
> > >>>> def run(): return service()
>
> > >>>> this should work but will require login for all services
>
> > >>>> @service.json()
> > >>>> @auth.requires_login()
> > >>>> def acceptme():
> > >>>>    return 'accepted'
> > >>>> def run(): return service()
>
> > >>>> this is not completely clear to me why does not work but I see some
> > >>>> logical problems.
>
> > >>>> Massimo
>
> > >>>> On Jun 23, 7:31 pm, Hasanat Kazmi  wrote:
>
> > >>>>> Here is an interesting behavior.
> > >>>>> i have following function
>
> > >>>>> @auth.requires_login()
> > >>

[web2py:26754] Re: Authentication against a web2py hosted json function from python client

2009-07-17 Thread David Watson

Thanks so much for the help. I use json for some other functions, but
that was not a requirement here so I just hit it with a hammer and
switched to xmlrpc. I didn't realize that you could use the service
proxy like that for json though, so that was a very useful exercise.

-d

On Jul 16, 11:48 am, Fran  wrote:
> On Jul 16, 4:43 pm, Fran  wrote:
>
> > @service.xmlrpc
>
> I see you use JSON, so:
> @service.jsonrpc
>
> > from xmlrpclib import ServerProxy
> > server = ServerProxy('http:///app/default/call/xmlrpc')
> > print server.myfunction('user', 'password')
>
> from jsonrpc import ServiceProxy
> server = ServiceProxy("http://localhost:8000/app/default/call/
> jsonrpc")
> server.myfunction("user","password")
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27344] problem with web2py changing default application from init to welcome while it's running?

2009-07-24 Thread David Watson

Hi,

I am running tip of the trunk from svn. I have my application in init
and deleted the welcome application. I am running on ubuntu server
9.04 on a single core pentium 4. I start web2py with:

sudo nohup python web2py.py -p 80 -i 192.168.1.40 -a whatever

Everything is fine and the pages are served from init when
requesting / as a for instance.

Somewhere in a few hours, web2py starts pointing / at /welcome/default/
index. If I restart, then it goes back to serving / against init.

I don't think I've done anything wrong. Could this be a bug?

Thanks,
David

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27497] Re: problem with web2py changing default application from init to welcome while it's running?

2009-07-28 Thread David Watson

Thanks for all the responses.

I'm not doing os.chdir in my code.

What happens is this:

I launch from an ssh session to my ubuntu 9.04 server machine:

sudo nohup python web2py.py -p 80 -i 192.168.1.40 -a whatever &

I hit port 80 in the browser and get /init/default/index.

I then exit the ssh session by typing exit.

I hit port 80 in the browser and get /welcome/default/index which
fails since there is no welcome application.

Any ideas what could be going on? I tried to debug this, but I'm not
sure what's happening when I exit.

Thanks,
David

On Jul 25, 3:14 am, mdipierro  wrote:
> which os?
>
> do you do a os.chdir in your code? If so, that would cause this
> problem and it is not allowed because it is not thread safe.
>
> Massimo
>
> On Jul 25, 12:11 am, Jonathan Lundell  wrote:
>
> > On Jul 24, 2009, at 9:59 PM, Yarko Tymciurak wrote:
>
> > > I think it more likely he has another web2py process hanging around,  
> > > and depending on when one or the other grabs the request;
>
> > That should be easy enough to test: kill the known process and see if  
> > anybody is still at home.
>
> > > another possibility (although I don't understand how) is some cache  
> > > somewhere...  (browser cache doesn't make sense for this...)
>
> > > On Fri, Jul 24, 2009 at 11:48 PM, Jonathan Lundell  
> > >  wrote:
> > > On Jul 24, 2009, at 9:38 PM, Yarko Tymciurak wrote:
>
> > >> On Fri, Jul 24, 2009 at 11:27 PM, Jonathan Lundell  > >> > wrote:
> > >> On Jul 24, 2009, at 9:20 PM, Yarko Tymciurak wrote:
>
> > >>> check your processes - make sure you don't have another instance  
> > >>> of web2py still running somewhere...
>
> > >> There's a path in wsgibase that looks like it could cause this  
> > >> behavior if the execution environment gets sufficiently messed up:
>
> > >> Here - maybe this will help you read this: (you'll notice a few  
> > >> lines above, if no 'a' ... application set, then start with 'init'):
>
> > >>             if not os.path.exists(request.folder):  # if we can't  
> > >> find the app.
> > >>                 if request.application=='init':        # and we've  
> > >> already tried init, then
> > >>                     request.application = 'welcome'   # next try  
> > >> welcome
> > >>                     redirect(html.URL(r=request))   # and go  
> > >> there
>
> > >> This is the default sequence:  of no 'a' (app) specified, then  
> > >> start with init, and if it fails, then go to 'welcome'
>
> > >> Make sense now?
>
> > > It made sense already, and if request.folder (or more likely its  
> > > progenitors) gets corrupted somehow (I have no theory), then we'd  
> > > see something like what David is seeing, even in the absence of an  
> > > actual welcome application.
>
> > >> - Yarko
>
> > >> It might be worth looking to see whether that path ever gets taken,  
> > >> and if so why.
>
> > >>> On Fri, Jul 24, 2009 at 10:30 PM, David Watson  > >>> > wrote:
>
> > >>> Hi,
>
> > >>> I am running tip of the trunk from svn. I have my application in  
> > >>> init
> > >>> and deleted the welcome application. I am running on ubuntu server
> > >>> 9.04 on a single core pentium 4. I start web2py with:
>
> > >>> sudo nohup python web2py.py -p 80 -i 192.168.1.40 -a whatever
>
> > >>> Everything is fine and the pages are served from init when
> > >>> requesting / as a for instance.
>
> > >>> Somewhere in a few hours, web2py starts pointing / at /welcome/
> > >>> default/
> > >>> index. If I restart, then it goes back to serving / against init.
>
> > >>> I don't think I've done anything wrong. Could this be a bug?
>
> > >>> Thanks,
> > >>> David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27499] Re: problem with web2py changing default application from init to welcome while it's running?

2009-07-28 Thread David Watson

Also, there's only one web2py process as yarko had asked.

On Jul 28, 10:07 am, David Watson  wrote:
> Thanks for all the responses.
>
> I'm not doing os.chdir in my code.
>
> What happens is this:
>
> I launch from an ssh session to my ubuntu 9.04 server machine:
>
> sudo nohup python web2py.py -p 80 -i 192.168.1.40 -a whatever &
>
> I hit port 80 in the browser and get /init/default/index.
>
> I then exit the ssh session by typing exit.
>
> I hit port 80 in the browser and get /welcome/default/index which
> fails since there is no welcome application.
>
> Any ideas what could be going on? I tried to debug this, but I'm not
> sure what's happening when I exit.
>
> Thanks,
> David
>
> On Jul 25, 3:14 am, mdipierro  wrote:
>
> > which os?
>
> > do you do a os.chdir in your code? If so, that would cause this
> > problem and it is not allowed because it is not thread safe.
>
> > Massimo
>
> > On Jul 25, 12:11 am, Jonathan Lundell  wrote:
>
> > > On Jul 24, 2009, at 9:59 PM, Yarko Tymciurak wrote:
>
> > > > I think it more likely he has another web2py process hanging around,  
> > > > and depending on when one or the other grabs the request;
>
> > > That should be easy enough to test: kill the known process and see if  
> > > anybody is still at home.
>
> > > > another possibility (although I don't understand how) is some cache  
> > > > somewhere...  (browser cache doesn't make sense for this...)
>
> > > > On Fri, Jul 24, 2009 at 11:48 PM, Jonathan Lundell  
> > > >  wrote:
> > > > On Jul 24, 2009, at 9:38 PM, Yarko Tymciurak wrote:
>
> > > >> On Fri, Jul 24, 2009 at 11:27 PM, Jonathan Lundell  > > >> > wrote:
> > > >> On Jul 24, 2009, at 9:20 PM, Yarko Tymciurak wrote:
>
> > > >>> check your processes - make sure you don't have another instance  
> > > >>> of web2py still running somewhere...
>
> > > >> There's a path in wsgibase that looks like it could cause this  
> > > >> behavior if the execution environment gets sufficiently messed up:
>
> > > >> Here - maybe this will help you read this: (you'll notice a few  
> > > >> lines above, if no 'a' ... application set, then start with 'init'):
>
> > > >>             if not os.path.exists(request.folder):  # if we can't  
> > > >> find the app.
> > > >>                 if request.application=='init':        # and we've  
> > > >> already tried init, then
> > > >>                     request.application = 'welcome'   # next try  
> > > >> welcome
> > > >>                     redirect(html.URL(r=request))   # and go  
> > > >> there
>
> > > >> This is the default sequence:  of no 'a' (app) specified, then  
> > > >> start with init, and if it fails, then go to 'welcome'
>
> > > >> Make sense now?
>
> > > > It made sense already, and if request.folder (or more likely its  
> > > > progenitors) gets corrupted somehow (I have no theory), then we'd  
> > > > see something like what David is seeing, even in the absence of an  
> > > > actual welcome application.
>
> > > >> - Yarko
>
> > > >> It might be worth looking to see whether that path ever gets taken,  
> > > >> and if so why.
>
> > > >>> On Fri, Jul 24, 2009 at 10:30 PM, David Watson 
> > > >>>  > > >>> > wrote:
>
> > > >>> Hi,
>
> > > >>> I am running tip of the trunk from svn. I have my application in  
> > > >>> init
> > > >>> and deleted the welcome application. I am running on ubuntu server
> > > >>> 9.04 on a single core pentium 4. I start web2py with:
>
> > > >>> sudo nohup python web2py.py -p 80 -i 192.168.1.40 -a whatever
>
> > > >>> Everything is fine and the pages are served from init when
> > > >>> requesting / as a for instance.
>
> > > >>> Somewhere in a few hours, web2py starts pointing / at /welcome/
> > > >>> default/
> > > >>> index. If I restart, then it goes back to serving / against init.
>
> > > >>> I don't think I've done anything wrong. Could this be a bug?
>
> > > >>> Thanks,
> > > >>> David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27720] problem with web2py, gae, and taskqueue

2009-07-31 Thread David Watson

Has anybody had any luck getting the taskqueue from google app engine
to work in web2py? I presume that it should work under dev_appserver,
but isn't working for me.

I defined a simple default controller based on the gae example at the
google blog:

def process_post_file():
rows=db(db.files.processed=='False').select(db.files.ALL)
for row in rows:
f = row.file_blob
email_addresses = f.split('\n')
for email_address in email_addresses:
taskqueue.add(url='/init/default/sendmail', params=dict
(to=email_address, subject='Hello ' + email_address, body='this is a
message!'))
return dict(message=T('mail was queued'))

def sendmail():
mail.send_mail(
'm...@my.com', # needs to be from settings
request.vars['to'],
request.vars['subject'],
request.vars['body'])

but my sendmail function never gets called. Everything seems fine up
through the task queue, but no callback.

Thanks,
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:28654] Re: problem with web2py, gae, and taskqueue

2009-08-14 Thread David Watson

Thanks, Dan. I didn't know about the difference between dev and
production or the admin interface so that was helpful.

Cheers,
David

On Aug 5, 1:24 pm, Dan  wrote:
> done.http://www.web2py.com/AlterEgo/default/show/247
>
> On Aug 3, 10:19 pm, mdipierro  wrote:
>
>
>
> > Dan,
>
> > can you post an AlterEgo entry about this? It would be useful to other
> > users. Email me if you need the edit code.
>
> > Massimo
>
> > On Aug 4, 12:03 am, Dan  wrote:
>
> > > Hi David-
> > > Yes, I'm usingGAE'staskqueue with web2py, and it works in both the
> > > dev and production environments. Note that in the dev environment, the
> > > tasks do not run automatically - you will need to manually trigger
> > > them using thehttp://localhost:8080/_ah/adminwebconsole.
>
> > > I wasn't able to get the url-encoded payload variable working
> > > properly, so I tried the other method that uses a params dictionary
> > > and it worked OK. (I'm not a python expert, so it's quite likely that
> > > I was doing something wrong with urllib.) In any case, here is the
> > > code snippet that works for me to create atask:
>
> > > if request.env.web2py_runtime_gae: # if running on Google App Engine
> > >     from google.appengine.api.labs import taskqueue
>
> > > tqparams = {'row_id':r}
> > > taskqueue.add(
> > >   url=URL(r=request, c='mycontroller', f='call/run/taskfunction'),
> > >   params=tqparams,
> > > )
>
> > > and the controller file that gets called has these lines in it
> > > (simplified for this example):
>
> > > def call():
> > >     return service()
>
> > > @service.run      ## we'll use this to enable this as a taskqueue-
> > > friendly URL
> > > def taskfunction():
> > >     """
> > >    For security, this URL should be restricted to the admin user in
> > > app.yaml
> > >     """
> > >     return dict(row_id=request.vars.row_id)
>
> > > On Jul 31, 11:38 am, David Watson  wrote:
>
> > > > Has anybody had any luck getting the taskqueue from google app engine
> > > > to work in web2py? I presume that it should work under dev_appserver,
> > > > but isn't working for me.
>
> > > > I defined a simple default controller based on thegaeexample at the
> > > > google blog:
>
> > > > def process_post_file():
> > > >     rows=db(db.files.processed=='False').select(db.files.ALL)
> > > >     for row in rows:
> > > >         f = row.file_blob
> > > >         email_addresses = f.split('\n')
> > > >         for email_address in email_addresses:
> > > >             taskqueue.add(url='/init/default/sendmail', params=dict
> > > > (to=email_address, subject='Hello ' + email_address, body='this is a
> > > > message!'))
> > > >     return dict(message=T('mail was queued'))
>
> > > > def sendmail():
> > > >     mail.send_mail(
> > > >             '@my.com', # needs to be from settings
> > > >             request.vars['to'],
> > > >             request.vars['subject'],
> > > >             request.vars['body'])
>
> > > > but my sendmail function never gets called. Everything seems fine up
> > > > through thetaskqueue, but no callback.
>
> > > > Thanks,
> > > > David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29880] the book 2nd ed. - is there any option but lulu?

2009-09-02 Thread David Watson

Hi,

I tried to buy the book this morning on lulu. What a nightmare.
Started in safari 4.03 on OS X, couldn't get logged in or registered,
generally came back with blank pages. Tried it in FF 3.5. Same thing.
I even tried Chrome, which went so far as to report connection error
102 at the same point the other two died. I've concluded that lulu is
about as reliable as a crack addict in a meth lab. Googling lulu
indicates I'm not alone.

So, is there an alternative to getting the book without lulu involved?

Thanks,
David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29915] Re: the book 2nd ed. - is there any option but lulu?

2009-09-02 Thread David Watson

On Sep 2, 2:08 pm, Yarko Tymciurak  wrote:
> I am able to login to Lulu;  are you running behind a firewall, or with some
> network security that would prevent a secure (https) connection?  That is
> required for login.

Nope. I have lots of ssh, ssl, and htttps connections going all the
time.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py] couchdb sample: AttributeError: 'Server' object has no attribute 'commit'

2011-01-05 Thread David Watson
Hello,

I am running CouchDBX 1.0.1 on Mac OS X 10.6 with couchdb-python
version 0.8. I am using the following code in db.py:

db=DAL('couchdb://127.0.0.1:5984')
db.define_table('person',Field('name'))
id=db.person.insert(name='Jim')
print id
row=db.person(id)
print row
print db(db.person.id==id).update(name="john")
print db.person(id)
del db.person[id]

However, when the code executes, it tries to call commit and dies. See
the traceback below. I realize that this support is experimental but I
wasn't sure if there was something I was doing wrong. I'm running hg
clones of trunk for both web2py and couchdb-python.

Thanks,
David

VERSION
web2py™ Version 1.91.6 (2011-01-04 15:55:30)
Python  Python 2.6.1: /usr/bin/python

TRACEBACK

Traceback (most recent call last):
  File "/Users/david/web2py/gluon/main.py", line 466, in wsgibase
BaseAdapter.close_all_instances(BaseAdapter.commit)
  File "/Users/david/web2py/gluon/dal.py", line 272, in
close_all_instances
action(instance)
  File "/Users/david/web2py/gluon/dal.py", line 1036, in commit
return self.connection.commit()
AttributeError: 'Server' object has no attribute 'commit'


[web2py] Re: couchdb sample: AttributeError: 'Server' object has no attribute 'commit'

2011-01-05 Thread David Watson
Hi Massimo,

I updated and now it fails with a similar exception on close:

Traceback (most recent call last):
  File "/Users/david/web2py/gluon/main.py", line 466, in wsgibase
BaseAdapter.close_all_instances('commit')
  File "/Users/david/web2py/gluon/dal.py", line 283, in
close_all_instances
instance.connection.close()
AttributeError: 'Server' object has no attribute 'close'

Thanks,
David

On Jan 5, 11:41 pm, mdipierro  wrote:
> this should now be fixed.please try.
>
> On Jan 5, 8:21 pm, David Watson  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I am running CouchDBX 1.0.1 on Mac OS X 10.6 with couchdb-python
> > version 0.8. I am using the following code in db.py:
>
> >     db=DAL('couchdb://127.0.0.1:5984')
> >     db.define_table('person',Field('name'))
> >     id=db.person.insert(name='Jim')
> >     print id
> >     row=db.person(id)
> >     print row
> >     print db(db.person.id==id).update(name="john")
> >     print db.person(id)
> >     del db.person[id]
>
> > However, when the code executes, it tries to call commit and dies. See
> > the traceback below. I realize that this support is experimental but I
> > wasn't sure if there was something I was doing wrong. I'm running hg
> > clones of trunk for both web2py and couchdb-python.
>
> > Thanks,
> > David
>
> > VERSION
> > web2py™       Version 1.91.6 (2011-01-04 15:55:30)
> > Python  Python 2.6.1: /usr/bin/python
>
> > TRACEBACK
>
> > Traceback (most recent call last):
> >   File "/Users/david/web2py/gluon/main.py", line 466, in wsgibase
> >     BaseAdapter.close_all_instances(BaseAdapter.commit)
> >   File "/Users/david/web2py/gluon/dal.py", line 272, in
> > close_all_instances
> >     action(instance)
> >   File "/Users/david/web2py/gluon/dal.py", line 1036, in commit
> >     return self.connection.commit()
> > AttributeError: 'Server' object has no attribute 'commit'


[web2py] Re: couchdb sample: AttributeError: 'Server' object has no attribute 'commit'

2011-01-06 Thread David Watson
I had the same crash as David Marko on the welcome app.

On Jan 6, 2:23 am, David Marko  wrote:
> I have the same problem here.
>
> Whats more with latest trunk I cant 
> openhttp://127.0.0.1:8000/welcome/default/index. It raises:
>
> Traceback (most recent call last):
>   File "c:\java\web2py\gluon\restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "c:/java/web2py/applications/welcome/models/db.py" 
> , line 42, in 
> 
>     auth.define_tables()                           # creates all needed tables
>   File "c:\java\web2py\gluon\tools.py", line 1173, in define_tables
>     format='%(first_name)s %(last_name)s (%(id)s)')
>   File "c:\java\web2py\gluon\dal.py", line 3431, in define_table
>     polymodel=polymodel)
>   File "c:\java\web2py\gluon\dal.py", line 468, in create_table
>     not_null = self.NOT_NULL(field.default,field.type)
>   File "c:\java\web2py\gluon\dal.py", line 665, in NOT_NULL
>     return 'NOT NULL DEFAULT %s' % self.represent(default,field_type)
>   File "c:\java\web2py\gluon\dal.py", line 1087, in represent
>     r = self.represent_exceptions(self,obj,fieldtype)
> TypeError: represent_exceptions() takes exactly 3 arguments (4 given)


[web2py] smartgrid: events and callbacks downstream?

2011-12-13 Thread David Watson
I am using smartgrid to generate some table and form interfaces to my
database. Is there a way to use something like the process function
with smartgrid to get callbacks? It's not clear to me how I can hook
into the downstream click-generated events from the edit form, for
instance. I just want to be able to hook some code into the event
stream after the successul creation of the database object described
by a row in the smart grid. I'm hoping there's a way, but if not,
having that kind of event chaining would be really useful.

Thanks,
David


[web2py] Re: smartgrid: events and callbacks downstream?

2011-12-13 Thread David Watson
This kind of answers my question:

http://comments.gmane.org/gmane.comp.python.web2py/72424

but I'll add just to weigh in on Massimo's question re: requirements
for this feature and a use case. My scenario is relatively easy to
describe:
I have a database of various tables representing different object
types. Each of these object types has a REST web service associated
with it that needs to be called relative to CRUD functions around the
database. So all I want is to be able to hook or get a callback on the
database trigger that allows me to do something like:

import requests

def on_insert_success_callback(row):
# url and auth omitted for brevity
r = requests.post(insert_api_url, data=row)
if r.status_code == 200:
   # yay
else:
# the second parameter would be needed to prevent the
potential
# for endless tight loops between failed insert and delete
callbacks
delete_row(row, no_cascade_callback)


def on_delete_success_callback(row):
r = request.post(delete_api_url, data=row)
if r.status_code == 200:
# yay
else:
print 'orphaned object deleted from database but not
webservice'

Given the complexity that Massimo describes, I'd argue for a very
simple CRUD trigger callback set as most all of my web service usage
patterns map to that directly.

Hope this helps.

David






On Dec 13, 2:44 pm, David Watson  wrote:
> I am using smartgrid to generate some table and form interfaces to my
> database. Is there a way to use something like the process function
> with smartgrid to get callbacks? It's not clear to me how I can hook
> into the downstream click-generated events from the edit form, for
> instance. I just want to be able to hook some code into the event
> stream after the successul creation of the database object described
> by a row in the smart grid. I'm hoping there's a way, but if not,
> having that kind of event chaining would be really useful.
>
> Thanks,
> David


[web2py] web2py app with no CSS or javascript?

2011-09-11 Thread David Watson
I'm using the latest stable release of web2py. I need to produce an
app that has no CSS or javascript. Is the quickest way to do this just
stripping these things from layout.html or is there a setting
somewhere that would cause the rendering to go plain-jane?

Thanks,
David


[web2py] Re: web2py with twitter bootstrap - very clean interface ...

2011-11-09 Thread David Watson
On Sep 26, 5:43 pm, Bruno Rocha  wrote:
> We are planning to include it in the next web2py version.
>
> I will share the actual w2p after a clean up.
>

Hi, does anybody know if the twitter-bootstrap integration code is
available for web2py yet? The one shown here:

http://labs.blouweb.com/bootstrap/

I was about to embark on some web2py work that requires twitter-
bootstrap, but I wasn't sure if this was available yet.

Thanks,
David


[web2py] Re: web2py with twitter bootstrap - very clean interface ...

2011-11-09 Thread David Watson
Sorry, I found it:

http://groups.google.com/group/web2py-developers/browse_thread/thread/d9c3698044c4902f/8eb26098b55388d3?lnk=gst&q=bootstrap#8eb26098b55388d3

On Nov 9, 12:47 pm, David Watson  wrote:
> On Sep 26, 5:43 pm, Bruno Rocha  wrote:
>
> > We are planning to include it in the next web2py version.
>
> > I will share the actual w2p after a clean up.
>
> Hi, does anybody know if the twitter-bootstrap integration code is
> available for web2py yet? The one shown here:
>
> http://labs.blouweb.com/bootstrap/
>
> I was about to embark on some web2py work that requires twitter-
> bootstrap, but I wasn't sure if this was available yet.
>
> Thanks,
> David


[web2py] django and sqlalchemy on web2py

2011-11-14 Thread David Watson
Hi All,

I've been working with the code here:

http://code.google.com/p/django-and-sqlalchemy-on-web2py/

to "port" a legacy django model to web2py.

It works fine for simple single inheritance cases, and cases where the
ancestor depth is one. However, when I try to use a user-defined
django model that inherits from another user-defined django model, I
get errors at runtime.

I suspect there is additional metaclass munging needed in
DjangoModelFactory but I'm not sure what that looks like exactly.

When I add this class PersonChoice to django.py:

class Person(Model):
name=CharField('Full Name',max_length=64,null=True)
choices=ManyToManyField(Choice)

class PersonChoice(Person):
test = CharField('test', max_length=64, null=True)


I get:

Traceback (most recent call last):
  File "django.py", line 213, in 
test_django_model()
  File "django.py", line 33, in test_django_model
class PersonChoice(Person):
  File "/usr/lib/python2.7/site-packages/gluon/dal.py", line 4592, in
__init__
db and db._adapter.sequence_name(tablename)
AttributeError: 'str' object has no attribute '_adapter'


And if I change the previous example to:

class PersonChoice(Model, Person):
test = CharField('test', max_length=64, null=True)

I get:

Traceback (most recent call last):
  File "django.py", line 213, in 
test_django_model()
  File "django.py", line 33, in test_django_model
class PersonChoice(Model, Person):
  File "django.py", line 181, in __new__
obj = type.__new__(cls,name,bases,attrs)
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a
(non-strict) subclass of the metaclasses of all its bases

Does anyone know if there's a way to get the DjangoModelFactory to
handle the additional layer of inheritance?

Thanks,
David


[web2py] packaging return from executesql as Rows object?

2011-11-16 Thread David Watson
Does anybody have example code showing how to package the return from
executesql as a gluon.sql.Rows object?

I have tried:

raw_rows = legacy_db.executesql(sqlstr, as_dict=True)
from gluon import sql
columns = ['col1', 'col2', 'col3']
rowsobj = sql.Rows(legacy_db, raw_rows, columns)
table = SQLTABLE(rowsobj)

but this blows up in sql.Rows. I'm just looking for a quick and dirty
(throw-away) way to do some reports with existing complex SQL queries.

Thanks,
Dave


[web2py] Re: packaging return from executesql as Rows object?

2011-11-18 Thread David Watson
Hi Bruno,

I tried both of these but neither one worked. I just wound up with an
empty table. I wasn't sure why you used Row objects in one list
comprehension and Storage objects in the other, but neither one
produced a list that the table likes. :( Not sure what's going on
there but there were no exceptions thrown and I know the raw rows list
is properly populated prior to the conversion to Rows.

Thanks,
David

On Nov 16, 8:09 pm, Bruno Rocha  wrote:
> wait, there is a better way.
>
> >>> from gluon.dal import Rows, Row
> >>> result = access.db.executesql("SELECT first_name, last_name FROM
>
> auth_user", as_dict=True)>>> rows = Rows(records=[Row(item) for item in 
> result])
> >>> rows[0].first_name
>
> u'Bruno'
>
> You can set other values for each Row.


[web2py] Re: packaging return from executesql as Rows object?

2011-11-18 Thread David Watson
This produces a table with a single column and the rows consisting of
what should have been the header columns followed by the body columns
manifested as rows also.

On Nov 17, 10:25 am, DenesL  wrote:
> Why not just:
>
> table = TABLE(THEAD(columns), TBODY(raw_rows))
>
> On Nov 16, 3:43 pm, David Watson  wrote:
>
>
>
>
>
>
>
> > Does anybody have example code showing how to package the return from
> > executesql as a gluon.sql.Rows object?
>
> > I have tried:
>
> >     raw_rows = legacy_db.executesql(sqlstr, as_dict=True)
> >     from gluon import sql
> >     columns = ['col1', 'col2', 'col3']
> >     rowsobj = sql.Rows(legacy_db, raw_rows, columns)
> >     table = SQLTABLE(rowsobj)
>
> > but this blows up in sql.Rows. I'm just looking for a quick and dirty
> > (throw-away) way to do some reports with existing complex SQL queries.
>
> > Thanks,
> > Dave


[web2py] fedora, pip, web2py, virtualenv, and mysql

2011-11-28 Thread David Watson
I've installed web2py via pip in a virtualenv with the --no-site-
packages option:

virtualenv --no-site-packages env

pip install web2py

which gives me version 1.98.2. I added a VERSION file in the root and
this got web2py running.

I copied admin and my application, which depends on mysql, into the
applications directory. I start web2py and admin is working, but my
app fails when it tries to connect to the database.

I've installed both MySQLdb and pymysql into the virtualenv:

(env)[watson@watson-thinkpad web2py_heroku (master)]$ python
Python 2.7.1 (r271:86832, Apr 12 2011, 16:15:16)
[GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> import pymysql

but web2py refuses to recognize either at startup:

(env)[watson@watson-thinkpad web2py_heroku (master)]$ env/bin/w2p_run
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
1.98.2
Database drivers available: SQLite3

Does anybody know why web2py doesn't see the database drivers? I'm
pretty close to having a working web2py on heroku.

Thanks,
David


[web2py] Re: fedora, pip, web2py, virtualenv, and mysql

2011-11-29 Thread David Watson
I don't believe that's true.

For instance, in the aforementioned example my code has a mysql db uri
specified in db.py, but the mysql driver is never loaded, despite its
obvious presence in the virtualenv. Only the sqlite3 driver gets
loaded.

The different behavior can clearly be observed after running w2p_clone
and then running w2p_run from env/bin vs. env/web2py/bin. The former
is 1.98.2 and the latter is 1.99.3. Just an observation, not
necessarily causation.

I noted the old version on the pip install. The version getting
invoked seems to change with the location in the project tree. I
believe there is something wrong with the way the pip install web2py
sets up within the virtualenv but I'm not sure what. The following
examples are, of course, after running source env/bin/activate.


Running env/bin/w2p_run from root directory (web2py version correct,
but
no mysql drivers loaded):

(env)[watson@watson-thinkpad web2py_heroku (master)]$ env/bin/w2p_run
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.98.2 (2011-08-28 09:59:26)
Database drivers available: SQLite3, mongoDB

=
Running env/web2py/w2p_run after w2p_clone from root directory (note
wrong
web2py version, but mysql drivers loaded) :
=

(env)[watson@watson-thinkpad web2py_heroku (master)]$ env/web2py/
w2p_run
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.98.2 (2011-08-28 09:59:26)
Database drivers available: SQLite3, pymysql, mongoDB
Starting hardcron...
WARNING:web2py:GUI not available because Tk library is not installed

=
Running env/web2py/w2p_run from same directory (note correct web2py
version and mysql drivers loaded)
=

(env)[watson@watson-thinkpad web2py (master)]$ w2p_run
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.3 (2011-11-28 08:28:56) dev
Database drivers available: SQLite3, pymysql, mongoDB
Starting hardcron...
WARNING:web2py:GUI not available because Tk library is not installed

Hope this helps.

Thanks,
David

On Nov 28, 5:51 pm, Christopher Steel  wrote:
> To change db backends you need to edit the db.py file and that should do it.


[web2py] 'id' on 1.99.3 with SQLFORM.grid and links

2011-12-01 Thread David Watson
I am running web2py version 1.99.3

I have the following code in my default controller. The view shows the
item. When i run
  links = [lambda row:
A('Edit',_href=URL("default","sweeps",args=[row.id])),
 lambda row:
A('Delete',_href=URL("default","promos",args=[row.id]))]
grid2 = SQLFORM.grid(db.auth_user, links=links)
return dict(item=grid2)

but it blows up with a keyerror on id. I thought my lambda links were
correct, but maybe something has changed or I've gotten it wrong?

Thanks,
David

 'id'

Traceback (most recent call last):
  File "/home/watson/latte/web2py/gluon/restricted.py", line 204, in
restricted
exec ccode in environment
  File "/home/watson/latte/web2py/applications/latte/controllers/
default.py", line 139, in 
  File "/home/watson/latte/web2py/gluon/globals.py", line 162, in

self._caller = lambda f: f()
  File "/home/watson/latte/web2py/applications/latte/controllers/
default.py", line 45, in apps
(db.portal_keyword.user_id==auth.user_id), links=links,
fields=fields, paginate=10, ui="jquery-ui")
  File "/home/watson/latte/web2py/gluon/sqlhtml.py", line 1810, in
grid
if link(row):
  File "/home/watson/latte/web2py/applications/latte/controllers/
default.py", line 41, in 
links = [lambda row:
A('Edit',_href=URL("default","index",args=[row.id])),
  File "/home/watson/latte/web2py/gluon/dal.py", line 3948, in
__getattr__
return self[key]
  File "/home/watson/latte/web2py/gluon/dal.py", line 3939, in
__getitem__
return dict.__getitem__(self, key)
KeyError: 'id'


[web2py] Re: 'id' on 1.99.3 with SQLFORM.grid and links

2011-12-02 Thread David Watson
Thanks for your response.

On Dec 1, 1:20 pm, Anthony  wrote:
> Does your query/grid include the 'id' field?

Yes.

Did the same code used to work
> on 1.99.2?

No.


[web2py] Exception with couchdb on trunk ('Database' object has no attribute 'save')

2011-06-15 Thread David Watson
Hi All,

I finally got some time to begin working with couchdb on trunk again.
I'm working with:

web2py™ Version 1.96.4 (2011-06-14 14:30:00)
Python  Python 2.6.5: /usr/bin/python
Couchdb   Apache 0.10.0

on Ubuntu 10.04 LTS

I was blown away by how far the web interface on web2py has progressed
in 6 months. No time for sleeping!

Anyhow, I created an app with the wizard, all the plugins, and no
model but auth. When the wizard finished, couchdb showed the following
objects:

auth_permission
auth_membership
auth_user
auth_event
auth_group
auth_cas

each of which was 79 bytes and empty from what I could tell. So far so
good. Then it crashed with the following stack:

Traceback (most recent call last):
  File "/home/davidthewatson/tornado-couch-blog/web2py/gluon/
restricted.py", line 192, in restricted
exec ccode in environment
  File "/home/davidthewatson/tornado-couch-blog/web2py/applications/
lazyblog/models/db_wizard_populate.py", line 3, in 
populate(db.auth_user,10)
  File "/home/davidthewatson/tornado-couch-blog/web2py/gluon/contrib/
populate.py", line 155, in populate
table.insert(**record)
  File "/home/davidthewatson/tornado-couch-blog/web2py/gluon/dal.py",
line 4701, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/home/davidthewatson/tornado-couch-blog/web2py/gluon/dal.py",
line 3374, in insert
ctable.save(values)
AttributeError: 'Database' object has no attribute 'save'

This looks very similar to the exceptions I was seeing six months ago
where I presume that either the registration of the couchdb callbacks
isn't right or the calls shouldn't get made for couchdb.

Thanks,
Dave


[web2py] Re: mongoDBAdapter test ......

2011-06-21 Thread David Watson
Hi Joe,

That report is generated because the types dictionary for that key
doesn't have a value that encodes a template for the field.length to
be written into. If you look at the types at the top of the class,
you'll notice that some types do have a template value and some do
not.

Unfortunately, you shouldn't have even got that far. If you look
closely at the MongoDBAdapter and compare it to the CouchDB adapter,
you'll notice that the Mongo adapter is barely implemented, and in
fact, needs it's own specialization of the create_table method similar
to the couchdb adapter in order to function correctly, i.e. all that
SQL or DML stuff should not be happening for Mongo, because it doesn't
speak that dialect.

When I ran the couchdb adapter, it died in similar ways though I'm not
sure why, but I suspect that, again, there's a missing method that
should be marked "not implemented" which causes it to fail.
Unfortunately, it's difficult to find these issues without a rigorous
test suite and also, the design goals are difficult to interpret
because the schemaless DBs simply don't require a lot of the munging
that the relational ones do WRT to schema changes.

FWIW, I've been using auth as a test for these schemaless DB classes.
It would not be difficult to use that as an acid test (no pun
intended) and automate that such that if the app survives
initialization with auth turned on, you're at least through the C in
CRUD in terms of verifying that the functionality works.

I'm also a little concerned with the way these adapters are treating
UUIDs in terms of translating from legacy IDs back and forth under the
covers. We use UUIDs as ID fields even when we run PostgreSQL.

Part of the value proposition of the schemaless DBs is to eliminate
the problem of merging disparate relational database data into a
single global entity, i.e the data silo problem of the last 20 years
or so. UUIDs are a hard-stop requirement for that, and I'm not sure
that this kind of code is a good idea WRT preserving that kind of
functionality. See this article for more info:

http://en.wikipedia.org/wiki/U-form

Regards,
David

On May 5, 10:41 pm, joseph simpson  wrote:
> #!/usr/bin/python
> import sys
> import time
> sys.path.append('/Users/pcode/Desktop/mongodb_test/web2py')
> from gluon.dal import DAL, Field
>
> db = DAL('mongodb://127.0.0.1:5984/db')
> #mongodb test set
> #start with simple data types
> #then inser into mongodb
>
> db.define_table('m_test',
>         Field('name','text'),
>         Field('number','integer'))
>
> #
> # The above code produces the following error
> #
> Traceback (most recent call last):
>   File "./test_mdb_1.py", line 7, in 
>     db = DAL('mongodb://127.0.0.1:5984/db')
>   File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
> 3724, in __init__
>     raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
> (attempts, error)
> RuntimeError: Failure to connect, tried 5 times:
> 'MongoDBAdapter' object has no attribute '_uri'
>
> #
> ### Make the following changes
> #
> Line number 3342
> FROM:
>  m = re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)
> $').match(self._uri[10:])
> TO:
>  m = re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)
> $').match(self.uri[10:])
>
> Line number 3344
> FROM:
>  raise SyntaxError, "Invalid URI string in DAL: %s" % self._uri
> TO:
>  raise SyntaxError, "Invalid URI string in DAL: %s" % self.uri
> #
> ### Execute code again
> #
> ### New error listed below
> #
> Traceback (most recent call last):
>   File "./test_mdb_1.py", line 7, in 
>     db = DAL('mongodb://127.0.0.1:5984/db')
>   File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
> 3724, in __init__
>     raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
> (attempts, error)
> RuntimeError: Failure to connect, tried 5 times:
> port must be an instance of int
> #
> # Make the following change
> #
> Line 3351
> FROM:
>  port = m.group('port') or 27017
> TO:
>  port = 27017
> ### ##
> # Now the code connects to the server but the error below is
> reported
> ### 
> ###
> Traceback (most recent call last):
>   File "./test_mdb_1.py", line 14, in 
>     Field('number','integer'))
>   File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
> 4032, in define_table
>     polymodel=polymode

[web2py] 404 access denied problem with janrain on cube2py

2011-06-21 Thread David Watson
I uncommented and edited the janrain code on a freshly installed
version of cube2py with the latest web2py on ubuntu lucid. All four of
the logins work; however, all 3 but google fail after they get back to
cube2py as follows:

If I try to go here:

http://davidwatson.local/cube2py/plugin_wiki/page/home

I get 404 not found.

If I try to go here:

http://davidwatson.local/cube2py/plugin_wiki/

I get forwarded here:

http://davidwatson.local/cube2py/default/user/not_authorized

with:

Insufficient privileges
Not authorized
ACCESS DENIED

What's interesting is that in each of the 3 failing cases, the logout
and profile buttons show up and work, meaning that web2py clearly
realizes a successful login, which makes me wonder if the problem is
in cube2py.

Any ideas?

Thanks,
David