Posted by eXt |
|
Hi!
I've got one Django's instance running sphboard. I'd like to: 1. Create two separate boards on two different urls 2. Share members between the boards 3. Have separate permissions for moderators etc. on each board and its categories etc. 4. Use my own app for registering and logging users in/out. Ad. 1. AFAIK in sphboard what I call "board" is equal to "group". So I created two groups and set my urls to point to that: (r'^pl/board/', include('sphene.sphboard.urls'), pl_dict), (r'^en/board/', include('sphene.sphboard.urls'), en_dict), Ad. 2. This works out of the box. After my user logs in he is able to visit both urls and place posts there. Ad. 3. I'm not sure how to set things up. I'm confused because I have "Manage Roles" link in sphboard and some tables in Admin. What should I change and where? I've tried to add a role in "manage roles" and then add a member to this role, and it looks that it works. But what are the groups? Users belong to groups or users only have roles defined for a specific group? What is more when I click Roles table in Admin I get: Environment: Request Method: GET Request URL: http://localhost:8000/admin/community/role/ Django Version: 0.97-pre-SVN-7106 Python Version: 2.5.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.humanize', 'django.contrib.flatpages', 'django.contrib.admin', 'django.contrib.sitemaps', 'multilingual', 'base', 'base_toolbox', 'loginapp', 'registration', 'board', 'sphene.community', 'sphene.sphboard', 'sphene.sphwiki'] Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.locale.LocaleMiddleware', 'sphene.community.middleware.ThreadLocals', 'sphene.community.middleware.GroupMiddleware', 'sphene.community.middleware.LastModified', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'sphene.community.middleware.PermissionDeniedMiddleware') Traceback: File "/home/ext/workingenvs/sphene/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 56. return view_func(request, *args, **kwargs) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in change_list 776. cl = ChangeList(request, model) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in __init__ 582. self.get_results(request) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in get_results 640. result_list = list(self.query_set) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/db/models/query.py" in __iter__ 114. return iter(self._get_data()) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/db/models/query.py" in _get_data 483. self._result_cache = list(self.iterator()) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/db/models/query.py" in iterator 189. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/home/ext/workingenvs/multi-trunk/lib/python2.5/site-packages/django/db/backends/util.py" in execute 18. return self.cursor.execute(sql, params) Exception Type: ProgrammingError at /admin/community/role/ Exception Value: missing FROM-clause entry for table "community_group" Ad. 4. I've changed registration to my own module (in fact it is django-registeration module). It works but I'm not sure whether I should set groups for users that are registering or not? Is there anything I should know about? |
|
Posted by Herbert Poul |
|
ad 1.) well .. actually yes.. to create two fully separated boards .. i would suggest using two community Groups. (i basically use Groups to separate whole websites) - although another way would be to set up a 'PL' and 'EN' category and below it create the forum categories you need.. and then simply link to the PL or EN categories.. it all depends on how much separation you need..
ad 2.) yes, thats no problem.. django users are global for the installation .. (although if you use separate (sub)domains, the login is not shared.. i have yet to find a way to make the session cookie registered for *.sphene.net ;) (not that hard i guess.. it just wasn't any priority of mine yet)) ad 3.) roles only exists within community Groups, but it is not necessary to add users to community Groups .. You should use the 'Manage Roles' link to administer roles (no idea why there is an exception in the django admin .. i'll have to look at it .. but.. you shouldn't have to use it anyway) I would create a 'Forum Moderator' role giving it pretty much all permissions of sphboard_* - afterwards decide which user should be moderator for which category .. - click the 'Add Member' link .. enter the username .. and check 'Has Limitation' (this means that the member has the role only for a specific object) - afterwards select 'Category' for the object type (which .. is the only option currently) .. and .. then.. select the category in which the user should have the role's permissions. If you want one user to have those permissions in more than one category .. you have to add him once for each category .. (this is probably quite some work.. the UI could need some improvements i guess in that respect) ad 4.) well .. it all depends on how you've set up permissions .. when creating a forum category you can choose who can view posts, create threads and post replies.. if you never have something like 'Only group members' there is no need to add users to the group .. (a user has the right to do something if he either has the permission according to the category-setting ('all users') OR because of a role permission - ie. if you select 'Nobody' can post threads, but give somebody permissions through roles.. he can still post threads..) i hope that clarifies a bit of the confusion :) Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Thanks for your answer. It clarifies much, but... I've just hit the wall with the:
pl_dict = {'groupName': 'pl', 'urlPrefix': 'pl', } en_dict = {'groupName': 'en', 'urlPrefix': 'en', } (r'^pl/community/', include('sphene.community.urls'), pl_dict), (r'^pl/board/', include('sphene.sphboard.urls'), pl_dict), (r'^en/community/', include('sphene.community.urls'), en_dict), (r'^en/board/', include('sphene.sphboard.urls'), en_dict), The above doesn't work properly because 'reverse', '{% url %}' or '{% sph_url %}' always finds the first matching url so the links are rendered as 'domain/pl/rest-of-url'. My questions are: 1. What is a puprose of group dictionary? 2. What is 'urlPrefix' in group dictionary? 3. How should I define the above? Any hints? |
|
Posted by Herbert Poul |
|
this .. is a good point .. i think you would have to write something similar to the multi host middleware.. but instead of looking at the domain name which urlconf to use .. you would use the path .. this way only the correct urlconf would be available in the first place.. so reverse & co would work ..
ad 1.) what group dictionary ? the { 'groupName': xxx } ? this way you define which group should be used .. ad 2.) urlPrefix is deprecated. . i hope it's not used anywhere .. Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
I'm going to just use MultiHost Middleware but I've ecountered some problems. Main thing is that when I have a vanilla Board instance (with multi host middleware enabled) and no groups in database I can't get into admin panel because of "No Group matches the given query" error.
After I disable MultiHost Middleware and add some groups I can enable MH Middleware and everything works well. Is this a normal behavior? |
|
Posted by Herbert Poul |
|
well.. i'm not sure what the middleware should do otherwise.. it has to fetch the group from the database based on the host ... if it can't find the group .. it has to throw an error..
it could check before if the request actually needs the group (e.g. if the request goes to /admin/ no group is required) .. but i'm not sure how useful this would be ... i actually assert that users always have at least one group which they use to setup others (one you first run syncdb it should create the 'example' group) btw. from where exactly is the exception coming ? it seems to me that the MultiHostMiddleware would catch DoesNotExist exceptions and simply ignore them.. but not the GroupMiddleware .. i guess .. the error comes from middleware.py line 91 (GroupMiddleware) where it always loads the group if it is set in the SPH_HOST_MIDDLEWARE_URLCONF_MAP setting.. it then sets the group into a thread local ... and i guess this is the problem.. it has no real way to figure out if the group is actually needed later on .. since everyone can request it at all time group the thread local (calling sphene.community.middleware.get_current_group() ) well .. maybe it would be better to lazy-load the group .. once it is needed.. (e.g. only storing the group name in the thread local and loading it once someone calls get_current_group() ) .. but actually .. i don't think this is too important ? it just seems to be a problem when you set up a new installation with existing configuration but without it's data .. (ie. a configuration which requires a group != 'example' but data right after a 'syncdb' which only contains this one group) .. is this correct or am i missing on a major problem ? Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
It doesn't throw a traceback so I don't know. Probably you're right. PDB session passed through MultiHost Middleware, then i just contiunued it.
I think you're right here. It is not important, I can easily workaround this. Just wanted to know whether it is something wrong in my conf :) There are more seriuos problems :P I've just hit the unicode decode error in admin. It is caused by __str__ in the models. What do you think about changing it to __unicode__? |
|
Posted by Herbert Poul |
|
this is possible if you've used non-ascii characters in category names or something :) .
hmm.. i'm pretty sure, when i started SCT the django tutorials described to implement __str__ .. but .. yes, sure.. __unicode__ would be the way to go :( it seems there are only a handful of occurrences though .. herbert-pouls-computer:~/dev/python/communitytools herbert$ grep __str__ `find . -name "*.py"` -r ./sphenecoll/sphene/community/models.py: def __str__(self): ./sphenecoll/sphene/community/models.py: def __str__(self): ./sphenecoll/sphene/community/models.py: def __str__(self): ./sphenecoll/sphene/sphboard/models.py: def __str__(self): ./sphenecoll/sphene/sphboard/models.py: def __str__(self): ./sphenecoll/sphene/sphwiki/models.py: def __str__(self): ./sphenecoll/sphene/sphwiki/models.py: def __str__(self): herbert-pouls-computer:~/dev/python/communitytools herbert$ it should be enough to simply rename those methods to __unicode__ Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Right. Here is a patch.
|
|
Posted by Herbert Poul |
|
cool, thanks a lot again :) it's applied and committed ..
btw. have i asked you before if your website which uses SCT is already available ? :) and, are there any specific features missing you would like to see in SCT ? (except those you've already implemented like i18n ;) ) .. i'm just thinking about the priorities i should work on next.. Hey, we have Signatures !!! Great, isn't it ? ;) |