# Python AttributeError when included in dir()

**URL:** <https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354>\
**Category:** Ignition\
**Created:** [September 26, 2021, 10:48pm UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354 "2021-09-26T22:48:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 26, 2021, 10:48pm UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/1 "2021-09-26T22:48:23Z")

</div>

This is probably a lack of my Java knowledge...

I got this from someone at IA to get a full list of all of the default alarm props:

> [@system.tag.getAlarmStates alternative?](https://forum.inductiveautomation.com/t/system-tag-getalarmstates-alternative/27803/13):
>
> Update: You can get the alarm default values using: from com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties, AlarmModeProperties properties = {} properties.update(dict((s.getName(), s.getDefaultValue()) for s in CommonAlarmProperties.values())) properties.update(dict((s.getName(), s.getDefaultValue()) for s in AlarmModeProperties.values()))

I'm trying to do something similar but for tags in general (history would be good as well).  
I searched the API and found `com.inductiveautomation.ignition.common.tags.config.BasicTagConfiguration` and `com.inductiveautomation.ignition.common.tags.config.BasicTagConfigurationModel` which seemed to be what I was after maybe... and proceeded to try to use the `getValues` method, but got an AttributeError for both:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e8c1ec3b0b3cee1932bb95ab503efa86881c034.png)

Can someone explain this, and point me in the right direction?  
@paul-griffith? 🙂

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 27, 2021, 1:27am UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/2 "2021-09-27T01:27:13Z")

</div>

You are trying to use an instance property (really translated from NetBeans getter .getValues()) on a class. You need to use it on an instance.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 27, 2021, 1:28am UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/3 "2021-09-27T01:28:49Z")

</div>

> [@system.tag.getAlarmStates alternative?](https://forum.inductiveautomation.com/t/system-tag-getalarmstates-alternative/27803/13):
>
> com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties, AlarmModeProperties properties = {} properties.update(dict((s.getName(), s.getDefaultValue()) for s in CommonAlarmProperties.values())) properties.update(dict((s.getName(), s.getDefaultValue()) for s in AlarmModeProperties.values()))

How does what i'm doing differ from the alarm code though?

```auto
com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties, AlarmModeProperties
properties = {}
properties.update(dict((s.getName(), s.getDefaultValue()) for s in CommonAlarmProperties.values()))

```

Edit:  
Using this works, but it turns out I don't think I have the right objects to get the default config 😕 any ideas?

```auto
from com.inductiveautomation.ignition.common.tags.config import BasicTagConfigurationModel
from com.inductiveautomation.ignition.common.tags.config.types import TagObjectType
from com.inductiveautomation.ignition.common.tags.paths import BasicTagPath

tagPath = BasicTagPath('path')
a = BasicTagConfigurationModel(tagPath, # path
							   True, # mutable
							   False, # inherited
							   True, # isNew
							   TagObjectType.AtomicTag) # type
print a.values

```

Edit:  
a.values just prints an empty list

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 27, 2021, 10:06am UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/4 "2021-09-27T10:06:39Z")

</div>

CommonAlarmProperties is an enum class, which naturally has a values() method (on the class). Distinct from a getValues() method of `BasicTagConfigurationModel` which is not an enum. Your constructor looks fine. I don’t know why it doesn’t work. (But I haven’t explored in this area. You can keep blazing a trail…)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 27, 2021, 2:19pm UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/5 "2021-09-27T14:19:31Z")

</div>

You’re not doing anything wrong (necessarily), it’s just that BasicTagConfigurationModel doesn’t do what you expect it to do.

It looks like, at a glance, it’s still ‘just’ an extension of the PropertySet model that everything else tag related uses - TagConfigurationModel and its related members are extended to allow, for instance, ‘layering’ of snapshots over each other, but you still need to derive those snapshots from somewhere. Ultimately, the more helpful thing for what you’re trying to do is probably going to be using `com.inductiveautomation.ignition.common.tags.config.BasicTagConfiguration#createEdit(com.inductiveautomation.ignition.common.tags.model.TagPath)`, then extracting each property (or its default) using `com.inductiveautomation.ignition.common.config.PropertyValueSource#getOrDefault`.

To get a static reference to the properties you care about, refer to the aptly-named `com.inductiveautomation.ignition.common.tags.config.properties.WellKnownTagProps`.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 27, 2021, 8:40pm UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/6 "2021-09-27T20:40:54Z")

</div>

Thanks Paul, that’s gotten me somewhere.  
Onto the next dumb question 🙂  
How would I get a list of all of the fields of `WellKnownTagProps`? I can use `dir()` but that will return methods and everything else as well. Is there something else I can use?

Also, I actually don’t think I need to use `BasicTagConfiguration*` or `PropertyValueSource` at all as the `WellKnownTagProps` has a method `getDefaultValue()`.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 27, 2021, 9:05pm UTC](https://forum.inductiveautomation.com/t/python-attributeerror-when-included-in-dir/51354/7 "2021-09-27T21:05:20Z")

</div>

> [@nminchin](#):
>
> How would I get a list of all of the fields of `WellKnownTagProps` ? I can use `dir()` but that will return methods and everything else as well. Is there something else I can use?

Java's reflection API, though I haven't done a lot with it from Jython. E.G, something like this from the class definition, translated to Jython:

> <https://stackoverflow.com/questions/3422390/retrieve-only-static-fields-declared-in-java-class/3422435#3422435>

There's no central registry or anything; as of 8.0 a key aspect of the tag configuration model is that any tag can have any number of properties, and the 'actors' that actually _do_ anything with the tag configuration simply 'ask' for what they care about.
