Lots of ways to skin this cat.
You can just store login times as user metadata but if this is a very busy
site, with many login events, I would lean toward keeping the login times
updated in an external key/value store to avoid ZODB bloat. In either case,
just sort your catalog results by mod date and then iterate through the result
list to generate a dictionary keyed by creator. Then create a new list by
appending each dict value in the sorted order given by your login time store.
from collections import defaultdict
results = portal_catalog(**kwargs) # sorted by mod time
users = userids_sorted_by_login_times()
resultdict = defaultdict(list)
for result in results:
resultdict[result['Creator']].append(result)
newresults = []
for user in users:
newresults.extend(resultdict[user])
return newresults
This, of course, iterates through the entire result list which might an issue
with very large result lists.
Cheers,
Ric
On May 13, 2012, at 10:52 AM, zjs2k wrote:
> Sorry I didn't make it clear. I want to list and sort contents based on their
> owner's last login time. But I do not want to update the content every time
> its owner login. I worry that it will involve too many objects. So my
> question is where should I put the user last login time info so I can easily
> sort on it?
>
> --
> View this message in context:
> http://plone.293351.n2.nabble.com/How-to-search-and-sort-content-based-on-owner-last-login-time-tp7554312p7555083.html
> Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________
> Product-Developers mailing list
> [email protected]
> https://lists.plone.org/mailman/listinfo/plone-product-developers
>
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers