# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t


from _objects import DatabaseObject
from _pgsql import pgQuery
from wh import xlt
class Schema(DatabaseObject):
  typename=xlt("Schema")
  shortname=xlt("Schema")
  refreshOid="nsp.oid"
  
  @staticmethod
  def InstancesQuery(parentNode):
    sql=pgQuery("pg_namespace nsp")
    sql.AddCol("nsp.oid, nspacl, nspname as name, pg_get_userbyid(nspowner) AS owner, description")
    sql.AddLeft("pg_description des ON des.objoid=nsp.oid")
    sql.AddWhere("(nsp.oid=2200 OR nsp.oid > %d)" % parentNode.GetServer().GetLastSysOid())
    sql.AddOrder("nspname")
    return sql


  def GetIcon(self):
    icons=[]
    icons.append("Schema")
    oid=self.GetOid()
    if oid <= self.GetServer().GetLastSysOid() and oid != 2200:
      icons.append('pg')
    return self.GetImageId(icons)

    
  def GetProperties(self):
    if not len(self.properties):

      self.properties = [
        (xlt("Name"),           self.name),
        (  "OID" ,              self.info['oid']),

# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t


# Path: modPg/Schema.py
from _objects import DatabaseObject
from _pgsql import pgQuery
from wh import xlt

class Schema(DatabaseObject):
  typename=xlt("Schema")
  shortname=xlt("Schema")
  refreshOid="nsp.oid"
  
  @staticmethod
  def InstancesQuery(parentNode):
    sql=pgQuery("pg_namespace nsp")
    sql.AddCol("nsp.oid, nspacl, nspname as name, pg_get_userbyid(nspowner) AS owner, description")
    sql.AddLeft("pg_description des ON des.objoid=nsp.oid")
    sql.AddWhere("(nsp.oid=2200 OR nsp.oid > %d)" % parentNode.GetServer().GetLastSysOid())
    sql.AddOrder("nspname")
    return sql


  def GetIcon(self):
    icons=[]
    icons.append("Schema")
    oid=self.GetOid()
    if oid <= self.GetServer().GetLastSysOid() and oid != 2200:
      icons.append('pg')
    return self.GetImageId(icons)

    
  def GetProperties(self):
    if not len(self.properties):

      self.properties = [
        (xlt("Name"),           self.name),
        (  "OID" ,              self.info['oid']),

        (xlt("Owner"),          self.info['owner']),