# ValidatePrefs issue

**URL:** <https://forums.plex.tv/t/validateprefs-issue/276847>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [June 28, 2018, 12:30pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847 "2018-06-28T12:30:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![coder-alpha](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/coder-alpha/32/12985_2.png) [@coder-alpha](https://forums.plex.tv/u/coder-alpha)\
**Post date:** [June 28, 2018, 12:30pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/1 "2018-06-28T12:30:39Z")

</div>

So I’m trying to use the ValidatePrefs function to propagate the Preferences to my library (python code library). For this it is essential to have this function run anytime the user changes their Preferences. However, this does not happen and the function does not run and instead I see a Critical Error entry. Am I doing something wrong ?

```auto
2018-06-28 08:07:15,204 (db0) : DEBUG (preferences:198) - Saved the user preferences
2018-06-28 08:07:15,206 (db0) : CRITICAL (sandbox:298) - Function named 'ValidatePrefs' couldnt be found in the current environment

```

```auto
@route(PREFIX + "/ValidatePrefs")
def ValidatePrefs():
        val = Prefs['val_to_propagate_key']
        my_lib_control.set('val_to_propagate_key', val)

```

Mods please report this to the concerned Plex developers if this is a genuine bug.

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [June 28, 2018, 8:03pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/2 "2018-06-28T20:03:35Z")

</div>

Is your PREFIX set correctly?

---

<div class="post-metadata">

**Author:** ![coder-alpha](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/coder-alpha/32/12985_2.png) [@coder-alpha](https://forums.plex.tv/u/coder-alpha)\
**Post date:** [June 28, 2018, 8:06pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/3 "2018-06-28T20:06:06Z")

</div>

I think so since my MainMenu uses the same…

```auto
@handler(PREFIX, TITLE, art=common.ART, thumb=common.ICON)
@route(PREFIX + "/MainMenu")
def MainMenu(**kwargs):

```

EDIT: Well I see it being used in WebTools and it works fine there so it seems something in my code is causing this issue. So doesn’t look like a bug.

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [June 28, 2018, 8:27pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/4 "2018-06-28T20:27:16Z")

</div>

Confirmed not to be a bug, by testing in WebTools 😃

---

<div class="post-metadata">

**Author:** ![coder-alpha](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/coder-alpha/32/12985_2.png) [@coder-alpha](https://forums.plex.tv/u/coder-alpha)\
**Post date:** [June 28, 2018, 8:39pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/5 "2018-06-28T20:39:08Z")

</div>

All good now… refactoring of code went a lil too far. I guess some core functions need to reside in the ` __init__.py` file.

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [June 28, 2018, 8:41pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/6 "2018-06-28T20:41:10Z")

</div>

Sadly so, and as far as I found out, only files located side by side with the **init**.py file can use the framework.

If you put them in like a shared directory or siml, framework functions are not avail for them, AFAICT

---

<div class="post-metadata">

**Author:** ![coder-alpha](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/coder-alpha/32/12985_2.png) [@coder-alpha](https://forums.plex.tv/u/coder-alpha)\
**Post date:** [June 28, 2018, 8:52pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/7 "2018-06-28T20:52:06Z")

</div>

Well previously I did have it in a separate main.py file (residing next to init.py) but it doesn’t seem to be accessible even from there.

Going offtopic… the code/preformatted text option of Discourse needs a better template for the Plex Dark theme, its almost non-viewable with its contrasting white. Also, something that might not be realized outside of the Dev section(s) where its primarily used for code.

 ![image](https://global.discourse-cdn.com/plex/original/3X/0/e/0e7419e978aac6d565f86d4fe8c800e349d05f67.png)

EDIT: …and [voiced my opinion here](https://forums.plex.tv/t/theme-feedback/274395/9)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [September 26, 2018, 8:52pm UTC](https://forums.plex.tv/t/validateprefs-issue/276847/8 "2018-09-26T20:52:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
