Thanks, I always forget about makepy (what a terrible name). I'm still relatively new to Python.
On Jan 29, 2008 4:39 PM, Mark Hammond <[EMAIL PROTECTED]> wrote: > 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: > > > > rule_obj. _print_details_() > > > > and see what is dumped. Finally, if you can use makepy, the generated > file should make it clearer to see what is going on. > > > > Cheers, > > > > Mark > > > > *From:* [EMAIL PROTECTED] [mailto: > [EMAIL PROTECTED] *On Behalf Of *Tim Johnson > *Sent:* Wednesday, 30 January 2008 11:18 AM > *To:* [email protected] > *Subject:* [python-win32] "Property '%s.%s' can not be set" on read/write > attribute > > > > 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: > > > > >>> coll.AddMembershipRule(rule) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "H:\p4rootw\lib\ops\sms.py", line 495, in AddMembershipRule > rule_obj.RuleName = name > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line > 550, in __setattr__ > raise AttributeError, "Property '%s.%s' can not be set." % > (self._username_, attr) > > > > If you look in the SMS 2003 SDK v3.1 or here ( > http://www.microsoft.com/technet/prodtechnol/sms/sms2003/opsguide/ops_854m.mspx?mfr=true) > 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. > > > > > > > > > > > > # This is a method of an sms.Collection object. > > # > > # self.parent.wmi_connection is an object created via wmi.WMI() with the > > # namespace set to \\server\root\sms\site_S01, > > # and I can retrieve information fine, as well as add/edit Collection, > > # advertisement, and other objects just fine. > > # > > # self.parent.db_connection is an object created via odbc.odbc(), > connected to the SMS database > > > > def AddMembershipRule(self, rule): > """Adds a membership rule using an sms.MemberShipRule object. > > Note: this method only supports adding System Resources through direct > membership, not User or Group Resources. > > Args: > rule: an sms.CollectionMembershipRule object > > Raises: > TypeError: if rule is not an sms.CollectionMembershipRule object > SmsUnsupportedResourceType: if a direct membership rule for a > non-system > resource type is passed > > Returns: > True on Success > None on Failure > > TODO: Remove object type limitation for direct membership rules > """ > if not isinstance(rule, CollectionMembershipRule): > raise TypeError > > self.parent.ConnectWmi() > self.parent.ConnectDb() > conn = self.parent.wmi_connection > > if rule.type == 'direct': > if rule.resource_type != 5: > raise SmsUnsupportedResourceType > > cursor = self.parent.db_connection.cursor() > cursor.execute('SELECT Netbios_Name0, Name0 from v_R_System ' > 'WHERE ResourceID = %s' % rule.resource_id) > names = cursor.fetchall() > name = None > > if names[0]: > name = names[0] > else: > name = names[1] > > > > # This is the problem section > > rule_obj = conn.Get('SMS_CollectionRuleDirect').SpawnInstance_() > rule_obj.ResourceClassName = 'SMS_R_System' > rule_obj.RuleName = name > rule_obj.ResourceID = rule.resource_id > coll_obj = conn.Get('SMS_Collection.CollectionID="%s"' > % self.collection_id) > coll_obj.AddMembershipRule(rule_obj) > > > > > > -- > _____________________ > Ceci n'est pas un email. > -- _____________________ Ceci n'est pas un email.
_______________________________________________ python-win32 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-win32
