Posted by eXt |
|
Oh yes. You're right I'll do it this way.
No. I mean the form which is shown right after the profile is saved. It is a list of last posts of a user. Hmm.. I digged to post.body_escapedfunction which sets cache. Is there any easy way to clear that cache?
Sure. I'll add the comments. |
|
Posted by eXt |
|
Answering myself. I've written a quick cache cleaner to by put into sphboard_extras:
def clear_posts_render_cache(instance): allowed_categories = get_all_viewable_categories( instance.group, instance.user ) post_list = Post.objects.filter( category__id__in = allowed_categories, author = instance.user ) for post in post_list: cache.delete( post.__get_render_cachekey() ) dispatcher.connect(clear_posts_render_cache, sender = CommunityUserProfile, signal = signals.post_save) Looks that it works. |
|
Posted by Herbert Poul |
|
for post in post_list: cache.delete( post.__get_render_cachekey() ) looks nice .. maybe we could put the actual cache.delete(..) call into a method like clear_render_cache() of the Post method - because __get_render_cachekey() is actually meant as a "private" method .. in addition this method could be also used in the Post.save() method .. (i guess you have the cache.delete call from there?) Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Yes I know that this is private, but now I'm just hacking around to get something working. I have the cache delete call from CommunityUserProfile, because it changes the username (displayusername) which is displayed in the posts list. Just click my username to see my profile and the list I'm talking about.
A little problem I can see in the above code would be the "group" parameter which is not an attribute of CommunityUserProfile as I assumed. |
|
Posted by eXt |
|
Ok. Here is a complete patch that has all the functionality we were talking about. I won't commit that unless you verify it.
The cache cleaning code is now: def clear_posts_render_cache(instance): for group in Group.objects.all(): allowed_categories = get_all_viewable_categories( group, instance.user ) post_list = Post.objects.filter( category__id__in = allowed_categories, author = instance.user ) for post in post_list: post.clear_render_cache() dispatcher.connect(clear_posts_render_cache, sender = CommunityUserProfile, signal = signals.post_save) everything works well for me. |
|
Posted by Herbert Poul |
|
looks very good.. :)
just one thing ... do you know of the changelog attribute ? it's a SCT specific "feature" to the model so that on 'syncdb' new columns would get added.. the CommunityUserProfile already has a changelog attribute.. so simply add something like: ( '2008-04-10 00', 'alter', 'ADD displayname varchar(250)' ), ( '2008-04-10 01', 'update', "SET displayname = ''" ), ( '2008-04-10 02', 'alter', 'ALTER displayname SET NOT NULL' ), this way everyone updating from SVN and running syncdb would see the changes .. and postgresql users get updated automatically :) but other than that, the patch looks perfect :) thanks Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Thats really cool and useful feature. Something like django-evolution. In fact I've experienced existence of this feature some time ago but I didn't know that this is SCT specific thing and that changelog attribute is resposible for that.
I've added the lines from above to CommunityUserProfile changelog. So if you'll give me a green light I'll commit the changes to the trunk. The "final" patch is attached. |
|
Posted by Herbert Poul |
|
i just needed a easy way to keep my server database in sync with my development on my notebook .. i haven't found a solution in django so i created this simple changelog script .. but i hope something comes out of the django model evolution branch :)
i have looked through the patch .. seems fine :) please commit it, and i'll try it out on this server ;) thanks, herbert Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Commited.
|
|
Posted by Herbert Poul |
|
thanks .. i've tried it now ..
one small problem/misunderstanding i didn't catch earlier.. wouldn't it be better to have a setting (community_displayname_filled_with_username_or_fullname) to affect only the fallback, instead of the initial value of the profile form ? (if the user wants the default behavior there is no need to store the username or first/last name as display name) - what do you think about moving this check right into the get_fullusername() method ? Hey, we have Signatures !!! Great, isn't it ? ;) |