Hi, just want to know anyone succeeded in integrating osqa with an existing django project(django version 1.2.3)

the steps I've tried with are:

1) get the latest svn trunk, with is r611 into a new directory
2) edit settings_local.py to point the database settings to the existing project database
3) since I have no need for facebook and twitter login, I also modified the DISABLED_MODULES field


DISABLED_MODULES = ['books', 'recaptcha', 'facebookauth', 'oauthauth', 'openidauth', 'project_badges']
 
4) run python manage.py runserver

Following these steps, however, I can't log in with an existing user.

I did some investigation on the source, it turns out there're two problems: 1) within forum_modules/localauth/forms.py


        try:
            self.user_cache = user_.user    (line:81)
        except:
            error_list.append(_('This user is not a valid user'))
 

here the user_ is actually the result of calling


user_ = authenticate(username=username, password=password)   (line:69)

which is an django.contrib.auth.User instance and has no attribute user

2) after fixing the aforementioned problem by changing line 81 to

 self.user_cache = user_    (line:81) 
I still got problems by process_provider_signin in forum/views/auth.py based on following logic, it seems to me assoc_key is expected to be an forum.User object, but since


assoc_key = provider_class.process_authentication_request(request)     (line:102)

it's an django.contrib.auth.User and can't pass following tests and the authentication eventually failed.

My guess is somewhere within localauth we need to do sth to wrap up a django user into an osqa user, and at the same time store it to the database if it doesn't previously exists.

Any comments?

asked 10 Nov '10, 07:20

cheka's gravatar image

cheka
16113
accept rate: 0%

edited 10 Nov '10, 07:30


This question has become old. But here it goes. OSQA is not meant to be integrated with other django apps. Anyway, that integration is not that hard, and you don't need to mess with that code, there is no problem with it, actually has almost zero relation with your problem. Here's a couple of followup questions: How are you planning on do the integration? Which app will be in charge of the registration process and all that stuff? Do you already have an existing user base, or you're just testing?

link

answered 10 Nov '10, 10:57

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

I did actually check some relevant questions before posting my own but unfortunately they didn't help me much.

I still think there's some issue within forum_modules/localauth/forms.py, as the user_ is the direct result of calling django.contrib.auth.authenticate(), it is a legal django.contrib.auth.models.User and in no way has it a "user" attributed expected in the code.

Here're my answers for your questions:

How are you planning on do the integration?

I want osqa run as a separate project, more specifically with a separate fcgi process, but it will reuse the existing django project's user table. Previously our site has a simple forum based on django-forum and I want it replaced by osqa, to migrate the data is another topic.

Which app will be in charge of the registration process and all that stuff?

The existing django app will be responsible for registration, but I want to try something described in this post to make osqa share the same login. So what I wish is there is a link like "Q&A" on the main project and when users click on it they will navigate to osqa without the need to re-login.

you already have an existing user base, or you're just testing?

Yes I've have existing user base already and I take this approach very seriously.

link

answered 10 Nov '10, 22:41

cheka's gravatar image

cheka
16113
accept rate: 0%

edited 10 Nov '10, 22:42

So lemme explain you why forum_modules/localauth/forms.py behaves like that. When you log in, we start the session for that user and immediately redirect you to another page. Immediately, another request starts, and the extended_user middleware has the chance to set things right. This is just a possible approach, and there's nothing wrong with it.

So my suggestion is that, you make some changes to the extended user middleware, or better yet, you can just make it a module, so that whenever you see an users without the necessary "dependencies" you can just create them on the fly and move on. Its just a one way proccess, cause the OSQA user is just an extension of the auth User, and unless there is some very weird check on the existing django-app, it shouldn't even notice the difference.

(11 Nov '10, 06:12) Hernani Cerq... ♦♦

Thanks Hernâni, I'll check how extended user middleware works.

link

answered 11 Nov '10, 06:27

cheka's gravatar image

cheka
16113
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×45
×32

Asked: 10 Nov '10, 07:20

Seen: 827 times

Last updated: 11 Nov '10, 06:27

powered by OSQA