cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Why are we enforced to use `is_*` methods of tagged union

Explorer | Level 4

I am trying to list all members in a column/row format.

For example, column1=email, column2=status

I can add email to the column1 row just fine, but I cannot access the status tag. I am enforced to call each is_* methods until I get a True response and then figure which is_* method returned True and the corresponding tag to the column2 row. Why can't we simply access the tag? Why this overhead of calling each is_* method and why not just add an attribute that returns the tag (I am reluctant to use the _tag attribute).

 

 

4 Replies 4
Highlighted

Re: Why are we enforced to use `is_*` methods of tagged union

Dropboxer
Dropboxer

Thanks for the feedback! In general, the SDKs are meant to abstract away the concept of the "tag", but I'll pass this along as a feature request for a public accessor for the tag value itself. 

(Also, "_tag" is considered private, but that said, it's unlikely to change.)

Highlighted

Re: Why are we enforced to use `is_*` methods of tagged union

Explorer | Level 4

I appreciate your response, Greg.

Please consider use cases where the value of the tag is necessary. For example, let's say I want to export all users/groups to a CSV file with column names that correspond to the tag names and rows that correspond to the value of the tag.

Columns: id, firstname, lastname, email, status

Rows: <id>, X, Y, x.y@noemail.com, <active|suspended>

In this case, I just need be to extract the value associated with `status` (i.e. user.status should either evaluate to 'active|suspended|removed'). This is unfortunately not possible with the current specification. Is there any other way to retrieve what I want?

Also, can you explain what following in the SDK implies? What are corresponding get_* methods here? I couldn't find any get_* methods.

This class acts as a tagged union. Only one of the is_* methods will return true. To get the associated value of a tag (if one exists), use the corresponding get_* method.

 

 

 

Highlighted

Re: Why are we enforced to use `is_*` methods of tagged union

Dropboxer
Dropboxer

With the Python SDK, you can use the "_tag" property to access the value. It is private, and so not officially supported, but I don't expect it to change. Just make sure you test it whenver you update to a new version of the SDK.

The get_* methods can be used to retrieve the value of the set union field. The field may not always have a typed value to return, so you won't always see the get_* methods on any particular class. You can see an example of one at CreateFolderError.get_path though.

Highlighted

Re: Why are we enforced to use `is_*` methods of tagged union

Explorer | Level 4

Thanks Greg!

I'm using a hacky approach to get the results. I wasn't confident using '_tag' attribute as it's private and implementation changes might break my code. 

 

 

 

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?