def init_root_resource(self, is_root=True):
        self.server = ServerInterface(self.server_url, COOKIE_FILE)

        if is_root:
            self.root = RootResource(self.server, self.server_url)
        else:
            self.root = Resource(self.server, self.server_url)
            self.root._load()

        self.current = self.root
        self.stack = []
        self.stack.append([self.root, self.make_parent_button(self.root.resource_name)])

        self.actions = []
class ResourceWidget(gtk.ScrolledWindow):
    def __init__(self, hadjustment=None, vadjustment=None, server_url=SERVER_URL, is_root=True):
        super(ResourceWidget, self).__init__()
        self.set_border_width(10)
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
        self.main_box = gtk.VBox(False, 10)
        self.main_box.show()
        self.add_with_viewport(self.main_box)
        
        self.server_url = server_url
        self.init_root_resource(is_root)

        self.header_table = gtk.Table(1, 3)
        self.header_table.show()
        self.tree_box = gtk.VBox(False, 0)
        self.tree_box.show()
        tree_label = gtk.Label("Resource Tree:")
        tree_label.show()
        self.tree_box.pack_start(tree_label)
        self.header_table.attach(self.tree_box, 0, 1, 0, 1)
        self.current_tree_size = 0
        self.update_tree()
        self.main_box.pack_start(self.header_table)

        self.actions_box = gtk.VBox(False, 0)
        self.actions_box.show()
        actions_label = gtk.Label("Actions:")
        actions_label.show()
        self.actions_box.pack_start(actions_label)
        self.header_table.attach(self.actions_box, 2, 3, 0, 1)        

        self.table = None
        self.get_id = None
        self.changes = {}
        self.build_table(self.root.data)


    def init_root_resource(self, is_root=True):
        self.server = ServerInterface(self.server_url, COOKIE_FILE)

        if is_root:
            self.root = RootResource(self.server, self.server_url)
        else:
            self.root = Resource(self.server, self.server_url)
            self.root._load()

        self.current = self.root
        self.stack = []
        self.stack.append([self.root, self.make_parent_button(self.root.resource_name)])

        self.actions = []

    def parent_clicked(self, widget, data):
        curr = self.stack[len(self.stack) - 1]

        while not curr[0].resource_name == data:
            curr = self.stack.pop()
            curr[1].hide()
            self.tree_box.remove(curr[1])
            self.current_tree_size = self.current_tree_size - 1        
            curr = self.stack[len(self.stack) - 1]

        self.current = curr[0]
        self.link_clicked(None, 'self')
        #self.build_table(self.current.data)

    def link_clicked(self, widget, data):
        if data:
            if data == 'update':
                try:
                    for n in self.changes.keys():
                        self.current.update_field(n, self.changes[n])

                    self.current.save()
                except urllib2.HTTPError, e:
                    #print e.read()
                    pass
            elif data == 'create':
                error = True
                self.current = self.current.create()
                
                while error:
                    try:
                        self.current.save()
                        error = False
                    except urllib2.HTTPError, e:
                        text = e.read()
                        text_json = json_loads(text)
                        if 'fields' in text_json:
                            for n in text_json['fields']:
                                print 'Missing Field Required!'
                                print 'Please enter a value for %s' % n
                                value = raw_input('%s: ' % n)
                                self.current.update_field(n, value)
                        else:
                            self.current.clear_updates()

                self.stack.append([self.current, self.make_parent_button(self.current.resource_name)])
                self.update_tree()                            
            else: