2
2

I'm working on getting our StackExchange site migrated over to OSQA. I've successfully made it through the migration (using a sync from SVN yesterday evening) with only two problems.

  1. I was getting exceptions in ui.register() in registry.py because there was no CONTACT_URL or SUPPORT_URL. I commented out those two lines and it worked. This seems like an obvious bug-- OSQA should tolerate missing/bad values for these two.
  2. Next, I was not able to get "my ID" setting to work correctly-- unless I entered a bogus user ID on the importer form, the import would fail on this line in importer.py: osqau = orm.User.objects.get(id=1). Unfortunately there are no exceptions showing up in the log, so I can't easily debug the problem. Although given that my original (pre-migration) userid was 2 (not 1) I'm not sure how this line of code could ever succeed.

Once worked around those problems, I ran into another one I don't know how to resolve: I can't log into any migrated accounts using OpenID. By default I was, after migration, logged into the account of one of the admins (not me). Then I logged out out of that admin account and tried to log into my account. But when I try to log in with the OpenID mapped to my StackExchange account, OSQA sees it as a new account and tries to create a new account for me.

Any idea how to fix this without re-running the migration? And if I have to re-run the migration, any suggestions for how to work around the problem after migration, so I can log in?

If it matters, my account on the StackExchange site is using myOpenID as a provider.

asked 01 Sep '10, 09:28

Justin%20Grant's gravatar image

Justin Grant
1.1k163532
accept rate: 12%

edited 01 Sep '10, 09:28


First of all I need to explain your possible problems:

  1. This site itself runs without any of those parameters, actually most sites running OSQA never set them up. So the problem is probably some other, which makes the template or whatever blow in that particular line, and Django templates are not very famous for giving good error messages.
  2. Easy, that first line of code should work, because is not trying to get your user from the dump, rather from the db. The stuff is explained here and there and should be straight forward, you start the import process right after creating one and only one user and doing nothing else. Then you select which id you had in the stack exchange site (in your case, number 2), and that user will be merged from the dump into the OSQA user number 1. The reason is simple, the user number 1 has some special privileges in OSQA, is the site owner.

Check the database in the table forum_authkeyuserassociation, if there's any map between your user id and your open id. If not, you can add it safely, and you can be sure it will work.

link

answered 01 Sep '10, 10:07

Hernani%20Cerqueira's gravatar image

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

forum_authkeyuserassociation does contain an association between my (migrated) user account and one of my openid URLs. But my Alternate OpenID URL association is not present. Is this expected?

(01 Sep '10, 15:33) Justin Grant

What wasn't expected to me is the existence of the alternate openid provider :) Is the first time I heard of it, in the dumps I had to annalyze, there wasn't, or I didn't notice the alternate openid field. Which is kind of natural, if you look closely to a dump file (specially Users.xml) you'll that the tag for a given field is ommited if the field is empty, and you're the first one to ever miss it. But if you know the name of the field in the xml file (or want to send a copy to us) well add that to the importer, is a 5 minute addition and we can put it in trunk asap.

(01 Sep '10, 21:24) Hernani Cerq... ♦♦

The element name in the XML is "OpenIdAlt".

(01 Sep '10, 23:27) Justin Grant
1

Also, about #2 above: is it expected that there will be an entry with id=1 in the DB? My DB (populated using the instructions on http://wiki.osqa.net/display/docs/Setting+up+a+development+environment+on+Windows) only had one row in the forum_user table prior to the SX import.

(01 Sep '10, 23:31) Justin Grant

Yes, in a completely fresh database, that one user should have id 1.

(02 Sep '10, 07:33) Hernani Cerq... ♦♦

I created a fresh DB twice (in postgres) and in neither case did my first user account end up with ID=1, even though I think I only had one user in the forum_user table before migration. I suspect this may be caused by failed attempts at initial user creation, because (on some DBMS's at least) failed transactions still increment the sequence counter even if the resulting rows aer rolled back. In any case, seems like the right solution is to adjust the logic to use the current user ID, not a hard-coded "1".

(02 Sep '10, 20:18) Justin Grant

Almost correct :), in some rdbms (most of them actually) the indices are maintained by sequences. In the case of a failed transaction the sequence won't increment, what happens is that when you create for example a record with an assigned id of 1, and then delete that record, and create a new one, even though you deleted object #1, the sequence nextval is still 2, so the new record will be assigned an id of 2.

But if the database is completely fresh (not just emptying the tables, but actually dumping and creating a new one) the user id will be 1, unless weird stuff is happening.

Regarding the solution you propose, there are two issues. First, we would have to adjust other logic not related with the importer, and second of all, imagine that in your dump there is already user number 15, which happens to be the id of the user you're logged in with. Then we would have a collision of ids. And id 1 is perfect in this case because is almost a guarantee that is a non-existent id in the dump.

(02 Sep '10, 20:36) Hernani Cerq... ♦♦
showing 5 of 7 show 2 more comments
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:

×40
×38
×37

Asked: 01 Sep '10, 09:28

Seen: 709 times

Last updated: 02 Sep '10, 20:36

powered by OSQA