<?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 Re: Cannot add/remove attachments in python when table/featureclass is versioned in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58969#M4631</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like you may have discovered a bug.&amp;nbsp; I was able to reproduce the same behavior using ArcGIS 10.1 SP1 and SQL Server.&amp;nbsp; I would recommend following up with Tech Support to verify this, and to have this bug logged with your customer information attached to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for your workaround, I don't see any problems using this.&amp;nbsp; I ran a test and everything appeared to work.&amp;nbsp; I also verified that the delta (A &amp;amp; D) tables update correctly, as well as the SDE_STATES table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Dec 2012 10:09:04 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2012-12-10T10:09:04Z</dc:date>
    <item>
      <title>Cannot add/remove attachments in python when table/featureclass is versioned</title>
      <link>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58968#M4630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone run into problems when using the arcpy.AddAttachments_management() function with tables that have been registered as versioned? I can't seem to successfully do it...even though attachments work fine through other means (e.g., via a REST interface for a FeatureServer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my specific case, I have an enterprise sde geodatabase (using PostgreSQL). Before anything gets registered as versioned, I can add attachments as usual. Once things are versioned, however, it's a different story. Here's the easiest way for me to summarize this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; # Works arcpy.AddAttachments_management("C:/test/test.sde/test.sde.test_table","objectid","C:/test/test.csv","FileID","FilePath","#")&amp;nbsp; # Cleanup arcpy.RemoveAttachments_management("C:/test/test.sde/test.sde.test_table","objectid","C:/test/test.csv","FileID","#")&amp;nbsp; # Register the table as versioned: arcpy.RegisterAsVersioned_management("C:/test/test.sde/test.sde.test_table")&amp;nbsp; # Produces this error: http://resources.arcgis.com/en/help/main/10.1/00vp/00vp0000002n001180.htm arcpy.AddAttachments_management("C:/test/test.sde/test.sde.test_table","objectid","C:/test/test.csv","FileID","FilePath","#")&amp;nbsp; # Unregister the table as versioned: arcpy.UnregisterAsVersioned_management("C:/test/test.sde/test.sde.test_table")&amp;nbsp; # Still produces this error: http://resources.arcgis.com/en/help/main/10.1/00vp/00vp0000002n001180.htm arcpy.AddAttachments_management("C:/test/test.sde/test.sde.test_table","objectid","C:/test/test.csv","FileID","FilePath","#")&amp;nbsp; # Oops, looks like the __ATTACH table is still versioned (gets registered automatically, but not unregistered) # Note: if I only unregister the __ATTACH table, then the table it is associated with does get automatically unversioned. arcpy.UnregisterAsVersioned_management("C:/test/test.sde/test.sde.test_table__ATTACH")&amp;nbsp; # Now this works again: arcpy.AddAttachments_management("C:/test/test.sde/test.sde.test_table","objectid","C:/test/test.csv","FileID","FilePath","#") &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I have the same table/featureclass accessible through an editable feature service, the addattachments REST calls work fine, and respect versioning. This problem seems to be limited to only python. As a workaround, I guess I can manually insert records into the __ATTACH table...is this a bad idea? This seems to work okay:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; edit = arcpy.da.Editor("C:/test/test.sde") edit.startEditing(False, True) edit.startOperation()&amp;nbsp; cur = arcpy.da.InsertCursor("C:/test/test.sde/test.sde.test_table__ATTACH",["rel_objectid","content_type","att_name","data_size","data"]) file = memoryview(open("C:/test/test.pdf","rb").read()) row = [801,"application/pdf","test.pdf",len(file.tobytes()),file] cur.insertRow(row)&amp;nbsp; edit.stopOperation() edit.stopEditing(True) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After performing the above, everything else (e.g., a FeatureServer) seems to recognize the attachments without any noticeable problem. Is it a bad idea to do this as a workaround? My interpretation is that all the add/remove features tools do is modify the contents of the __ATTACH tables, so it seems like inserting rows like the above should be safe to do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts/suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 16:33:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58968#M4630</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-12-07T16:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot add/remove attachments in python when table/featureclass is versioned</title>
      <link>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58969#M4631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like you may have discovered a bug.&amp;nbsp; I was able to reproduce the same behavior using ArcGIS 10.1 SP1 and SQL Server.&amp;nbsp; I would recommend following up with Tech Support to verify this, and to have this bug logged with your customer information attached to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for your workaround, I don't see any problems using this.&amp;nbsp; I ran a test and everything appeared to work.&amp;nbsp; I also verified that the delta (A &amp;amp; D) tables update correctly, as well as the SDE_STATES table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 10:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58969#M4631</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-12-10T10:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot add/remove attachments in python when table/featureclass is versioned</title>
      <link>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58970#M4632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I also looked into this issue and was able to repro it using the GP tools as well. It seems that when you register the input dataset as versioned, the __ATTACH table becomes registered as versioned too (because it is in a relationship class with the input dataset). However, when the the input dataset is unregistered as versioned, the __ATTACH table is not automatically unregistered as versioned. This conflict seems to be causing the error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another work around you could use is to manually unregister the __ATTACH table by right clicking&amp;gt;unregister as versioned or using arcpy.UnregisterAsVersioned_management() in your script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 22:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-add-remove-attachments-in-python-when-table/m-p/58970#M4632</guid>
      <dc:creator>JillianPenney</dc:creator>
      <dc:date>2012-12-17T22:38:56Z</dc:date>
    </item>
  </channel>
</rss>

