<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Crawling and Searching in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/crawling-and-searching/m-p/1167615#M43997</link>
    <description>&lt;P&gt;I am using ArcGIS Pro 2.9.2 (the latest at this writing).&amp;nbsp; My project's Python Notebook reports that my sys.version is 3.7.11.&lt;/P&gt;&lt;P&gt;My goal is to create a function that tells me which Portal items are using a given ArcGIS Server service, and which Portal items are used by &lt;EM&gt;those&lt;/EM&gt; items, ad infinitum.&amp;nbsp; For example, if I query Portal for a URL to my asphalt service, I want to see the map layers, feature layers, map packages, maps, dashboards, that depend on it&lt;/P&gt;&lt;P&gt;My problem is that a basic Python function is throwing an exception when it should just be returning False.&lt;/P&gt;&lt;P&gt;I am looping through the results of arcgis.gis.GIS.content.search.&amp;nbsp; This returns a list of objects of type&amp;nbsp;arcgis.gis.Item.&amp;nbsp; The documentation for that class says, "Items that have layers (eg FeatureLayerCollection items and ImageryLayer items) and tables have the dynamic layers and tables properties to get to the individual layers/tables in this item."&lt;/P&gt;&lt;P&gt;When I call hasattr(webItem, "layers") on an Item that has a layers property, the hasattr function returns True.&amp;nbsp; However, when I call this function on an Item that &lt;EM&gt;doesn't&lt;/EM&gt; have a layers property, a KeyError exception is thrown.&amp;nbsp; The same occurs if I call getattr(webItem, "layers", []).&amp;nbsp; What's interesting to note is that if I call hasattr(webItem, "abc"), then False is returned.&lt;/P&gt;&lt;P&gt;Why doesn't hasattr just return False, and getattr just return an empty list, when a property named layers doesn't exist on a web Item?&lt;/P&gt;&lt;P&gt;I'm also open to different ways of crawling through Portal to achieve the goal stated above.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2022 17:41:45 GMT</pubDate>
    <dc:creator>DirtDogRoj</dc:creator>
    <dc:date>2022-04-25T17:41:45Z</dc:date>
    <item>
      <title>Crawling and Searching</title>
      <link>https://community.esri.com/t5/data-management-questions/crawling-and-searching/m-p/1167615#M43997</link>
      <description>&lt;P&gt;I am using ArcGIS Pro 2.9.2 (the latest at this writing).&amp;nbsp; My project's Python Notebook reports that my sys.version is 3.7.11.&lt;/P&gt;&lt;P&gt;My goal is to create a function that tells me which Portal items are using a given ArcGIS Server service, and which Portal items are used by &lt;EM&gt;those&lt;/EM&gt; items, ad infinitum.&amp;nbsp; For example, if I query Portal for a URL to my asphalt service, I want to see the map layers, feature layers, map packages, maps, dashboards, that depend on it&lt;/P&gt;&lt;P&gt;My problem is that a basic Python function is throwing an exception when it should just be returning False.&lt;/P&gt;&lt;P&gt;I am looping through the results of arcgis.gis.GIS.content.search.&amp;nbsp; This returns a list of objects of type&amp;nbsp;arcgis.gis.Item.&amp;nbsp; The documentation for that class says, "Items that have layers (eg FeatureLayerCollection items and ImageryLayer items) and tables have the dynamic layers and tables properties to get to the individual layers/tables in this item."&lt;/P&gt;&lt;P&gt;When I call hasattr(webItem, "layers") on an Item that has a layers property, the hasattr function returns True.&amp;nbsp; However, when I call this function on an Item that &lt;EM&gt;doesn't&lt;/EM&gt; have a layers property, a KeyError exception is thrown.&amp;nbsp; The same occurs if I call getattr(webItem, "layers", []).&amp;nbsp; What's interesting to note is that if I call hasattr(webItem, "abc"), then False is returned.&lt;/P&gt;&lt;P&gt;Why doesn't hasattr just return False, and getattr just return an empty list, when a property named layers doesn't exist on a web Item?&lt;/P&gt;&lt;P&gt;I'm also open to different ways of crawling through Portal to achieve the goal stated above.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 17:41:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/crawling-and-searching/m-p/1167615#M43997</guid>
      <dc:creator>DirtDogRoj</dc:creator>
      <dc:date>2022-04-25T17:41:45Z</dc:date>
    </item>
  </channel>
</rss>

