Re: Am I missing something?
On Wed, Dec 4, 2013 at 6:04 AM, James Laver james.la...@gmail.com wrote: - :form-params uses string keys not keywords so it then needs to be keywordified before it’s suitable for passing to the database layer Which DB layer requires keywords? Not java.jdbc - it's perfectly happy with string keys. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
I happen to be working on the prototype for the caribou plugin layer right now (which may or may not be related to what you mean by pluggable). The default caribou template combines a number of libs that can in many cases be used independently of one another. We use ring and clojure.java.jdbc so other things using these tools are generally compatible with a caribou. Any elaboration on the choices we make that seem questionable is welcome. On Wednesday, December 4, 2013 2:53:12 AM UTC-8, James Laver wrote: On 4 Dec 2013, at 05:00, David Nolen dnolen...@gmail.com javascript: wrote: Did you look at Caribou? It seems more like a complete solution - http://let-caribou.in I’ve now given this a look over. It seems insane. It makes quite a lot of (IMO) questionable choices and it doesn’t seem terribly pluggable. James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
We had to tell Cheshire to always use bigdecimals - and I think there was something else, can't remember. Not all that advanced, really. On 4 Dec 2013 16:17, Brian Craft craft.br...@gmail.com wrote: On Tuesday, December 3, 2013 8:48:34 PM UTC-8, Korny wrote: * Compojure for routing, and static resources - the only middleware we had to write was for advanced json parsing What is advanced json parsing? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 3 Dec 2013 23:28, James Laver james.la...@gmail.com wrote: Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this It sounds like part of the issue is with ring.middleware.format overloading the :params key, but it also seems like you might have an unusual set of requirements. The custom middleware you describe sounds like one or two lines of code. Did you find it took particularly long to write? Others have mentioned Liberator, which I'd highly recommend using for RESTful web services. It gets rid of a lot of the boilerplate required, at least the parts that deal with HTTP. - James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 Dec 2013, at 09:06, James Reeves ja...@booleanknot.com wrote: It sounds like part of the issue is with ring.middleware.format overloading the :params key, but it also seems like you might have an unusual set of requirements. Actually, my larger problem was with compojure doing it. I wanted a distinction between data coming from the route and data coming from the form data, since after vaidation, that gets shoved straight into the database. The custom middleware you describe sounds like one or two lines of code. Did you find it took particularly long to write? Ring is really wonderfully simple. the two combined take up only a handful of lines. Unfortunately, the tests take up rather a lot of lines (~140) and since they helped squeeze out the bugs, it would be a poor argument to say “don’t write them”. See the source here https://gist.github.com/jjl/7785497 Others have mentioned Liberator, which I'd highly recommend using for RESTful web services. It gets rid of a lot of the boilerplate required, at least the parts that deal with HTTP. I think I’m going to have to look into it more fully. James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 Dec 2013, at 05:00, David Nolen dnolen.li...@gmail.com wrote: Did you look at Caribou? It seems more like a complete solution - http://let-caribou.in I’ve now given this a look over. It seems insane. It makes quite a lot of (IMO) questionable choices and it doesn’t seem terribly pluggable. James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On Wednesday, December 4, 2013 at 12:37, James Laver wrote: Ring is really wonderfully simple. the two combined take up only a handful of lines. Unfortunately, the tests take up rather a lot of lines (~140) and since they helped squeeze out the bugs, it would be a poor argument to say “don’t write them”. See the source here https://gist.github.com/jjl/7785497 Just a humble suggestion, but from a cursory glance at your tests, it seems that something like simple-check might save you a lot of time in the future: https://github.com/reiddraper/simple-check Cheers, Josh -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 Dec 2013, at 11:00, Joshua Ballanco jball...@gmail.com wrote: Just a humble suggestion, but from a cursory glance at your tests, it seems that something like simple-check might save you a lot of time in the future: https://github.com/reiddraper/simple-check That’s a much valued suggestion actually. I had been missing Haskell’s QuickCheck. Cheers, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 December 2013 10:37, James Laver james.la...@gmail.com wrote: On 4 Dec 2013, at 09:06, James Reeves ja...@booleanknot.com wrote: It sounds like part of the issue is with ring.middleware.format overloading the :params key, but it also seems like you might have an unusual set of requirements. Actually, my larger problem was with compojure doing it. I wanted a distinction between data coming from the route and data coming from the form data, since after vaidation, that gets shoved straight into the database. Compojure also adds to the :route-params key, so if you need to, you can explicitly decide how you want maps of parameters to be merged. The :params key is just there for the convenience of the majority of users. You could write something like: (POST /blah/:id [id :as {params :form-params}] ...) This would get the id from the routes (as they're always merged last), and the parameters map from :form-params. - James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 Dec 2013, at 11:38, James Reeves ja...@booleanknot.com wrote: Compojure also adds to the :route-params key, so if you need to, you can explicitly decide how you want maps of parameters to be merged. The :params key is just there for the convenience of the majority of users. You could write something like: (POST /blah/:id [id :as {params :form-params}] ...) This would get the id from the routes (as they're always merged last), and the parameters map from :form-params. Hi James, I’m pretty sure that’s the behaviour I was already seeing. Imagine this scenario: - I access this route passing in the ID of the database record I wish to modify - I pass in a new value for it in the post data (okay, bad example, you’re not likely to want to change an integer primary key, but bear with me) - I then need access to not only the value of the id from the params but also the value from the post data, separately - :form-params uses string keys not keywords so it then needs to be keywordified before it’s suitable for passing to the database layer (not to mention to make it significantly less of a pain to work with in userland code) I think it’s mostly the effect of trying to use all of the pieces together that’s causing me some pain. I’ve now worked around it with the middleware I previously posted, but it was a little surprising that I had to. Would you mind please explaining: a: how that syntax deals with merges? I don’t quite understand what’s going on underneath. Does that actually bind to params? b: how i could get those params extracted into a variable as well as access to the request map? Cheers, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On 4 December 2013 14:04, James Laver james.la...@gmail.com wrote: I’m pretty sure that’s the behaviour I was already seeing. Imagine this scenario: - I access this route passing in the ID of the database record I wish to modify - I pass in a new value for it in the post data (okay, bad example, you’re not likely to want to change an integer primary key, but bear with me) - I then need access to not only the value of the id from the params but also the value from the post data, separately - :form-params uses string keys not keywords so it then needs to be keywordified before it’s suitable for passing to the database layer (not to mention to make it significantly less of a pain to work with in userland code) Surely that's only a problem if you choose names for your route parameters that conflict with your form parameters? I think it’s mostly the effect of trying to use all of the pieces together that’s causing me some pain. I’ve now worked around it with the middleware I previously posted, but it was a little surprising that I had to. Would you mind please explaining: a: how that syntax deals with merges? I don’t quite understand what’s going on underneath. Does that actually bind to params? b: how i could get those params extracted into a variable as well as access to the request map? The code sample demonstrates using normal Clojure destructuring with Compojure's more specialised kind. I wasn't merging anything, I was just pulling out the form parameters and a parameter named id. This is covered in more detail in the Compojure wiki: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax - James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Am I missing something?
Hi all, I'm fairly new to clojure (a few months), but not new to lisp or indeed functional languages in general and I have around 10 years of experience programming dynamic languages in general. I've recently been using luminus to build a RESTful web API and I've been honestly surprised by how much code I've had to write to enable me to actually get things done while using it. I can't say I was expecting something full-stack like Django or Rails, but I wasn't expecting to have to write quite so much code to get simple things done. I've now spent around 14 hours building a RESTful web service that handles CRUD for a single database table because I've had to solve so many things I've come up against. What I'm actually wondering here is what I'm missing. Is it that the entire clojurian approach is here are the pieces, build a framework from them or is it just that I've had terrible luck with libraries? Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this 4. migratus seems to have the smallest note ever in the documentation informing you that version numbers must be 14 digits long (i was using 12 digits for a timestamp by not having the seconds listed). This seems like a really daft requirement in the first place. 5. every migrations library i've seen that doesn't work off raw SQL files is incapable of representing advanced features of my database of choice (postgresql) 6. lobos requires varchars to have a length limit applied (postgres does not) 7. the best way i've found of dealing with a database is korma. While korma does reduce some of the pain of SQL for standard things, it has limits and it doesn't save all that much pain. etc. So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? Thanks, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
CRUD against an SQL database is not imo the sweet spot for Clojure, at least not if you're comparing it against things like Rails or Django. With most of the NoSql stores out there, there's a Clojure client that let's you basically say, Here's a map, upsert it, which is essentially what you can say with Rails, Django, etc. (just replace map with class). So for the first 80% of cases of db access you long for that effortlessness you had with your ORM, but once you get a bit further down the line you don't get stuck in the muck of Vietnam on the last 20%. On Tuesday, December 3, 2013 3:26:53 PM UTC-8, James Laver wrote: Hi all, I'm fairly new to clojure (a few months), but not new to lisp or indeed functional languages in general and I have around 10 years of experience programming dynamic languages in general. I've recently been using luminus to build a RESTful web API and I've been honestly surprised by how much code I've had to write to enable me to actually get things done while using it. I can't say I was expecting something full-stack like Django or Rails, but I wasn't expecting to have to write quite so much code to get simple things done. I've now spent around 14 hours building a RESTful web service that handles CRUD for a single database table because I've had to solve so many things I've come up against. What I'm actually wondering here is what I'm missing. Is it that the entire clojurian approach is here are the pieces, build a framework from them or is it just that I've had terrible luck with libraries? Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this 4. migratus seems to have the smallest note ever in the documentation informing you that version numbers must be 14 digits long (i was using 12 digits for a timestamp by not having the seconds listed). This seems like a really daft requirement in the first place. 5. every migrations library i've seen that doesn't work off raw SQL files is incapable of representing advanced features of my database of choice (postgresql) 6. lobos requires varchars to have a length limit applied (postgres does not) 7. the best way i've found of dealing with a database is korma. While korma does reduce some of the pain of SQL for standard things, it has limits and it doesn't save all that much pain. etc. So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? Thanks, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
Take a look at Liberator, which is specifically designed for building REST APIs - but bear in mind the mindset of the Clojure community is generally to compose several libraries to create the specific solution you need, rather than having any full stack frameworks. That said, 14 hours to create a RESTful web service for CRUD for a single table seems excessive so I'd be curious exactly what you're trying to achieve and why you're finding it so laborious? Perhaps if you explain your requirements a bit more, we can offer better suggestions...? Sean On Tue, Dec 3, 2013 at 3:26 PM, James Laver james.la...@gmail.com wrote: Hi all, I'm fairly new to clojure (a few months), but not new to lisp or indeed functional languages in general and I have around 10 years of experience programming dynamic languages in general. I've recently been using luminus to build a RESTful web API and I've been honestly surprised by how much code I've had to write to enable me to actually get things done while using it. I can't say I was expecting something full-stack like Django or Rails, but I wasn't expecting to have to write quite so much code to get simple things done. I've now spent around 14 hours building a RESTful web service that handles CRUD for a single database table because I've had to solve so many things I've come up against. What I'm actually wondering here is what I'm missing. Is it that the entire clojurian approach is here are the pieces, build a framework from them or is it just that I've had terrible luck with libraries? Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this 4. migratus seems to have the smallest note ever in the documentation informing you that version numbers must be 14 digits long (i was using 12 digits for a timestamp by not having the seconds listed). This seems like a really daft requirement in the first place. 5. every migrations library i've seen that doesn't work off raw SQL files is incapable of representing advanced features of my database of choice (postgresql) 6. lobos requires varchars to have a length limit applied (postgres does not) 7. the best way i've found of dealing with a database is korma. While korma does reduce some of the pain of SQL for standard things, it has limits and it doesn't save all that much pain. etc. So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? Thanks, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
Hi Sean, On Wednesday, December 4, 2013 12:03:45 AM UTC, Sean Corfield wrote: Take a look at Liberator, which is specifically designed for building REST APIs I did have a quick look at liberator earlier but by that time i'd scratched most of my itch with compojure. I do intend to look into it in more depth though since there's a lot of application left to write. - but bear in mind the mindset of the Clojure community is generally to compose several libraries to create the specific solution you need, rather than having any full stack frameworks. The lisp mindset is rather why I came over to clojure, but I wasn't expecting to have to write quite so much code to get on with things. That said, 14 hours to create a RESTful web service for CRUD for a single table seems excessive so I'd be curious exactly what you're trying to achieve and why you're finding it so laborious? Perhaps if you explain your requirements a bit more, we can offer better suggestions...? I'm building a data management service for several other services to hang off. The basic problem is solves is to avoid having to either a) share the same database across multiple codebases (given that we may want to change the structure and then things get tedious) or b) keep several different databases (in which case welcome to synchronisation hell). Part of the 14 hours has been a learning curve for the libraries involved. I also seem to have spent rather too patching what I perceive to be holes where facilities should be in the libraries I'm using and in writing abstractions to avoid some of the tedium. I didn't really imagine I'd write two data structure handling libraries, two pieces of middleware and a validation layer atop korma just to be able to do a little bit of CRUD. I think I've been spoiled by the libraries available in other languages which seem to me to achieve a better balance between raw power and helping you to get things done more quickly (something I've found Perl achieves particularly well -- it errs on the side of power but the libraries seem more 'complete' if that makes sense). Oh, I did find one library that I liked a lot, timbre. James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On Tuesday, December 3, 2013 3:26:53 PM UTC-8, James Laver wrote: So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? It sounds like half of your problems are arising from DB migrations. IMO the existing libraries for doing this from Clojure are just not worth the bother. This is one place where I think you're better served just by writing your own functions; it can be done cleanly with very few lines of code and doesn't have to tie you into any crazy db-agnostic abstractions that hide the details of Postgres: https://github.com/technomancy/syme/blob/master/src/syme/db.clj#L68 -Phil -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On Tue, Dec 3, 2013 at 4:20 PM, James Laver james.la...@gmail.com wrote: I did have a quick look at liberator earlier but by that time i'd scratched most of my itch with compojure. I do intend to look into it in more depth though since there's a lot of application left to write. Yes, there's a lot of detail in REST behavior and Liberator captures all of that. The lisp mindset is rather why I came over to clojure, but I wasn't expecting to have to write quite so much code to get on with things. I'm curious how this experience would have fared in Lisp? (I haven't done any serious work in Lisp - and haven't used any Lisp systems much since the mid-80's - so I don't know what sort of web and DB libraries exist out there for Lisp) Part of the 14 hours has been a learning curve for the libraries involved. Ah, yes, understandable. As Phil says, rolling your own migrations, native to Postgres, is probably the best way to go in that area. At World Singles, we use external SQL files with a prefix indicating DB level and an indicator of dev vs prod migration, and a small Clojure script that figures out what needs applying. That's partly because we started out with SQL files - sometimes provided by DBAs - before we introduced Clojure to the project. Like Phil, I tend to prefer to avoid SQL abstractions, unless I specifically need the ability to compose fragments of SQL, so I tend to work directly with java.jdbc with just a few helpers built on top of it (find-by-keys, get-by-id, delete-by-id). I ported my own simple, convention-based MVC framework to Clojure (from CFML) and it's based on Ring and I just tend to go with the flow as far as the standard middleware is concerned. That framework has simple render-json etc functions for returning JSON or XML or whatever as a REST response, and controllers are simple functions (operating on a simple map of parameters) and views - if returning HTML rather than just data - are Selmer templates (Django style). -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
My 2c on this : We are doing similar things at my current client - with less pain. I suspect you've been unlucky in your choice of libraries, and maybe expecting more than you get in clojure's ecosystem - ruby, python etc have been around a lot longer, and with a lot more focus on database use. We use : * Liberator for REST - it's pretty great, though we had to add some custom exception handling * Compojure for routing, and static resources - the only middleware we had to write was for advanced json parsing * Flyway for migrations - there's a Clojure wrapper, but we had to customise it a fair bit. This uses raw sql migrations, but I *like* that. * Korma for sql, though our database was fairly simple, and we talked about moving to an alternative like honey sql - I'm not a big fan of Korma myself. * custom validation - we probably should have looked harder at existing libraries, but ended up rolling our own validation. - Korny On 4 Dec 2013 10:29, James Laver james.la...@gmail.com wrote: Hi all, I'm fairly new to clojure (a few months), but not new to lisp or indeed functional languages in general and I have around 10 years of experience programming dynamic languages in general. I've recently been using luminus to build a RESTful web API and I've been honestly surprised by how much code I've had to write to enable me to actually get things done while using it. I can't say I was expecting something full-stack like Django or Rails, but I wasn't expecting to have to write quite so much code to get simple things done. I've now spent around 14 hours building a RESTful web service that handles CRUD for a single database table because I've had to solve so many things I've come up against. What I'm actually wondering here is what I'm missing. Is it that the entire clojurian approach is here are the pieces, build a framework from them or is it just that I've had terrible luck with libraries? Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this 4. migratus seems to have the smallest note ever in the documentation informing you that version numbers must be 14 digits long (i was using 12 digits for a timestamp by not having the seconds listed). This seems like a really daft requirement in the first place. 5. every migrations library i've seen that doesn't work off raw SQL files is incapable of representing advanced features of my database of choice (postgresql) 6. lobos requires varchars to have a length limit applied (postgres does not) 7. the best way i've found of dealing with a database is korma. While korma does reduce some of the pain of SQL for standard things, it has limits and it doesn't save all that much pain. etc. So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? Thanks, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
Did you look at Caribou? It seems more like a complete solution - http://let-caribou.in David On Tue, Dec 3, 2013 at 6:26 PM, James Laver james.la...@gmail.com wrote: Hi all, I'm fairly new to clojure (a few months), but not new to lisp or indeed functional languages in general and I have around 10 years of experience programming dynamic languages in general. I've recently been using luminus to build a RESTful web API and I've been honestly surprised by how much code I've had to write to enable me to actually get things done while using it. I can't say I was expecting something full-stack like Django or Rails, but I wasn't expecting to have to write quite so much code to get simple things done. I've now spent around 14 hours building a RESTful web service that handles CRUD for a single database table because I've had to solve so many things I've come up against. What I'm actually wondering here is what I'm missing. Is it that the entire clojurian approach is here are the pieces, build a framework from them or is it just that I've had terrible luck with libraries? Some examples: 1. The :params key is used by ring.middleware.params, compojure and ring.middleware.format so it's impossible to know where a given param is coming from 2. ring.middleware.params does not provide a convenience map that merges :query-params and :form-params, despite being happy to stuff everything into :params. At least ring.middleware.format adds :body-params here. I've now written a middleware to do this. 3. ring.middleware.keyword-params only keywordises the :params map, not the other maps. There is no configurable behaviour to ask it to do other maps. I've now written a middleware for this 4. migratus seems to have the smallest note ever in the documentation informing you that version numbers must be 14 digits long (i was using 12 digits for a timestamp by not having the seconds listed). This seems like a really daft requirement in the first place. 5. every migrations library i've seen that doesn't work off raw SQL files is incapable of representing advanced features of my database of choice (postgresql) 6. lobos requires varchars to have a length limit applied (postgres does not) 7. the best way i've found of dealing with a database is korma. While korma does reduce some of the pain of SQL for standard things, it has limits and it doesn't save all that much pain. etc. So, am I missing something? Are there any libraries people can recommend that will make my life easier? Am I just looking at this in completely the wrong way? Thanks, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On Wed, Dec 4, 2013 at 7:00 AM, Sean Corfield seancorfi...@gmail.comwrote: As Phil says, rolling your own migrations, native to Postgres, is probably the best way to go in that area. At World Singles, we use external SQL files with a prefix indicating DB level and an indicator of dev vs prod migration, and a small Clojure script that figures out what needs applying. That's partly because we started out with SQL files - sometimes provided by DBAs - before we introduced Clojure to the project. Slightly OT, has anyone used http://sqitch.org/ for the same purpose and found it useful? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
On Tuesday, December 3, 2013 8:48:34 PM UTC-8, Korny wrote: * Compojure for routing, and static resources - the only middleware we had to write was for advanced json parsing What is advanced json parsing? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
Ah! And you just missed the survey. ;-) On Tuesday, December 3, 2013 4:20:52 PM UTC-8, James Laver wrote: Part of the 14 hours has been a learning curve for the libraries involved. I also seem to have spent rather too patching what I perceive to be holes where facilities should be in the libraries I'm using and in writing abstractions to avoid some of the tedium. I didn't really imagine I'd write two data structure handling libraries, two pieces of middleware and a validation layer atop korma just to be able to do a little bit of CRUD. I think I've been spoiled by the libraries available in other languages which seem to me to achieve a better balance between raw power and helping you to get things done more quickly (something I've found Perl achieves particularly well -- it errs on the side of power but the libraries seem more 'complete' if that makes sense). -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Am I missing something?
I dislike all the migration libraries, because they all make migrations super complex for what I usually want to do. Wrote my own based of some code Phil Hagelberg pointed me to months ago: https://github.com/runa-dev/kits/blob/master/src/kits/db_migrator.clj On Tue, Dec 3, 2013 at 9:21 PM, Brian Craft craft.br...@gmail.com wrote: Ah! And you just missed the survey. ;-) On Tuesday, December 3, 2013 4:20:52 PM UTC-8, James Laver wrote: Part of the 14 hours has been a learning curve for the libraries involved. I also seem to have spent rather too patching what I perceive to be holes where facilities should be in the libraries I'm using and in writing abstractions to avoid some of the tedium. I didn't really imagine I'd write two data structure handling libraries, two pieces of middleware and a validation layer atop korma just to be able to do a little bit of CRUD. I think I've been spoiled by the libraries available in other languages which seem to me to achieve a better balance between raw power and helping you to get things done more quickly (something I've found Perl achieves particularly well -- it errs on the side of power but the libraries seem more 'complete' if that makes sense). -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.