@@ -68,6 +68,46 @@ def RECORD_ACTION_NEEDS(id):
68
68
class CAPRecord (Record ):
69
69
"""Record API class for CAP."""
70
70
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
+
71
111
def get_record_metadata (self ):
72
112
"""Get Record Metadata instance for deposit."""
73
113
return RecordMetadata .query .filter_by (id = self .id ).one_or_none ()
0 commit comments