[ANN] appengine-magic 0.4.1: Clojure on Google App Engine

61 views
Skip to first unread message

Constantine Vetoshev

unread,
Apr 3, 2011, 8:26:49 PM4/3/11
to clojure...@googlegroups.com
I would like to announce the release of appengine-magic version 0.4.1,
a library designed to make it easier to write Clojure applications for
Google App Engine.

Version 0.4.1 is a minor update to 0.4.0, and contains basic support
for the just-released App Engine 1.4.3 SDK.

https://github.com/gcv/appengine-magic

Future versions of appengine-magic will contain full support for new
features of App Engine, including the Files API, the Deferred API, and
the Remote API. (Patches welcome!)

Thanks,
Constantine Vetoshev

László Török

unread,
Apr 4, 2011, 3:24:21 AM4/4/11
to clojure...@googlegroups.com
Hi,

I've started playing with appengine-magic. Looks good so far.

I wonder if there is a way to automatically include wrap-stacktrace and wrap-reload middlewares when runnning the app in the developer sandbox. This would make restart/reload after every single change unnecessary.

Has anybody tried this? If not, I'm happy to send a patch.

Another issue I've been facing: I'm using enclojure for coding, but I can't use the enclojure IDE for coding unless I move appengine-magic from the dev-dependencies to depenpencies. Has anybody have a suggestion how to work around this other than patching enclojure to add the /lib/dev/ directory content to the classpath?

Thanks,

Las

2011/4/4 Constantine Vetoshev <gepa...@gmail.com>

Constantine Vetoshev

unread,
Apr 4, 2011, 12:07:33 PM4/4/11
to clojure...@googlegroups.com
On Mon, Apr 4, 2011 at 12:24 AM, László Török <ltor...@gmail.com> wrote:
> I've started playing with appengine-magic. Looks good so far.
> I wonder if there is a way to automatically include wrap-stacktrace and
> wrap-reload middlewares when runnning the app in the developer sandbox. This
> would make restart/reload after every single change unnecessary.

appengine-magic is primarily optimized for running in interactive REPL
mode, where you just recompile changed functions and see the results
immediately. The appengine-magic.core/serve function is specifically
there for that purpose; you should rarely have to restart anything.

