def _create_square(self, title, sqmodid, intro, logo):
        cur = self.db.cursor()
        sqlstr = ('INSERT INTO "SQUARE" ("title", "hidden", "sqmodid", '
                  '"intro", "logo", "accessid") VALUES (%s, %s, %s, %s, '
                  '%s, %s) RETURNING "sqid";')
        sqlarr = (title, False, sqmodid, intro, logo, 0)
        cur.execute(sqlstr, sqlarr)

        sqid = None
        for data in cur:
            sqid = data[0]

        if sqid == None:
            return None

        user_idenid = TOJAuth.get_current_iden()['idenid']
        with TOJAuth.change_current_iden(self._idendesc):
            accessid = TOJAuth.instance.create_access(user_idenid)

        sqlstr = ('UPDATE "SQUARE" SET "accessid" = %s WHERE "sqid" = %s;')
        sqlarr = (accessid, sqid)
        cur.execute(sqlstr, sqlarr)

        TOJAuth.instance.set_access_list(
            accessid, TOJAuth.ROLEID_SQUARE_ADMIN_GROUP, 
            TOJAuth.ACCESS_ALL
        )

        sqmodname = self.get_sqmodname_by_sqmodid(sqmodid)
        sqmod = mod.load_sqmod(sqmodname)

        sqmod.create_square_data(sqid)

        return sqid;
    def load_square(self, sqid):
        if sqid in self._sqmod_list:
            return self._sqmod_list[sqid]

        sqinfo = self.get_square_info_by_sqid(sqid)
        sqmodname = sqinfo['sqmodname']
        sqmod = mod.load_sqmod(sqmodname)
        self._sqmod_list[sqid] = sqmod(self._idendesc, self.get_link, sqid)

        return self._sqmod_list[sqid]
    def _delete_square(self, sqid):
        accessid = self.get_accessid_by_sqid(sqid)
        TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_DELETE)

        sqinfo = self.get_square_info_by_sqid(sqid)
        sqmodname = sqinfo['sqmodname']
        sqmod = mod.load_sqmod(sqmodname)

        with TOJAuth.change_current_iden(self._idendesc):
            self.unload_square(sqid)

        sqmod.delete_square_data(sqid)

        TOJAuth.instance.del_access(accessid)

        cur = self.db.cursor()
        sqlstr = ('DELETE FROM "SQUARE" WHERE "sqid" = %s;')
        sqlarr = (sqid, )
        cur.execute(sqlstr, sqlarr)

        sqlstr = ('DELETE FROM "SQUARE_USER" WHERE "sqid" = %s;')
        sqlarr = (sqid, )
        cur.execute(sqlstr, sqlarr)