Skip to content

Commit 3b6b57b

Browse files
committed
records: override new bucket methods
Signed-off-by: Parth Shandilya <[email protected]>
1 parent 0b4852a commit 3b6b57b

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

cap/modules/records/api.py

+40
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,46 @@ def RECORD_ACTION_NEEDS(id):
6868
class CAPRecord(Record):
6969
"""Record API class for CAP."""
7070

71+
@classmethod
72+
def create_bucket(cls, data):
73+
"""Create a bucket for this record.
74+
75+
Override this method to provide more advanced bucket creation
76+
capabilities. This method may return a new or existing bucket, or may
77+
return None, in case no bucket should be created.
78+
"""
79+
return None
80+
81+
@classmethod
82+
def load_bucket(cls, record):
83+
"""Load the bucket id from the record metadata.
84+
85+
Override this method to provide custom behavior for retrieving the
86+
bucket id from the record metadata. By default the bucket id is
87+
retrieved from the ``_bucket`` key. If you override this method, make
88+
sure you also override :py:data:`Record.dump_bucket()`.
89+
90+
:param record: A record instance.
91+
"""
92+
return
93+
94+
@classmethod
95+
def dump_bucket(cls, data, bucket):
96+
"""Dump the bucket id into the record metadata.
97+
98+
Override this method to provide custom behavior for storing the bucket
99+
id in the record metadata. By default the bucket id is stored in the
100+
``_bucket`` key. If you override this method, make sure you also
101+
override :py:data:`Record.load_bucket()`.
102+
103+
This method is called after the bucket is created, but before the
104+
record is created in the database.
105+
106+
:param data: A dictionary of the record metadata.
107+
:param bucket: The created bucket for the record.
108+
"""
109+
pass
110+
71111
def get_record_metadata(self):
72112
"""Get Record Metadata instance for deposit."""
73113
return RecordMetadata.query.filter_by(id=self.id).one_or_none()

requirements-local-forks.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
#-e git+https://github.com/parths007/invenio-records-rest.git@os-2-new#egg=invenio-records-rest
88
#-e git+https://github.com/parths007/[email protected]#egg=invenio-search[opensearch2]
99
-e git+https://github.com/parths007/[email protected]#egg=invenio-files-rest
10-
-e git+https://github.com/cernanalysispreservation/invenio-records-files.git@new#egg=invenio-records-files
10+
#-e git+https://github.com/cernanalysispreservation/invenio-records-files.git@new#egg=invenio-records-files
1111
-e git+https://github.com/cernanalysispreservation/invenio-deposit.git@os-2#egg=invenio-deposit
1212
-e git+https://github.com/cernanalysispreservation/invenio-query-parser.git@os#egg=invenio-query-parser

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
# Invenio Files deps
109109
'invenio-files-rest @ git+https://github.com/parths007/[email protected]',
110-
'invenio-records-files @ git+https://github.com/cernanalysispreservation/invenio-records-files.git@new#egg=invenio-records-files',
110+
'invenio-records-files>=1.2.1',
111111

112112
# Database deps
113113
'invenio-db[postgresql,versioning]==1.0.13',

0 commit comments

Comments
 (0)