Listing 4. Code that Calls Metaclass Function
# The tricky part--initializing objects from the
# configuration global
# `Configuration' is the top level of the object
# tree we're going to mung
Configuration = Controls()
copy_instance(Configuration, configuration)
Configuration.servers = [];
for server in configuration[`servers']:
Newsite = Server()
copy_instance(Newsite, server)
Configuration.servers.append(Newsite)
Newsite.users = [];
for user in server['users']:
Newuser = User()
copy_instance(Newuser, user)
Newsite.users.append(Newuser)
Copyright © 1994 - 2019 Linux Journal. All rights reserved.