Skip to content

Commit eb8ba04

Browse files
committed
add setattr magic method.
1 parent c954989 commit eb8ba04

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

irods/meta.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ def __init__(self, operation, avu, **kw):
131131

132132

133133
class iRODSMetaCollection:
134+
def __setattr__(self, name, value):
135+
"""Prevent the flag attributes such as 'admin', 'timestamps', etc., from
136+
being changed in a way not sanctioned by the library.
137+
"""
138+
from irods.manager.metadata_manager import _MetadataManager_opts_initializer
139+
140+
if name in _MetadataManager_opts_initializer:
141+
msg = f"""The "{name}" attribute is a special one, settable only via a
142+
call on the object. For example: admin_view = data_obj.metadata({name}=<value>)"""
143+
raise AttributeError(msg)
144+
145+
super().__setattr__(name, value)
146+
134147
def __getattr__(self, name):
135148
"""Here we intervene for the purpose of casting such settable flags such
136149
as 'admin', 'timestamps', etc. as readable attributes of the object.

0 commit comments

Comments
 (0)