On Wed, Jul 18, 2012 at 9:35 AM, Anand Buddhdev <[email protected]> wrote:
> Hello dnspython users, > > If I have a dns.zone.Zone object, what's the best way to make a copy of > it? I have some code that provides AXFR to a client. My code iterates > over all the RRsets in the Zone objects, and returns them in the AXFR. > > However, the zone could change while the AXFR is running, so in order to > guard against inconsistent records, I want to lock updates, create a > copy of the zone, and then serve the AXFR from this copy. > > Just doing something like "copyofzone = zone" doesn't work, because the > Zone object is mutable. Making a change in 'zone' is reflected in > 'copyofzone'. > > Any ideas? > > Hi Anand, One naive way to do it is to serialize and deserialize, something like: # z1 is an existing zone object... import StringIO str_io = StringIO.StringIO() z1.to_file(str_io) z2 = dns.zone.from_text(str_io. getvalue()) Alternatively, you could use a mutex shared between the AXFR and update processes. The update process would queue updates as they come in, if the mutex is unavailable, instead of immediately making the changes. Casey
_______________________________________________ dnspython-users mailing list [email protected] http://howl.play-bow.org/mailman/listinfo/dnspython-users
