# Get current scope in scripting

**URL:** <https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686>\
**Category:** General Discussion\
**Created:** [February 2, 2022, 9:35pm UTC](https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686 "2022-02-02T21:35:03Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [June 24, 2026, 9:47pm UTC](https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686/21 "2026-06-24T21:47:52Z")

</div>

> [@paul-griffith](#):
>
> PageModel is the class. The `PAGE` attribute will always be present because it's a `ThreadLocal` field:

> [@paul-griffith](#):
>
> So `if pageModel.PAGE.get() is not None:` would be the equivalent operation and should work.

> [@pturmel](#):
>
> > [@richardNZ15](#):
> >
> > asynchronous thread
> 
> The asynchronous thread will not have the thread local for the page.

i think that results in `if pageModel and pageModel.PAGE.get() is None` if i remember correctly (notice the absence of `not`)

edit for clarity:

```python
from com.inductiveautomation.ignition.common.model import ApplicationScope

def isPerspectiveAsync():
	# https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686/8
	# https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686/11
	try:
		from com.inductiveautomation.ignition.gateway import IgnitionGateway
		pageModel = IgnitionGateway.get().moduleManager.resolveClass("com.inductiveautomation.perspective.gateway.model.PageModel")
		return ApplicationScope.isGateway(scope) and hasattr(system,'perspective') and pageModel.PAGE.get() is None
	except: return False

```

[Previous page](https://forum.inductiveautomation.com/t/get-current-scope-in-scripting/55686.md?page=1)
