Thanks, I always forget about makepy (what a terrible name). I'm still relatively new to Python.<br><br>
<div class="gmail_quote">On Jan 29, 2008 4:39 PM, Mark Hammond <<a href="mailto:mhammond@skippinet.com.au">mhammond@skippinet.com.au</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">I can't see docs for that property, but if it takes optional params, it might have been transformed to a SetRuleName() method. You could try adding:</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">rule_obj.</span> <span style="FONT-SIZE: 11pt; COLOR: #1f497d">_print_details_()</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">and see what is dumped. Finally, if you can use makepy, the generated file should make it clearer to see what is going on.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Cheers,</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Mark</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: blue 1.5pt solid; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none">
<div>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<p><b><span style="FONT-SIZE: 10pt">From:</span></b><span style="FONT-SIZE: 10pt"> <a href="mailto:python-win32-bounces@python.org" target="_blank">python-win32-bounces@python.org</a> [mailto:<a href="mailto:python-win32-bounces@python.org" target="_blank">python-win32-bounces@python.org</a>] <b>On Behalf Of </b>Tim Johnson<br>
<b>Sent:</b> Wednesday, 30 January 2008 11:18 AM
<div class="Ih2E3d"><br><b>To:</b> <a href="mailto:python-win32@python.org" target="_blank">python-win32@python.org</a><br></div><b>Subject:</b> [python-win32] "Property '%s.%s' can not be set" on read/write attribute</span>
<p></p></p></div></div>
<div>
<div></div>
<div class="Wj3C7c">
<p> </p>
<div>
<p>So I'm trying to automate some tasks with SMS, and I've run into a roadblock when creating new collection membership rules. The code below is a method of a Collection object. It's a rough draft, so don't worry too much about the top half unless you think it might be screwing something up. My problem is that I go to create a new SMS_CollectionRuleDirect object (at the bottom of the code provided) and I get the following error:</p>
</div>
<div>
<p> </p></div>
<div>
<p><span>>>> coll.AddMembershipRule(rule)<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in ?<br> File "H:\p4rootw\lib\ops\sms.py", line 495, in AddMembershipRule<br>
rule_obj.RuleName = name<br> File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 550, in __setattr__<br> raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr)</span></p>
</div>
<div>
<p> </p></div>
<div>
<p>If you look in the SMS 2003 SDK v3.1 or here (<a href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/opsguide/ops_854m.mspx?mfr=true" target="_blank">http://www.microsoft.com/technet/prodtechnol/sms/sms2003/opsguide/ops_854m.mspx?mfr=true</a>) you can see that the property is indeed Read/Write. Is there any way to override this or some workaround that I can use to fix this? I'm about ready to start hopping up and down in my office chair like an angry chimpanzee.</p>
</div>
<div>
<p> </p></div>
<div>
<p> </p></div>
<div>
<p> </p></div>
<div>
<p> </p></div>
<div>
<p> </p></div>
<div>
<p><span># This is a method of an sms.Collection object.</span></p></div>
<div>
<p><span>#</span></p></div>
<div>
<p><span># self.parent.wmi_connection is an object created via wmi.WMI() with the </span></p></div>
<div>
<p><span># namespace set to </span><a><span>\\server\root\sms\site_S01</span></a><span>, </span></p></div>
<div>
<p><span># and I can retrieve information fine, as well as add/edit Collection, </span></p></div>
<div>
<p><span># advertisement, and other objects just fine.</span></p></div>
<div>
<p><span>#</span></p></div>
<div>
<p><span># self.parent.db_connection is an object created via odbc.odbc(), connected to the SMS database</span></p></div>
<div>
<p> </p></div>
<div>
<p><span> def AddMembershipRule(self, rule):<br> """Adds a membership rule using an sms.MemberShipRule object.<br> <br> Note: this method only supports adding System Resources through direct<br> membership, not User or Group Resources.<br>
<br> Args:<br> rule: an sms.CollectionMembershipRule object<br> <br> Raises:<br> TypeError: if rule is not an sms.CollectionMembershipRule object<br> SmsUnsupportedResourceType: if a direct membership rule for a non-system<br>
resource type is passed<br> <br> Returns:<br> True on Success<br> None on Failure<br> <br> TODO: Remove object type limitation for direct membership rules<br> """<br> if not isinstance(rule, CollectionMembershipRule):<br>
raise TypeError<br> <br> self.parent.ConnectWmi()<br> self.parent.ConnectDb()<br> conn = self.parent.wmi_connection<br> <br> if rule.type == 'direct':<br> if rule.resource_type != 5:<br>
raise SmsUnsupportedResourceType<br> <br> cursor = self.parent.db_connection.cursor()<br> cursor.execute('SELECT Netbios_Name0, Name0 from v_R_System '<br> 'WHERE ResourceID = %s' % rule.resource_id)<br>
names = cursor.fetchall()<br> name = None<br> <br> if names[0]:<br> name = names[0]<br> else:<br> name = names[1]</span></p></div>
<div>
<p> </p></div>
<div>
<p><span> # This is the problem section</span></p></div>
<div>
<p><span> rule_obj = conn.Get('SMS_CollectionRuleDirect').SpawnInstance_()<br> rule_obj.ResourceClassName = 'SMS_R_System'<br> rule_obj.RuleName = name<br> rule_obj.ResourceID = rule.resource_id<br>
coll_obj = conn.Get('SMS_Collection.CollectionID="%s"'<br> % self.collection_id)<br> coll_obj.AddMembershipRule(rule_obj)</span></p></div>
<div>
<p> </p></div>
<div>
<p><br clear="all"><br>-- <br>_____________________<br>Ceci n'est pas un email. </p></div></div></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>_____________________<br>Ceci n'est pas un email.