Re: [TurboGears] TurboGears2 and Java

12 views
Skip to first unread message
Message has been deleted

Michael Pedersen

unread,
Nov 7, 2015, 12:50:05 AM11/7/15
to TurboGears
Good evening.

This is a super open ended question, so the answer to it is very difficult. The sarcastic answers are "yes" and "when you identify the need" and "using Python for the parts Python is good at, and Java for the parts Java is good at".

The not sarcastic answers, though: Yes, there are are times when you will be using TurboGears and interacting with something from the Java world. As to when, it will almost never be with code from one language calling code from another language directly (if you've got that, you're using Jython, and unlikely to be using TurboGears). Instead, you will be dealing with well documented interfaces, usually via some socket based protocol (with http being the most common, via a REST API). If you're dealing with a REST API, then it doesn't matter if you've got Java running the backend. Use the requests module (see http://docs.python-requests.org/en/latest/ ), and the rest is simply implementation details.

If you're dealing with something else, you're still likely dealing with a network connection. On the front end, TG will be responding to HTTP requests from users, and getting some data from a backend server that happens to be written in Java, using some network protocol. If you're lucky, it's a common network connection (http, ftp, some database) and the modules to communicate are already written. If you're unlucky, you might have to roll your own (in which case, you're likely starting with the standard Python sockets module, and I don't envy you).

Outside of that, if you're trying to directly call some Java class from your Python code, you're probably using Jython, and I'm not even certain that TG2 *can* run on Jython.

Really, when asking this sort of question, we would need more details to provide any usable answers. What exactly are you trying to accomplish? What are the options we're allowed to provide (for instance, can we recommend a rewrite of the other side in Python? Can we recommend not using TG to accomplish your goals?)?

I hope this answer helps out a little bit, at least.

On Fri, Nov 6, 2015 at 8:40 PM Robert James Liguori <glies...@gmail.com> wrote:
Are there any use cases where TurboGears2 can or should be integrated with Java?  If so when and how?

Thanks!

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Martin Eliasson

unread,
Nov 8, 2015, 4:07:19 PM11/8/15
to turbogears
As Michael says, you integrate using REST between Java and Python if TurboGears are involved. If you don't have a problem to solve that is matching a REST based design, you probably shouldn't use TurboGears in the first place anyway.

/Martin

--
Martin Eliasson
+46 (0) 739 97 87 33
http://asplunden.org
Reply all
Reply to author
Forward
0 new messages