Ticket #1092 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

Add more convenient convenience methods for Properties

Reported by: Owned by:
Priority: major Milestone: Bcfg2 1.3.0 Release
Component: bcfg2-client Version: 1.0
Keywords: Cc:

Description (last modified by (diff)

(06:17:40 AM) tie: ok, working with properties is way too clumsy
(06:18:00 AM) tie: to get the FQDN property corresponding to the current host in a template, I need to do:
(06:18:12 AM) tie: ${[el.text for el in metadata.Properties['props.xml'].Match(metadata) if el.tag=='FQDN'][0]}
(06:20:27 AM) tie: ideally, this should be more like ${ metadata.MyProperties['props.xml'].FQDN[0].text}
(07:40:48 AM) stpierre: tie: how would you feel about ${metadata.Properties['props.xml'].get("FQDN").text} or ${metadata.Properties['props.xml'].get_all("FQDN")[0].text} ?
(07:44:04 AM) stpierre: i guess it would have to be ${metadata.Properties['props.xml'].get("FQDN", metadata=metadata).text} or something similar
(07:44:23 AM) stpierre: making that a kwarg doesn't make sense, so just get("FQDN", metadata).
(07:58:54 AM) tie: stpierre: ${metadata.Properties['props.xml'].get("FQDN").text} is OK, definitely much better than the current situation, though I'm not sure how it would handle multiple FQDN tags
(07:59:24 AM) tie: passing the metadata to a member of the metadata object seems superfluous
(08:00:29 AM) tie: it is very nice to have the entire set of Properties accessible, but there should be a shortcut that leads to the Properties of the current client or group
(08:01:30 AM) stpierre: you'd handle multiple tags with get_all.
(08:01:50 AM) stpierre: given the way connectors work we may not be able to eliminate the "extra" metadata argument.  i'll look into that
(08:01:50 AM) tie: ah, I see what you meant
(08:02:38 AM) tie: may I suggest adding an object member which links to the parent?
(08:03:03 AM) tie: e.g. whenever metadata gets Properties added, it does: = self
(08:03:32 AM) tie: so you can get a link to the current metadata inside the Properties object
(08:03:58 AM) tie: then it is trivial to add: if metadata == None: metadata == self.parent
(08:04:32 AM) stpierre: that would have to change the connector plugin interface as a whole
(08:04:43 AM) stpierre: it's not that this is impossible, it may just be improbable for a bugfix release :)
(08:07:15 AM) stpierre: made particularly difficult by the fact that metadata.Properties is not a Properties plugin object (or similar), but a dict().
(08:08:08 AM) tie: it can be subclassed, so it would retain all dict properties
(08:08:46 AM) stpierre: i know -- like i said, not impossible, just improbable for 1.2.1


Change History

comment:1 Changed 11 years ago by

  • Owner changed from desai to
  • Status changed from new to accepted
  • Description modified (diff)

comment:2 Changed 11 years ago by

  • Status changed from accepted to closed
  • Resolution set to fixed

The new XMLMatch() method and automatch setting make handling Group/Client? tags in Properties files much easier, along the lines of the very first suggestion in the description.

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.