MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / remove

Method remove

openlibrary/core/booknotes.py:188–214  ·  view source on GitHub ↗

Remove a patron's specific booknote by work_id. Technical note: work_id is not an optional argument and intentionally does not default to None (to reduce accidents/risk), however if one passes None as a value to work_id, this method will remove all booknotes for a pa

(cls, username, work_id, edition_id=NULL_EDITION_VALUE)

Source from the content-addressed store, hash-verified

186
187 @classmethod
188 def remove(cls, username, work_id, edition_id=NULL_EDITION_VALUE):
189 """Remove a patron's specific booknote by work_id.
190
191 Technical note: work_id is not an optional argument and
192 intentionally does not default to None (to reduce
193 accidents/risk), however if one passes None as a value to
194 work_id, this method will remove all booknotes for a patron
195 (useful for a patron who may decide to close their account.
196
197 Q: Is there a way to add a dryrun=False param to make this safer?
198
199 return: a list of the IDs affected
200 """
201 oldb = db.get_db()
202 where = {
203 "username": username,
204 "work_id": int(work_id),
205 "edition_id": edition_id,
206 }
207 try:
208 return oldb.delete(
209 "booknotes",
210 where=("work_id=$work_id AND username=$username AND edition_id=$edition_id"),
211 vars=where,
212 )
213 except: # we want to catch no entry exists
214 return None

Callers

nothing calls this directly

Calls 1

deleteMethod · 0.45

Tested by

no test coverage detected