Honestly, I've read the forums extensively but I'm still a bit bewildered at how to best incorporate Drupal into a site built around a web app?

Here's a concrete example:

- Imagine I'm writing a simple widget counting app where logged in users can view and modify inventory, etc.
- The widget counter uses a RAD framework like Django (I'll probably end up having to use CakePHP, but I so would love to get a chance to use Django for the web app).
- I use drupal for the community aspect of the site.
- Users will now need a login that works across both Drupal and the widget counter, plus Drupal should ideally be seamlessly displayed on the pages (i.e. the main column is the app and the side column has drupal blocks).

How should this be done?

My ideas so far:

1) Widget app is written to use Drupal's auth scheme, hence logging into Drupal will log you into the widget counter. However, what will I need to add to the widget counter so that it can tell a user is logged in? Is it just to look out for drupal's session/cookie authorization, or will it the widget app have to access the Drupal DB? Also, now I have the problem of displaying Drupal content (navigation, forum headlines, etc) in the web app.

2) I write a wrapper/module to somehow incorporate the widget app inside Drupal. How on earth do I accomadate for the fact that the widget counter has its own MVC? I find it all a bit confusing: do I hack the widget counter to use Drupal's View? I've looked at Drake for CakePHP, but it seems a bit odd to force 404 errors, plus it really doesn't seem scale well. Plus, I really would like to write the widget counter in Python and there doesn't seem any realisitic way to incorporate Django into drupal.

It seems to me that option #1 is conceptually easier. It will take some grunt work to call drupal from the widget app though. There's a part of me that desperately wishes that much of Drupal's content would be output statically akin to Movable Type so that I can just include it in the web app and skin it.

I'm pretty sure that there is a solution out there for my problem, I just don't know which parts of Drupal to extend or hack in order to find a simple, working solution.

Comments

Anonymous’s picture

Well you've pretty much got your options there... If you're dealing with a 3rd party app, what I have done in the past is write a drupal module that writes username & password and other info to the 3rd party apps user database when a user logs in or is created, and then set a cookie in whatever format the 3rd party app uses. This is fairly simple but somewhat of a pain, and you get into all sorts of issues with logging in/out in the 3rd party app, syncing other user data, etc.

If you're writing from scratch, well, I would think it would be much better to use the drupal system. Your app would have to handle logins in the same way as drupal, and query the drupal session table to test authentication using the drupal cookie.

kavinay’s picture

Thanks for your reply. The drupal module sounds interesting and I may end up going down that route.

Regarding the second option, using the drupal system, would you happen to know of a good place to learn the details of how to go about querrying the session table? Is it just a matter of having to dig through the user module and mimmicking the SQL calls, or are there (hopefully) some notes or snippets out there to accelerate the process of porting drupal's auth to another app?

mariano.iglesias’s picture

You may want to try the new Drake :: Drupal-CakePHP bridge:

http://dev.sypad.com/projects/drake

Or its home right here on drupal:

http://drupal.org/project/drake

No need to modify Drupal nor CakePHP source code, no need to force 404, a standard Drupal module that lets you execute your CakePHP applications inside Drupal without source code modifications.

Enjoy!