<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
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:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>rule_obj.</span> <span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>_print_details_()<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
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.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cheers,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Mark<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] <b>On
Behalf Of </b>Tim Johnson<br>
<b>Sent:</b> Wednesday, 30 January 2008 11:18 AM<br>
<b>To:</b> python-win32@python.org<br>
<b>Subject:</b> [python-win32] "Property '%s.%s' can not be set" on
read/write attribute<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<p class=MsoNormal>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:<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>>>>
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><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>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">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.<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># This is a method
of an sms.Collection object.</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#
self.parent.wmi_connection is an object created via wmi.WMI() with the </span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#
namespace set to </span><a href="file:///\\server\root\sms\site_S01"><span
style='font-family:"Courier New"'>\\server\root\sms\site_S01</span></a><span
style='font-family:"Courier New"'>, </span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># and I
can retrieve information fine, as well as add/edit Collection, </span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#
advertisement, and other objects just fine.</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>#
self.parent.db_connection is an object created via odbc.odbc(), connected to
the SMS database</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'> 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><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>
# This is the problem section</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>
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><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><br clear=all>
<br>
-- <br>
_____________________<br>
Ceci n'est pas un email. <o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>