In my understanding, Enclojure supports interactive REPL development
(correct me if I'm wrong). Just start a project, code up some
functions, wire them to the Ring response, and recompile them. There
is no need for wrap-reload middleware.

I don't recommend using dev_appserver.sh. It's supported in
appengine-magic, but I don't think it's useful, except maybe for a
quick test of the bundled final jars before production deployment.

As for wrap-stacktrace, I'm reluctant to include a dependency on it by
default in the library. It's easy enough to include in your
application's definition. In Compojure, it would look something like:

(def my-app-handler
(-> #'my-app-routes
ring/wrap-stacktrace))

(ae/def-appengine-app my-app #'my-app-handler)

That way, if you want to use a custom replacement for wrap-stacktrace,
you can do so (I actually do this in my apps), whereas including it by
default will force it on everyone.

By the way, you can recompile my-app-handler on the fly, too.

> Another issue I've been facing: I'm using enclojure for coding, but I can't
> use the enclojure IDE for coding unless I move appengine-magic from the
> dev-dependencies to depenpencies. Has anybody have a suggestion how to work
> around this other than patching enclojure to add the /lib/dev/ directory
> content to the classpath?

You mean Enclojure doesn't let you customize the project's classpath?

Vincent Liard

unread,
Apr 4, 2011, 4:26:22 AM4/4/11
to clojure...@googlegroups.com
Hi Constantine,

At Sun, 3 Apr 2011 17:26:49 -0700,


Constantine Vetoshev wrote:
>
> I would like to announce the release of appengine-magic version 0.4.1,
> a library designed to make it easier to write Clojure applications for
> Google App Engine.

Thanks for that, appengine-magic looks great.

I'm trying appengine-magic out, following the Getting Started
(https://github.com/gcv/appengine-magic#readme) but when I get to
"lein appengine-prepare", I receive the following error:

Exception in thread "main" java.io.FileNotFoundException: Could not locate lancet/core__init.class or lancet/core.clj on classpath: (appengine_prepare.clj:1)
[...]
Caused by: java.io.FileNotFoundException: Could not locate lancet/core__init.class or lancet/core.clj on classpath:
[...]

I'm very likely to be missing something but I can't find what. As far
as I can judge, I've followed your Getting Started strictly... Do I
need to set the classpath myself? Any idea why I fail there?

Thanks!

Vincent

László Török

unread,
Apr 4, 2011, 3:20:37 PM4/4/11
to clojure...@googlegroups.com
Hi,

see my reply inline

appengine-magic is primarily optimized for running in interactive REPL
mode, where you just recompile changed functions and see the results
immediately. The appengine-magic.core/serve function is specifically
there for that purpose; you should rarely have to restart anything.

That's fine. However, whenever I change a .clj file, I need to run (require '...) in the REPL to make those changes available to the running app.
With lein-ring [1], modified source files and all dependent namespaces where automatically loaded on each request which made the changes instantly available without manual reload.
However, I realized, it may not work as that middleware uses blacklisted classes.

In my understanding, Enclojure supports interactive REPL development
(correct me if I'm wrong). Just start a project, code up some
functions, wire them to the Ring response, and recompile them. There
is no need for wrap-reload middleware.

Sure, but see my comment above.

 
I don't recommend using dev_appserver.sh. It's supported in
appengine-magic, but I don't think it's useful, except maybe for a
quick test of the bundled final jars before production deployment.
I don't quite understand what do you mean by not using dev_appserver.sh.
I use (ae/serve) which I thought is about the same thing, it gives you an emulated GAE environment.
 
> Another issue I've been facing: I'm using enclojure for coding, but I can't
> use the enclojure IDE for coding unless I move appengine-magic from the
> dev-dependencies to depenpencies. Has anybody have a suggestion how to work
> around this other than patching enclojure to add the /lib/dev/ directory
> content to the classpath?

You mean Enclojure doesn't let you customize the project's classpath?
The managed REPL that can be started with 2 clicks relies on the maven dependencies.
lein pom does not include the dev-dependencies, but I now created an alternative task that does. [2]

 Thanks,

Las

 [1] https://github.com/weavejester/lein-ring
 [2] http://clojars.org/lein-pom-dev

Constantine Vetoshev

unread,
Apr 4, 2011, 3:53:03 PM4/4/11
to clojure...@googlegroups.com
On Mon, Apr 4, 2011 at 1:26 AM, Vincent Liard <vincen...@free.fr> wrote:
> I'm trying appengine-magic out, following the Getting Started
> (https://github.com/gcv/appengine-magic#readme) but when I get to
> "lein appengine-prepare", I receive the following error:
>
> Exception in thread "main" java.io.FileNotFoundException: Could not locate lancet/core__init.class or lancet/core.clj on classpath:  (appengine_prepare.clj:1)
> [...]
> Caused by: java.io.FileNotFoundException: Could not locate lancet/core__init.class or lancet/core.clj on classpath:
> [...]

It looks like you have an older version of Leiningen installed. Try
upgrading (to 1.5.0) with "lein upgrade".

Constantine Vetoshev

unread,
Apr 4, 2011, 4:12:41 PM4/4/11
to clojure...@googlegroups.com
On Mon, Apr 4, 2011 at 12:20 PM, László Török <ltor...@gmail.com> wrote:
> That's fine. However, whenever I change a .clj file, I need to run (require
> '...) in the REPL to make those changes available to the running app.
> With lein-ring [1], modified source files and all dependent namespaces where
> automatically loaded on each request which made the changes instantly
> available without manual reload.

I don't recommend using the (require ...) workflow to make changes
available to the app. Since Clojure is a Lisp, I suggest working with
s-expressions. In other words, don't reload files, just recompile the
functions which you changed.

In Emacs and SLIME, I just hit C-c C-c, and my current top-level
definition, usually a defn form, is recompiled in the running image. I
don't use Enclojure, but the screenshots suggest that it supports this
concept: http://www.enclojure.org/Clojure+Code+Editor+-+REPL+Integration
— it has an "Evaluate Expression" option, which sounds like it does
the right thing. You should not have to use a (require ...) form after
every change.

> I don't quite understand what do you mean by not using dev_appserver.sh.
> I use (ae/serve) which I thought is about the same thing, it gives you an
> emulated GAE environment.

Not exactly. From the Google SDK's point of view, dev_appserver.sh and
ae/serve run the same code. However, ae/serve enables interactive
development. When you use dev_appserver.sh, you're no better off than
using straight Java, with its inefficient
edit-compile-package-deploy-restart workflow; i.e., you can't attach a
live REPL to the JVM. When you use ae/serve, you can take advantage of
Clojure's Lisp-style workflow.

In early versions of appengine-magic, dev_appserver.sh also gave you
access to /_ah/admin. As of version 0.4.0, ae/serve gives you the same
features, so I do not recommend dev_appserver.sh for development.

> The managed REPL that can be started with 2 clicks relies on the maven
> dependencies.
> lein pom does not include the dev-dependencies, but I now created an
> alternative task that does. [2]

That looks pretty useful for Maven-only tools. Have you considered
discussing this on the Leiningen mailing list?

Vincent Liard

unread,
Apr 4, 2011, 4:29:16 PM4/4/11
to clojure...@googlegroups.com
At Mon, 4 Apr 2011 12:53:03 -0700,

You were right, thank you very much. I'm new to clojure and this was
driving me crazy! Now I can start :)

Vincent

László Török

unread,
Apr 5, 2011, 2:26:36 AM4/5/11
to clojure...@googlegroups.com
Hi,

In Emacs and SLIME, I just hit C-c C-c, and my current top-level
definition, usually a defn form, is recompiled in the running image. I
don't use Enclojure, but the screenshots suggest that it supports this
concept: http://www.enclojure.org/Clojure+Code+Editor+-+REPL+Integration
— it has an "Evaluate Expression" option, which sounds like it does
the right thing. You should not have to use a (require ...) form after
every change.
Good point, I've never considered this option before, thanks. I've tried Emacs multiple times, but it is just not geared toward my mind.
I prefer to have more visual feedback from an editor and more intuitive (even if inefficient) alternatives to be able to do work, before I learn the 100+ shortcut keys, which I am sure will be the ultimate way to use it.
 
> The managed REPL that can be started with 2 clicks relies on the maven
> dependencies.
> lein pom does not include the dev-dependencies, but I now created an
> alternative task that does. [2]


That looks pretty useful for Maven-only tools. Have you considered
discussing this on the Leiningen mailing list?
Not really, as most of the times it makes no sense to include dev-dependencies into the POM file.

Anyway, I hope I could help out at some point with ae-magic.

Las

Reply all
Reply to author
Forward
0 new messages