# -*- coding: utf-8 -*-

from Base import Base


class %(tableName)s(Base):
	
	def initProperties(self):
		self.super()
		self.Caption = "%(tableName)s"
		self.DataSource = "%(table)s"
		self.KeyField = %(pkField)s

		# Setting the DataStructure explicitly here is optional, but recommended as
		# it will keep Dabo from interpreting field types from the backend every 
		# time. It lets you specify what types you expect which fields to be. Also,
		# this information is used in self.setSQL() to add the fields to the query.
		# (field_alias, field_type, pk, table_name, field_name, field_scale)
%(dataStructure)s		

		# Use the DefaultValues dict to specify default field values for new 
		# records. By default DefaultValues is the empty dict, meaning that 
		# no default values will be filled in.
		#self.DefaultValues['<field_name>'] = <value_or_function_object>

		# Default encoding is set to utf8, but if your backend db encodes in 
		# something else, you need to set that encoding here (or in each 
		# bizobj individually. A very common encoding for the Americas and
		# Western Europe is "latin-1", so if you are getting errors but are
		# unsure what encoding to pick, try uncommenting the following line:
		#self.Encoding = "latin-1"
	

	def afterInit(self):
		self.super()
		

	def setBaseSQL(self):
		# Set up the base SQL (the fields clause, the from clause, etc.) The
		# UI refresh() will probably modify the where clause and maybe the
		# limit clause, depending on what the runtime user chooses in the
		# select page.
		self.addFrom("%(tableNameQt)s")
		self.setLimitClause("500")
		self.addFieldsFromDataStructure()
