First time here? Check out the FAQ!
6

How to use askbot as a pluggable django app?

I have seen mentioned in a few places that it shouldn't be too much work to integrate askbot into an existing django-based project (e.g., see here), however I haven't been able to find a comprehensive answer to how feasible that is. Has anyone actually done this? What needs to happen to make it work?

There are three ways to do integration: either as a pluggable app as part of the main site, as a separate site backed by the same DB using the django sites framework, or as "multiple Django instances hosting different parts of your URL space, allowing them to have multiple settings files." (That last option came from here, though I'll admit I'm not exactly sure how this would work in practice)

All thses options have a few obvious issues:

  • Does askbot still monkey-patch the django user model? I haven't found where that actually happens in the askbot source. What would be needed to clean that up? What else is being monkey patched? Is all of this black-magic contained in the askbot/patches directory?
  • What to do with existing users? OSQA's answer to this question isn't very encouraging: "OSQA is not meant to follow the philosophy of reusable django apps" -- I'm hoping askbot is a bit better in this regard. Is just running "add_missing_subscriptions" sufficient?
  • Beyond creating the User entries, what happens when a user is registered? Is it possible to use an external django user registration system? (ie can the process of migrating existing users happen continuously for new signups?) Obviously this is a bit different depending on whether askbot is installed as an app within the larger project or just backed by the same DB, since in the former case, it should be pretty easy to use signals to do any needed updates. In the multi-project configuration, some sort of (probably ugly) rpc layer might have to be used.
  • Is there any problem using Django 1.3? (Could askbot be coerced into using the static files framework?)
  • Are there any other standard Django best-practices that askbot doesn't follow, which I should be aware of?

Hmmm...that ended up being pretty long. And I'm sure there are a few other gotchas that I'm missing :P

Anyways, we've been pretty impressed after playing a bit with our standalone test deployment of Askbot, so I'm excited to get it integrated with the rest of our project. I do have some django development experience, so if there is a bit of work to do on askbot's core in order to make it more easily pluggable, I'm certainly willing to contribute, but before I sink too much time going down that path, I'd like to get some idea of the scope of the problems to be overcome.

Thanks!

Gabriel's avatar
63
Gabriel
asked 2011-05-27 01:09:29 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

5 Answers

2

I agree working away from the forced bundled authentication / User model stuff should be prioritized. Having a truly pluggable Q&A app would be a real differentiator from OSQA. It would also be nice if you could supply your own Tag model and be able to use the same Tag model across other Django apps, along with django-taggit/tagging.

Andrew Swihart's avatar
21
Andrew Swihart
answered 2011-05-28 09:47:24 -0500
edit flag offensive 0 remove flag delete link

Comments

Probably authentication #1 it is also simpler to do. The main thing to disconnect there is "post before login", on login the pending post is published. Also login system that comes with askbot takes some data from anonymous session to the logged in session upon login. Maybe the latter is not so important, but "post first then login" feature is useful. It would be nice to have that feature implemented without an extra query to the "anonymous post" table on every page hit. I will be away until Tuesday morning, won't be able to help before then.
Evgeny's avatar Evgeny (2011-05-28 10:06:23 -0500) edit
I'll work on decoupling login next week, should be simple. Also I typically merge others contributions on github, sometimes with some of my own modifications though. With tags I agree too, but I want to avoid using generic relations.
Evgeny's avatar Evgeny (2011-05-28 10:21:52 -0500) edit
2
Agree on this one: "Having a truly pluggable Q&A app would be a real differentiator from OSQA"
DealsVistaCom's avatar DealsVistaCom (2011-05-29 00:45:11 -0500) edit
authentication support is done.
Evgeny's avatar Evgeny (2011-06-05 15:09:01 -0500) edit
add a comment see more comments
2

Reusable app is the goal with an option to use askbot as a whole package.

Changed June 5 2011 Starting version 0.6.93 (available on github and pypi) askbot fully supports external authentication/user registration apps, all documentation on the subject will be here:

http://askbot.org/doc/askbot-as-reusable-django-application.html

