How to list a form's components?

What I’m trying to do:
I need to print out to the console a list of a form’s components. I have a blank form that I add components to in code… pdfrenderer uses this form to create a report… so in the IDE the form has no components

At the end of my server call to pdfrenderer, I want to print out the console (server log) a list of all components to see if something stray is getting added.

I don’t see anything in the documentation to do this:

for component in form.components:
   print(component)

form.get_components()

1 Like

So when I execute this diagnostic print statement, I’m seeing this:

<GetCVEs.aa_cover.aa_cover object>
<GetCVEs.ab_toc.ab_toc object>
<GetCVEs.ac_marketing.ac_marketing object>
<GetCVEs.ad_exec_preface.ad_exec_preface object>
<GetCVEs.ah_tb_summary.ah_tb_summary object>
<GetCVEs.ad_exec_summary.ad_exec_summary object>
<GetCVEs.ae_pfix_1.ae_pfix_1 object>
<GetCVEs.ae_pfix_2.ae_pfix_2 object>
<GetCVEs.ae_pfix_3.ae_pfix_3 object>

now… when I search, I see nothing anywhere my app that is named GetCVEs. It sounds like a function I would write… what is that “GETCVEs” position in the component name? the name of the form is A1Base…

I don’t think you can see the name of a component programmatically, unless it has changed recently (here is a very old FR about it)

You can read other properties, including tag, you can also get the dom node and read the html attributes, but I don’t think you can get the Anvil name.

This is the name of the app.

So the <GetCVEs.aa_cover.aa_cover object> is an instance of the aa_cover component which is located in the aa_cover file which is within the GetCVEs app.

1 Like

Interesting… because all of this is not in a GEtCVEs app… appreciate the responses

Could those components be from a dependency with that name (3rd party or private)?

This is what I get from get_components when I have an anvil_extras switch in the container in question:

<anvil_extras.Switch.Switch object>

even though that app that’s consuming the switch is obviously not named anvil_extras.

bingo… that’s what I’m seeing… hoping that all of this leads me to solve my problem with pdfrenderer always appending a blank page on my reports… Trying to see if there’s something on one of the components. Thx again

I found an app that calls a function in my core app, which is why I had set up my core app as available as a dependency. I don’t need this other app, but I don’t see how to remove that in my core app. When I go to dependencies, and then I delete GetCVEs… when I close that dialog box it reinserts that name.