I added an ordering adapter that prepends like so:
from plone.folder.default import DefaultOrdering
class PrependOrdering(DefaultOrdering):
"""prepend new added content"""
def notifyAdded(self, id):
"""
Inform the ordering implementation that an item was added
"""
order = self._order(True)
pos = self._pos(True)
order.insert(0, id)
pos.clear()
for n, id in enumerate(order):
pos[id] = n
Then you just need a snippet of code somehwere setting the ordering. I did this on a type basis with a subscriber like so:
def handler_set_ordering(obj, event):
"""subscriber to set ordering
"""
if getattr(aq_base(obj), 'portal_type', '') not in PREPEND_ORDERING_TYPES:
return
obj.setOrdering('prepend')
Hi and thanks.
It partly works, but for some stange reason 'with an offset' (the item ends up at about 5th 'place'.
Before debugging this: could it be an option to just call a sort view (looks like there is one available in Plone 5, from "folder_contents" ?
Or is this much slower ?