The remaining gotcha at the moment is that auth.models.User model, it is monkeypatched with add_to_class (in models/__init__.py) calls and migrations. As long as your other apps do not use the same extra fields, there should'n be problems. It is not very nice, but I have not yet heard from anyone that it prevented askbot from working with other apps.

Probably the right way is to have a separate model for askbot user profile data, something like AskbotUser linked with the auth.models.User.

Directory patches contains monkeypatches that "upgrade" some parts of Django to the level of 1.3. Askbot will (at least was tested at one point not too long ago) work with Django 1.1 to 1.3 without changes. For example - csrf protection will work on 1.1 even though it is not present in django 1.1.

Jinja2 templates are used for speed and more flexibility in programming.

Also I plan to use Google Closure for javascript, jquery will be gradually phased out (by gradually I mean - very gently - without breaking anything or shocking anyone. :)

I'll come back to your question tomorrow.

Evgeny's avatar
13.2k
Evgeny
updated 2011-06-05 23:11:12 -0500, answered 2011-05-27 04:10:09 -0500
edit flag offensive 0 remove flag delete link

Comments

Why the move to google closure from jquery? (Just curious, I only have experience in jquery so far).
arknotts's avatar arknotts (2011-05-27 14:31:13 -0500) edit
It is possible to do a lot more with closure (for example GMail and Google Documents, also this demo: http://chemwriter.com), there are docs for the library, take a look for more details. I understand that jQuery is a de-facto mainstream javascript tool, but closure compiler and the library offer a lot more.
Evgeny's avatar Evgeny (2011-05-27 17:27:40 -0500) edit
@arknotts regarging jquery vs closure, I did not mean than new jquery code won't be accepted in askbot, just that I myself will try to switch to Closure. The transition will take some time and won't break anything. Just wanted to clarify.
Evgeny's avatar Evgeny (2011-06-05 22:08:56 -0500) edit
@Evgeny Sure I understand. I took a look at google closure and it seems pretty cool!
arknotts's avatar arknotts (2011-06-07 20:22:42 -0500) edit
add a comment see more comments
1

Hi managed to install askbot as a pluggable django app, but I have some two probles:

  1. I had to create, under my project directory, a virtual link to skins folder

  2. despite I tell askbot to put the uploaded file into the directory /myproject/upfile, askbot continue to put the uploaded file into directory /myproject/askbot/upfile.

Regards,

Fabio

Fabio's avatar
48
Fabio
answered 2011-06-21 17:15:04 -0500
edit flag offensive 0 remove flag delete link

Comments

Hi Fabio, thanks, I got your message yesterday, sorry for not responding. Do you have a custom skin in some other directory? This part I did not quite understand.
Evgeny's avatar Evgeny (2011-06-21 17:31:28 -0500) edit
add a comment see more comments
0

No, as far I know I don't have any custom skin.

Fabio's avatar
48
Fabio
answered 2011-06-22 08:28:25 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

If I wanted to integrate some other django app with askbot, I would first try to put both in the same project.

For example, make a copy of your project including the database, then add askbot directory to the project and splice files urls.py and settings.py. Backing up the database will be very important here.

Askbot's sample project files are in the directory askbot/setup_templates.

Finally, run migrations (there are two apps to migrate for askbot - just run python manage.py migrate. All the extra fields on the user model will be added by askbot's migrations.

On the migrations - PostgresQL will help here. If a migration fails - a transaction will roll back to the previous successful migration and you will not end up in the middle of a failed one. With MySQL you might, then you'd have to clean the database manually or start over.

The add_missing_subscriptions command will fill the holes in the data of pre-existing users.

There is also a management command add_askbot_user which might help creating new user accounts in the case you prefer to stick to your existing user registration system. The management command can be called programmatically via django.core.management.call_command

Where you might have difficulties - askbot uses internal login app and registration app (will be decoupled soon), and there are some middlewares that may get in the way of other apps. Please let us know of such issues.

Evgeny's avatar
13.2k
Evgeny
updated 2011-05-28 06:07:18 -0500, answered 2011-05-28 06:01:48 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments