Skip to content

Commit

Permalink
- improve the Browse tab with more table information
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Jun 11, 2018
1 parent f53c6c4 commit 0c576fc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Products.ZMySQLDA change log

- Removed the hurt system files.

- Improved the ``Browse`` tab with more table information.


3.1.1
-----
Expand Down
12 changes: 7 additions & 5 deletions Products/ZMySQLDA/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ def tables(self, rdb=0, _care=("TABLE", "VIEW")):
""" Returns list of tables.
"""
t_list = []
db_result = self._query("SHOW TABLES")
row = db_result.fetch_row(1)
while row:
t_list.append({"table_name": row[0][0], "table_type": "table"})
row = db_result.fetch_row(1)
db_result = self._query("SHOW TABLE STATUS")
for row in db_result.fetch_row(0):
description = '%s, %s rows, character set/collation %s' % (
row[1], str(row[4]), row[14])
t_list.append({'table_name': row[0],
'table_type': 'table',
'description': description})
return t_list

def columns(self, table_name):
Expand Down
6 changes: 4 additions & 2 deletions Products/ZMySQLDA/tests/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
""" Dummy fixtures for testing
"""

RESULTS = {'show tables': [['table1']],
RESULTS = {'show table status': [['table1', 'engine1', None, None, 5, None,
None, None, None, None, None, None, None,
None, 'my_collation']],
'show variables': [('var1', 'val1'), ('version', '5.5.5')]}

TABLE = {'table_name': 'table1', 'table_type': 'type1'}
TABLE = {'table_name': 'table1', 'table_type': 'type1', 'description': ''}

COLUMNS = [{'name': 'col1', 'icon': 'icon1', 'description': 'desc1'},
{'name': 'col2', 'icon': 'icon2', 'description': 'desc2'}]
Expand Down
4 changes: 2 additions & 2 deletions Products/ZMySQLDA/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _makeOne(self):
def test_instantiation(self):
browser = self._makeOne()
self.assertEqual(browser.icon, 'what')
self.assertEqual(browser.description, '')
self.assertEqual(browser.description(), '')
self.assertEqual(browser.check, '')

def test_getattr(self):
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_tpURL(self):

def test_description(self):
browser = self._makeOne()
self.assertEqual(browser.description(), ' desc1')
self.assertEqual(browser.description(), 'desc1')


class valuesTests(unittest.TestCase):
Expand Down
7 changes: 5 additions & 2 deletions Products/ZMySQLDA/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __getitem__(self, i):

class TableBrowser(BrowserBase, Implicit):
icon = "what"
description = check = ""
check = ""
info = HTMLFile("www/table_info", globals())

def tpValues(self):
Expand Down Expand Up @@ -72,6 +72,9 @@ def name(self):
def type(self):
return self._d["table_type"]

def description(self):
return self._d["description"]


class ColumnBrowser(BrowserBase):
icon = "field"
Expand All @@ -89,7 +92,7 @@ def tpURL(self):
return "Column/%s" % self._d["name"]

def description(self):
return " %s" % self._d["description"]
return self._d["description"]


table_icons = {"table": "table", "view": "view", "system_table": "stable"}
2 changes: 1 addition & 1 deletion Products/ZMySQLDA/www/browse.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dtml-tree header=info>
<img src="&dtml-SCRIPT_NAME;/misc_/ZMySQLDA/&dtml-icon;"
alt="&dtml-type;" border="0">
<dtml-var name><dtml-var description>
<strong><dtml-var name></strong> (<dtml-var description>)
</dtml-tree>

<dtml-var manage_page_footer>

0 comments on commit 0c576fc

Please sign in to comment.