user956424
user956424

Reputation: 1609

How to get a collection of checked-in files?

How do I get a collection of files that are in 'checked-in' status at any point of time? Using plone 4.1. Checked-in is not a workflow status. It is a file that has been locked by a user while editing so that the other user cannot access the latest copy before the former has unlocked the file by 'check-in'. I want to know if I can have a collection to display a list of all the files that have been locked i.e 'check-out' or have 'check-in' status at any point of time.

Upvotes: 0

Views: 160

Answers (3)

Ida
Ida

Reputation: 3965

It's possible with this approach:

  • Add a new field 'Has workingcopy' to all ATCT's via the famous schemaextender.
  • Register the field in the catalog, to make it available to collections.
  • Listen to eventhandlers to set the field to true, when a workingcopy is created and to False when it's chekced-out or canceled.

I wrote a package for this, because I need it anyway for a project soon: adi.workingcopyflag

Upvotes: 1

user2665694
user2665694

Reputation:

Since the checked-in/checked-out state is not indexed in portal_catalog there is no way to make the information available to a collection.

Upvotes: 0

Alex
Alex

Reputation: 4345

Since checked-in objects are indistinguishable from "normal" published objects, there is probably no easy way to create such a collection.

A few workarounds come to mind:

  • Look for checked out objects by searching for objects in the private state whose ids begin with "copy_of"

  • Check for "published" objects.

  • Create a custom workflow that contains an additional "checked-in" state and (somehow) use the checked in state for objects that have been checked out and checked back in at least once.

None of these are particularly attractive so a catalog search for published items is probably your best bet:

>>> [brain.getObject().getId() for brain in portal.portal_catalog(
    review_state="published")]
['front-page', 'news', 'aggregator', 'events', 'aggregator', 'Members']

Which you can compare with a list of all objects if you like:

>>> [brain.getObject().getId() for brain in portal.portal_catalog()]
['front-page', 'news', 'aggregator', 'events', 'aggregator', 'Members',
    'copy_of_front-page']

You don't need to do this programmatically, just wanted to demonstrate the difference between searching for published objects vs all objects. The latter returns an additional checked out object (in the private state).

Upvotes: 1

Related Questions