AttributeError for rdfSingle

1 view
Skip to first unread message

cakebread

unread,
Apr 7, 2008, 1:06:59 PM4/7/08
to rdfalchemy-dev

I like how rdfMultiple raises an AttributeError if I try to pass in a
non-list.

Could we get rdfSingle to do something similar if we try to pass in a
list or tuple? That doesn't cover all incorrect types, but would cover
the most common mistakes.

Something like:

+++ descriptors.py (working copy)
@@ -145,6 +145,10 @@
def __set__(self, obj, value):
log.debug("SET with descriptor value %s of type %s"%
(value,type(value)))
#setattr(obj, self.name, value) #this recurses indefinatly
+
+ if isinstance(value, list) or isinstance(value, tuple):
+ raise AttributeError("to set an rdfSingle you must pass
in a single value")
+

Philip Cooper

unread,
Apr 7, 2008, 5:12:02 PM4/7/08
to rdfalch...@googlegroups.com
cakebread at about 4/7/08 11:06 AM said:
> I like how rdfMultiple raises an AttributeError if I try to pass in a
> non-list.
>
> Could we get rdfSingle to do something similar if we try to pass in a
> list or tuple?


Thanks Rob,
Put this in changeset: 116

also updated rdfMultiple (and descendants) to allow a list or a tuple
(not just a list).

--
Phil

Reply all
Reply to author
Forward
0 new messages