Closed tomiles closed 14 years ago
It says that CouchDB returned 500 response, instead of 200 or 201. Try doing this using another software. Like embedded CouchDB client. Maybe the problem is in version compatibility.
Speaking about embedded sessions... What data do you store in CouchDB? Is it just a few kb? Then you don't need a store at all. With embedded sessions cookies are signed in order to be sure that they weren't changed when your app last edited it. It is much faster since you don't need a separate request and is a lot easier to use.
I store extended information about a dynamic javascript page, so that on page refresh some of the dynamic stuff can be reload from the session data and the state of the page can be restored. My CouchDB server is working fine I can put and get info from the DB with other client, so it must be an issue with the PUT data that Couchdb.pm sends.
Why don't you use then JavaScript CouchDB clients?
Could you show me how you use MojoX::Session so I can replicate the bug?
Ok i put in some croaks so I could take a look at the data it send to couchdb. And there is the issue it sends: { "logged_in": "false", "expires": 1274120830, "__ip_match": "127.0.0.1" }
but in CouchDB __ip_match is not allowed, because names starting with underscores are not allowed in the root level of a document that is reserved for internal variables like _rev, _id ... So a fix would be to save __ip_match inside another level like:
{
"logged_in": "false",
"expires": 1274120830,
"data": { "__ip_match": "127.0.0.1"}
}
I use Javascript Couchdb client but the Mojo scripts also need access to the session data because the html page state has to be coupled to the session of the current user.
Ah, that's a very interesting bug :) That was a temporary idea to hide private data from a user.
Underscore names at root level have always been reserved in couch but it could be that it didn't show up earlier if you used and older couchdb version, because a few versions back couchdb didn't enforce the underscore rule, but it does now.
Will there be a new cpan release with a fix for this? or should I just uninstall the cpan module and use a patched version on my local server myself?
Do you think it is a good idea to replace __ip_address with mojox.session.ip_address?
as far as I know it's only couchdb that is having issues with the underscores so you could just change: $data = $self->_encode_json({%$data, expires => $expires}); to $data = $self->_encode_json({data => %$data, expires => $expires}); in the couchdb load and create methods and then adapt the load method so it again puts everything under 'data =>' at the same level in the $body that is returned.
mojox.session.ip_address will be a pain in perl because of the special meaning of points in perl, when the json encoding is translated to perl variables/hash.
I've updated git version. Could you try it and report the results? If everything is ok I will release it on CPAN.
Thanks
Just gave it a go and the couchdb stuff seems to work fine now. Thanks for the fix
Fixed in latest github source and MojoX-Session-0.20 on CPAN. Closing the issue.
I know that you won't improve it or extend. But can't get the couchdb store to work I always get:
and in my couchdb log I see the put request that creates the session document return a 500 error but I don't know why.
Could you help? and if not, do you know how I could use couchdb with the embedded Mojolicious sessions instead?