Commits

paj  committed 1ae2297

AutoComplete example in widget browser

  • Participants
  • Parent commits 3bfdb59

Comments (0)

Files changed (9)

File examples/autocomplete.py

 import tw2.core as twc, tw2.forms as twf, tw2.yui as twy
 
-class MyDataSource(twy.DataSource):
+class MyDataSource(twy.XHRDataSource):
     @classmethod
     def ajax_request(self, req):
         return {'result': ['a','b','c']}

File tw2/yui/__init__.py

 from widgets import (Slider, TabView, AutoComplete, ColorPicker, Calendar,
-        Editor, TreeView, DataSource, LogReader)
+        Editor, TreeView, XHRDataSource, LocalDataSource, LogReader)

File tw2/yui/samples.py

-import widgets as twy, tw2.forms as twf
+import widgets as twy, tw2.forms as twf, tw2.core as twc
 
 page_options = {'css_class': 'yui-skin-sam'}
 
 
 class DemoEditor(twy.Editor):
     rows = 5
+
+class DemoAutoComplete(twy.AutoComplete):
+    class datasrc(twy.LocalDataSource):
+        resources = twy.DataSource.resources + [
+            twc.JSLink(modname=__name__, filename="static/sample-data.js"),
+        ]
+        data = 'YAHOO.example.Data.arrayStates'
+        responseSchema = {'fields ': ["state"]};

File tw2/yui/static/data.js

-YAHOO.example.Data = {
-
-menu: {
-    breakfasts: [
-        "donuts",
-        "omelette",
-        "pancakes",
-        "yogurt"
-    ],
-    lunches: [
-        "burrito",
-        "hamburger",
-        "salad",
-        "turkey sandwich"
-    ],
-    dinners: [
-        "meatloaf",
-        "spaghetti",
-        "pot roast",
-        "roast chicken",
-        "steak"
-    ]
-},
-
-tags: [
-    "accessibility",
-    "college",
-    "family",
-    "funny",
-    "high school",
-    "music",
-    "origami",
-    "photography",
-    "security",
-    "standards",
-    "travel",
-    "video",
-    "work",
-    "yui"
-],
-
-accounts: [
-    {name: "ABC Company", id: 57367 },
-    {name: "Acme Supply Company", id: 84377},
-    {name: "Avery Widgets", id: 73678},
-    {name: "AAA International", id: 73675},
-    {name: "Atlantic Brothers, Inc", id: 83757},
-    {name: "Ace Products", id: 48588},
-    {name: "Above Average, Ltd", id: 75968}
-],
-
-arrayStates: [
-    "Alabama",
-    "Alaska",
-    "Arizona",
-    "Arkansas",
-    "California",
-    "Colorado",
-    "Connecticut",
-    "Delaware",
-    "Florida",
-    "Georgia",
-    "Hawaii",
-    "Idaho",
-    "Illinois",
-    "Indiana",
-    "Iowa",
-    "Kansas",
-    "Kentucky",
-    "Louisiana",
-    "Maine",
-    "Maryland",
-    "Massachusetts",
-    "Michigan",
-    "Minnesota",
-    "Mississippi",
-    "Missouri",
-    "Montana",
-    "Nebraska",
-    "Nevada",
-    "New Hampshire",
-    "New Jersey",
-    "New Mexico",
-    "New York",
-    "North Dakota",
-    "North Carolina",
-    "Ohio",
-    "Oklahoma",
-    "Oregon",
-    "Pennsylvania",
-    "Rhode Island",
-    "South Carolina",
-    "South Dakota",
-    "Tennessee",
-    "Texas",
-    "Utah",
-    "Vermont",
-    "Virginia",
-    "Washington",
-    "West Virginia",
-    "Wisconsin",
-    "Wyoming"
-],
-
-arrayAreaCodesStates: [
-    ["201", "New Jersey"],
-    ["202", "Washington, DC"],
-    ["203", "Connecticut"],
-    ["204", "Manitoba, Canada"],
-    ["205", "Alabama"],
-    ["206", "Washington"],
-    ["207", "Maine"],
-
-    ["208", "Idaho"],
-    ["209", "California"],
-    ["210", "Texas"],
-    ["212", "New York"],
-    ["213", "California"],
-    ["214", "Texas"],
-
-    ["215", "Pennsylvania"],
-    ["216", "Ohio"],
-    ["217", "Illinois"],
-    ["218", "Minnesota"],
-    ["219", "Indiana"],
-    ["224", "Illinois"],
-
-    ["225", "Louisiana"],
-    ["227", "Maryland"],
-    ["228", "Mississippi"],
-    ["229", "Georgia"],
-    ["231", "Michigan"],
-    ["234", "Ohio"],
-
-    ["239", "Florida"],
-    ["240", "Maryland"],
-    ["242", "Bahamas"],
-    ["246", "Barbados"],
-    ["248", "Michigan"],
-    ["250", "British Columbia"],
-
-    ["251", "Alabama"],
-    ["252", "North Carolina"],
-    ["253", "Washington"],
-    ["254", "Texas"],
-    ["256", "Alabama"],
-    ["260", "Indiana"],
-
-    ["262", "Wisconsin"],
-    ["264", "Anguilla"],
-    ["267", "Pennsylvania"],
-    ["268", "Antigua and Barbuda"],
-    ["269", "Michigan"],
-    ["270", "Kentucky"],
-
-    ["276", "Virginia"],
-    ["281", "Texas"],
-    ["283", "Ohio"],
-    ["284", "British Virgin Islands"],
-    ["289", "Ontario"],
-    ["301", "Maryland"],
-
-    ["302", "Delaware"],
-    ["303", "Colorado"],
-    ["304", "West Virginia"],
-    ["305", "Florida"],
-    ["306", "Saskatchewan, Canada"],
-    ["307", "Wyoming"],
-
-    ["308", "Nebraska"],
-    ["309", "Illinois"],
-    ["310", "California"],
-    ["312", "Illinois"],
-    ["313", "Michigan"],
-    ["314", "Missouri"],
-
-    ["315", "New York"],
-    ["316", "Kansas"],
-    ["317", "Indiana"],
-    ["318", "Louisiana"],
-    ["319", "Iowa"],
-    ["320", "Minnesota"],
-
-    ["321", "Florida"],
-    ["323", "California"],
-    ["330", "Ohio"],
-    ["331", "Illinois"],
-    ["334", "Alabama"],
-    ["336", "North Carolina"],
-
-    ["337", "Louisiana"],
-    ["339", "Massachusetts"],
-    ["340", "US Virgin Islands"],
-    ["345", "Cayman Islands"],
-    ["347", "New York"],
-    ["351", "Massachusetts"],
-
-    ["352", "Florida"],
-    ["360", "Washington"],
-    ["361", "Texas"],
-    ["386", "Florida"],
-    ["401", "Rhode Island"],
-    ["402", "Nebraska"],
-
-    ["403", "Alberta, Canada"],
-    ["404", "Georgia"],
-    ["405", "Oklahoma"],
-    ["406", "Montana"],
-    ["407", "Florida"],
-    ["408", "California"],
-
-    ["409", "Texas"],
-    ["410", "Maryland"],
-    ["412", "Pennsylvania"],
-    ["413", "Massachusetts"],
-    ["414", "Wisconsin"],
-    ["415", "California"],
-
-    ["416", "Ontario, Canada"],
-    ["417", "Missouri"],
-    ["418", "Quebec, Canada"],
-    ["419", "Ohio"],
-    ["423", "Tennessee"],
-    ["424", "California"],
-
-    ["425", "Washington"],
-    ["434", "Virginia"],
-    ["435", "Utah"],
-    ["440", "Ohio"],
-    ["441", "Bermuda"],
-    ["443", "Maryland"],
-
-    ["445", "Pennsylvania"],
-    ["450", "Quebec, Canada"],
-    ["464", "Illinois"],
-    ["469", "Texas"],
-    ["470", "Georgia"],
-    ["473", "Grenada"],
-
-    ["475", "Connecticut"],
-    ["478", "Georgia"],
-    ["479", "Arkansas"],
-    ["480", "Arizona"],
-    ["484", "Pennsylvania"],
-    ["501", "Arkansas"],
-
-    ["502", "Kentucky"],
-    ["503", "Oregon"],
-    ["504", "Louisiana"],
-    ["505", "New Mexico"],
-    ["506", "New Brunswick, Canada"],
-    ["507", "Minnesota"],
-
-    ["508", "Massachusetts"],
-    ["509", "Washington"],
-    ["510", "California"],
-    ["512", "Texas"],
-    ["513", "Ohio"],
-    ["514", "Quebec, Canada"],
-
-    ["515", "Iowa"],
-    ["516", "New York"],
-    ["517", "Michigan"],
-    ["518", "New York"],
-    ["519", "Ontario, Canada"],
-    ["520", "Arizona"],
-
-    ["530", "California"],
-    ["540", "Virginia"],
-    ["541", "Oregon"],
-    ["551", "New Jersey"],
-    ["557", "Missouri"],
-    ["559", "California"],
-
-    ["561", "Florida"],
-    ["562", "California"],
-    ["563", "Iowa"],
-    ["564", "Washington"],
-    ["567", "Ohio"],
-    ["570", "Pennsylvania"],
-
-    ["571", "Virginia"],
-    ["573", "Missouri"],
-    ["574", "Indiana"],
-    ["580", "Oklahoma"],
-    ["585", "New York"],
-    ["586", "Michigan"],
-
-    ["601", "Mississippi"],
-    ["602", "Arizona"],
-    ["603", "New Hampshire"],
-    ["604", "British Columbia, Canada"],
-    ["605", "South Dakota"],
-    ["606", "Kentucky"],
-
-    ["607", "New York"],
-    ["608", "Wisconsin"],
-    ["609", "New Jersey"],
-    ["610", "Pennsylvania"],
-    ["612", "Minnesota"],
-    ["613", "Ontario, Canada"],
-
-    ["614", "Ohio"],
-    ["615", "Tennessee"],
-    ["616", "Michigan"],
-    ["617", "Massachusetts"],
-    ["618", "Illinois"],
-    ["619", "California"],
-
-    ["620", "Kansas"],
-    ["623", "Arizona"],
-    ["626", "California"],
-    ["630", "Illinois"],
-    ["631", "New York"],
-    ["636", "Missouri"],
-
-    ["641", "Iowa"],
-    ["646", "New York"],
-    ["647", "Ontario, Canada"],
-    ["649", "Turks and Caicos Islands"],
-    ["650", "California"],
-    ["651", "Minnesota"],
-
-    ["660", "Missouri"],
-    ["661", "California"],
-    ["662", "Mississippi"],
-    ["664", "Montserrat"],
-    ["667", "Maryland"],
-    ["670", "CNMI"],
-
-    ["671", "Guam"],
-    ["678", "Georgia"],
-    ["682", "Texas"],
-    ["701", "North Dakota"],
-    ["702", "Nevada"],
-    ["703", "Virginia"],
-
-    ["704", "North Carolina"],
-    ["705", "Ontario, Canada"],
-    ["706", "Georgia"],
-    ["707", "California"],
-    ["708", "Illinois"],
-    ["709", "Newfoundland, Canada"],
-
-    ["712", "Iowa"],
-    ["713", "Texas"],
-    ["714", "California"],
-    ["715", "Wisconsin"],
-    ["716", "New York"],
-    ["717", "Pennsylvania"],
-
-    ["718", "New York"],
-    ["719", "Colorado"],
-    ["720", "Colorado"],
-    ["724", "Pennsylvania"],
-    ["727", "Florida"],
-    ["731", "Tennessee"],
-
-    ["732", "New Jersey"],
-    ["734", "Michigan"],
-    ["737", "Texas"],
-    ["740", "Ohio"],
-    ["754", "Florida"],
-    ["757", "Viriginia"],
-
-    ["758", "St. Lucia"],
-    ["760", "California"],
-    ["763", "Minnesota"],
-    ["765", "Indiana"],
-    ["767", "Dominica"],
-    ["770", "Georgia"],
-
-    ["772", "Florida"],
-    ["773", "Illinois"],
-    ["774", "Massachusetts"],
-    ["775", "Nevada"],
-    ["778", "British Columbia, Canada"],
-    ["780", "Alberta, Canada"],
-
-    ["781", "Massachusetts"],
-    ["784", "St. Vincent & Gren."],
-    ["785", "Kansas"],
-    ["786", "Florida"],
-    ["787", "Puerto Rico"],
-
-    ["801", "Utah"],
-    ["802", "Vermont"],
-    ["803", "South Carolina"],
-    ["804", "Virginia"],
-    ["805", "California"],
-    ["806", "Texas"],
-
-    ["807", "Ontario, Canada"],
-    ["808", "Hawaii"],
-    ["809", "Dominican Republic"],
-    ["810", "Michigan"],
-    ["812", "Indiana"],
-    ["813", "Florida"],
-
-    ["814", "Pennsylvania"],
-    ["815", "Illinois"],
-    ["816", "Missouri"],
-    ["817", "Texas"],
-    ["818", "California"],
-    ["819", "Quebec, Canada"],
-
-    ["828", "North Carolina"],
-    ["830", "Texas"],
-    ["831", "California"],
-    ["832", "Texas"],
-    ["835", "Pennsylvania"],
-    ["843", "South Carolina"],
-
-    ["845", "New York"],
-    ["847", "Illinois"],
-    ["848", "New Jersey"],
-    ["850", "Florida"],
-    ["856", "New Jersey"],
-    ["857", "Massachusetts"],
-
-    ["858", "California"],
-    ["859", "Kentucky"],
-    ["860", "Connecticut"],
-    ["862", "New Jersey"],
-    ["863", "Florida"],
-    ["864", "South Carolina"],
-
-    ["865", "Tennessee"],
-    ["867", "Yukon, NW Territories, Canada"],
-    ["868", "Trinidad and Tobago"],
-    ["869", "St. Kitts & Nevis"],
-    ["870", "Arkansas"],
-
-    ["872", "Illinois"],
-    ["876", "Jamaica"],
-    ["878", "Pennsylvania"],
-    ["901", "Tennessee"],
-    ["902", "Nova Scotia, Canada"],
-    ["903", "Texas"],
-
-    ["904", "Florida"],
-    ["905", "Ontario, Canada"],
-    ["906", "Michigan"],
-    ["907", "Alaska"],
-    ["908", "New Jersey"],
-    ["909", "California"],
-
-    ["910", "North Carolina"],
-    ["912", "Georgia"],
-    ["913", "Kansas"],
-    ["914", "New York"],
-    ["915", "Texas"],
-    ["916", "California"],
-
-    ["917", "New York"],
-    ["918", "Oklahoma"],
-    ["919", "North Carolina"],
-    ["920", "Wisconsin"],
-    ["925", "California"],
-    ["928", "Arizona"],
-
-    ["931", "Tennessee"],
-    ["936", "Texas"],
-    ["937", "Ohio"],
-    ["939", "Puerto Rico"],
-    ["940", "Texas"],
-    ["941", "Florida"],
-
-    ["947", "Michigan"],
-    ["949", "California"],
-    ["952", "Minnesota"],
-    ["954", "Florida"],
-    ["956", "Texas"],
-    ["959", "Connecticut"],
-
-    ["970", "Colorado"],
-    ["971", "Oregon"],
-    ["972", "Texas"],
-    ["973", "New Jersey"],
-    ["975", "Missouri"],
-    ["978", "Massachusetts"],
-
-    ["979", "Texas"],
-    ["980", "North Carolina"],
-    ["984", "North Carolina"],
-    ["985", "Louisiana"],
-    ["989", "Michigan"]
-]
-
-};

File tw2/yui/static/sample-data.js

+YAHOO.example.Data = {
+
+menu: {
+    breakfasts: [
+        "donuts",
+        "omelette",
+        "pancakes",
+        "yogurt"
+    ],
+    lunches: [
+        "burrito",
+        "hamburger",
+        "salad",
+        "turkey sandwich"
+    ],
+    dinners: [
+        "meatloaf",
+        "spaghetti",
+        "pot roast",
+        "roast chicken",
+        "steak"
+    ]
+},
+
+tags: [
+    "accessibility",
+    "college",
+    "family",
+    "funny",
+    "high school",
+    "music",
+    "origami",
+    "photography",
+    "security",
+    "standards",
+    "travel",
+    "video",
+    "work",
+    "yui"
+],
+
+accounts: [
+    {name: "ABC Company", id: 57367 },
+    {name: "Acme Supply Company", id: 84377},
+    {name: "Avery Widgets", id: 73678},
+    {name: "AAA International", id: 73675},
+    {name: "Atlantic Brothers, Inc", id: 83757},
+    {name: "Ace Products", id: 48588},
+    {name: "Above Average, Ltd", id: 75968}
+],
+
+arrayStates: [
+    "Alabama",
+    "Alaska",
+    "Arizona",
+    "Arkansas",
+    "California",
+    "Colorado",
+    "Connecticut",
+    "Delaware",
+    "Florida",
+    "Georgia",
+    "Hawaii",
+    "Idaho",
+    "Illinois",
+    "Indiana",
+    "Iowa",
+    "Kansas",
+    "Kentucky",
+    "Louisiana",
+    "Maine",
+    "Maryland",
+    "Massachusetts",
+    "Michigan",
+    "Minnesota",
+    "Mississippi",
+    "Missouri",
+    "Montana",
+    "Nebraska",
+    "Nevada",
+    "New Hampshire",
+    "New Jersey",
+    "New Mexico",
+    "New York",
+    "North Dakota",
+    "North Carolina",
+    "Ohio",
+    "Oklahoma",
+    "Oregon",
+    "Pennsylvania",
+    "Rhode Island",
+    "South Carolina",
+    "South Dakota",
+    "Tennessee",
+    "Texas",
+    "Utah",
+    "Vermont",
+    "Virginia",
+    "Washington",
+    "West Virginia",
+    "Wisconsin",
+    "Wyoming"
+],
+
+arrayAreaCodesStates: [
+    ["201", "New Jersey"],
+    ["202", "Washington, DC"],
+    ["203", "Connecticut"],
+    ["204", "Manitoba, Canada"],
+    ["205", "Alabama"],
+    ["206", "Washington"],
+    ["207", "Maine"],
+
+    ["208", "Idaho"],
+    ["209", "California"],
+    ["210", "Texas"],
+    ["212", "New York"],
+    ["213", "California"],
+    ["214", "Texas"],
+
+    ["215", "Pennsylvania"],
+    ["216", "Ohio"],
+    ["217", "Illinois"],
+    ["218", "Minnesota"],
+    ["219", "Indiana"],
+    ["224", "Illinois"],
+
+    ["225", "Louisiana"],
+    ["227", "Maryland"],
+    ["228", "Mississippi"],
+    ["229", "Georgia"],
+    ["231", "Michigan"],
+    ["234", "Ohio"],
+
+    ["239", "Florida"],
+    ["240", "Maryland"],
+    ["242", "Bahamas"],
+    ["246", "Barbados"],
+    ["248", "Michigan"],
+    ["250", "British Columbia"],
+
+    ["251", "Alabama"],
+    ["252", "North Carolina"],
+    ["253", "Washington"],
+    ["254", "Texas"],
+    ["256", "Alabama"],
+    ["260", "Indiana"],
+
+    ["262", "Wisconsin"],
+    ["264", "Anguilla"],
+    ["267", "Pennsylvania"],
+    ["268", "Antigua and Barbuda"],
+    ["269", "Michigan"],
+    ["270", "Kentucky"],
+
+    ["276", "Virginia"],
+    ["281", "Texas"],
+    ["283", "Ohio"],
+    ["284", "British Virgin Islands"],
+    ["289", "Ontario"],
+    ["301", "Maryland"],
+
+    ["302", "Delaware"],
+    ["303", "Colorado"],
+    ["304", "West Virginia"],
+    ["305", "Florida"],
+    ["306", "Saskatchewan, Canada"],
+    ["307", "Wyoming"],
+
+    ["308", "Nebraska"],
+    ["309", "Illinois"],
+    ["310", "California"],
+    ["312", "Illinois"],
+    ["313", "Michigan"],
+    ["314", "Missouri"],
+
+    ["315", "New York"],
+    ["316", "Kansas"],
+    ["317", "Indiana"],
+    ["318", "Louisiana"],
+    ["319", "Iowa"],
+    ["320", "Minnesota"],
+
+    ["321", "Florida"],
+    ["323", "California"],
+    ["330", "Ohio"],
+    ["331", "Illinois"],
+    ["334", "Alabama"],
+    ["336", "North Carolina"],
+
+    ["337", "Louisiana"],
+    ["339", "Massachusetts"],
+    ["340", "US Virgin Islands"],
+    ["345", "Cayman Islands"],
+    ["347", "New York"],
+    ["351", "Massachusetts"],
+
+    ["352", "Florida"],
+    ["360", "Washington"],
+    ["361", "Texas"],
+    ["386", "Florida"],
+    ["401", "Rhode Island"],
+    ["402", "Nebraska"],
+
+    ["403", "Alberta, Canada"],
+    ["404", "Georgia"],
+    ["405", "Oklahoma"],
+    ["406", "Montana"],
+    ["407", "Florida"],
+    ["408", "California"],
+
+    ["409", "Texas"],
+    ["410", "Maryland"],
+    ["412", "Pennsylvania"],
+    ["413", "Massachusetts"],
+    ["414", "Wisconsin"],
+    ["415", "California"],
+
+    ["416", "Ontario, Canada"],
+    ["417", "Missouri"],
+    ["418", "Quebec, Canada"],
+    ["419", "Ohio"],
+    ["423", "Tennessee"],
+    ["424", "California"],
+
+    ["425", "Washington"],
+    ["434", "Virginia"],
+    ["435", "Utah"],
+    ["440", "Ohio"],
+    ["441", "Bermuda"],
+    ["443", "Maryland"],
+
+    ["445", "Pennsylvania"],
+    ["450", "Quebec, Canada"],
+    ["464", "Illinois"],
+    ["469", "Texas"],
+    ["470", "Georgia"],
+    ["473", "Grenada"],
+
+    ["475", "Connecticut"],
+    ["478", "Georgia"],
+    ["479", "Arkansas"],
+    ["480", "Arizona"],
+    ["484", "Pennsylvania"],
+    ["501", "Arkansas"],
+
+    ["502", "Kentucky"],
+    ["503", "Oregon"],
+    ["504", "Louisiana"],
+    ["505", "New Mexico"],
+    ["506", "New Brunswick, Canada"],
+    ["507", "Minnesota"],
+
+    ["508", "Massachusetts"],
+    ["509", "Washington"],
+    ["510", "California"],
+    ["512", "Texas"],
+    ["513", "Ohio"],
+    ["514", "Quebec, Canada"],
+
+    ["515", "Iowa"],
+    ["516", "New York"],
+    ["517", "Michigan"],
+    ["518", "New York"],
+    ["519", "Ontario, Canada"],
+    ["520", "Arizona"],
+
+    ["530", "California"],
+    ["540", "Virginia"],
+    ["541", "Oregon"],
+    ["551", "New Jersey"],
+    ["557", "Missouri"],
+    ["559", "California"],
+
+    ["561", "Florida"],
+    ["562", "California"],
+    ["563", "Iowa"],
+    ["564", "Washington"],
+    ["567", "Ohio"],
+    ["570", "Pennsylvania"],
+
+    ["571", "Virginia"],
+    ["573", "Missouri"],
+    ["574", "Indiana"],
+    ["580", "Oklahoma"],
+    ["585", "New York"],
+    ["586", "Michigan"],
+
+    ["601", "Mississippi"],
+    ["602", "Arizona"],
+    ["603", "New Hampshire"],
+    ["604", "British Columbia, Canada"],
+    ["605", "South Dakota"],
+    ["606", "Kentucky"],
+
+    ["607", "New York"],
+    ["608", "Wisconsin"],
+    ["609", "New Jersey"],
+    ["610", "Pennsylvania"],
+    ["612", "Minnesota"],
+    ["613", "Ontario, Canada"],
+
+    ["614", "Ohio"],
+    ["615", "Tennessee"],
+    ["616", "Michigan"],
+    ["617", "Massachusetts"],
+    ["618", "Illinois"],
+    ["619", "California"],
+
+    ["620", "Kansas"],
+    ["623", "Arizona"],
+    ["626", "California"],
+    ["630", "Illinois"],
+    ["631", "New York"],
+    ["636", "Missouri"],
+
+    ["641", "Iowa"],
+    ["646", "New York"],
+    ["647", "Ontario, Canada"],
+    ["649", "Turks and Caicos Islands"],
+    ["650", "California"],
+    ["651", "Minnesota"],
+
+    ["660", "Missouri"],
+    ["661", "California"],
+    ["662", "Mississippi"],
+    ["664", "Montserrat"],
+    ["667", "Maryland"],
+    ["670", "CNMI"],
+
+    ["671", "Guam"],
+    ["678", "Georgia"],
+    ["682", "Texas"],
+    ["701", "North Dakota"],
+    ["702", "Nevada"],
+    ["703", "Virginia"],
+
+    ["704", "North Carolina"],
+    ["705", "Ontario, Canada"],
+    ["706", "Georgia"],
+    ["707", "California"],
+    ["708", "Illinois"],
+    ["709", "Newfoundland, Canada"],
+
+    ["712", "Iowa"],
+    ["713", "Texas"],
+    ["714", "California"],
+    ["715", "Wisconsin"],
+    ["716", "New York"],
+    ["717", "Pennsylvania"],
+
+    ["718", "New York"],
+    ["719", "Colorado"],
+    ["720", "Colorado"],
+    ["724", "Pennsylvania"],
+    ["727", "Florida"],
+    ["731", "Tennessee"],
+
+    ["732", "New Jersey"],
+    ["734", "Michigan"],
+    ["737", "Texas"],
+    ["740", "Ohio"],
+    ["754", "Florida"],
+    ["757", "Viriginia"],
+
+    ["758", "St. Lucia"],
+    ["760", "California"],
+    ["763", "Minnesota"],
+    ["765", "Indiana"],
+    ["767", "Dominica"],
+    ["770", "Georgia"],
+
+    ["772", "Florida"],
+    ["773", "Illinois"],
+    ["774", "Massachusetts"],
+    ["775", "Nevada"],
+    ["778", "British Columbia, Canada"],
+    ["780", "Alberta, Canada"],
+
+    ["781", "Massachusetts"],
+    ["784", "St. Vincent & Gren."],
+    ["785", "Kansas"],
+    ["786", "Florida"],
+    ["787", "Puerto Rico"],
+
+    ["801", "Utah"],
+    ["802", "Vermont"],
+    ["803", "South Carolina"],
+    ["804", "Virginia"],
+    ["805", "California"],
+    ["806", "Texas"],
+
+    ["807", "Ontario, Canada"],
+    ["808", "Hawaii"],
+    ["809", "Dominican Republic"],
+    ["810", "Michigan"],
+    ["812", "Indiana"],
+    ["813", "Florida"],
+
+    ["814", "Pennsylvania"],
+    ["815", "Illinois"],
+    ["816", "Missouri"],
+    ["817", "Texas"],
+    ["818", "California"],
+    ["819", "Quebec, Canada"],
+
+    ["828", "North Carolina"],
+    ["830", "Texas"],
+    ["831", "California"],
+    ["832", "Texas"],
+    ["835", "Pennsylvania"],
+    ["843", "South Carolina"],
+
+    ["845", "New York"],
+    ["847", "Illinois"],
+    ["848", "New Jersey"],
+    ["850", "Florida"],
+    ["856", "New Jersey"],
+    ["857", "Massachusetts"],
+
+    ["858", "California"],
+    ["859", "Kentucky"],
+    ["860", "Connecticut"],
+    ["862", "New Jersey"],
+    ["863", "Florida"],
+    ["864", "South Carolina"],
+
+    ["865", "Tennessee"],
+    ["867", "Yukon, NW Territories, Canada"],
+    ["868", "Trinidad and Tobago"],
+    ["869", "St. Kitts & Nevis"],
+    ["870", "Arkansas"],
+
+    ["872", "Illinois"],
+    ["876", "Jamaica"],
+    ["878", "Pennsylvania"],
+    ["901", "Tennessee"],
+    ["902", "Nova Scotia, Canada"],
+    ["903", "Texas"],
+
+    ["904", "Florida"],
+    ["905", "Ontario, Canada"],
+    ["906", "Michigan"],
+    ["907", "Alaska"],
+    ["908", "New Jersey"],
+    ["909", "California"],
+
+    ["910", "North Carolina"],
+    ["912", "Georgia"],
+    ["913", "Kansas"],
+    ["914", "New York"],
+    ["915", "Texas"],
+    ["916", "California"],
+
+    ["917", "New York"],
+    ["918", "Oklahoma"],
+    ["919", "North Carolina"],
+    ["920", "Wisconsin"],
+    ["925", "California"],
+    ["928", "Arizona"],
+
+    ["931", "Tennessee"],
+    ["936", "Texas"],
+    ["937", "Ohio"],
+    ["939", "Puerto Rico"],
+    ["940", "Texas"],
+    ["941", "Florida"],
+
+    ["947", "Michigan"],
+    ["949", "California"],
+    ["952", "Minnesota"],
+    ["954", "Florida"],
+    ["956", "Texas"],
+    ["959", "Connecticut"],
+
+    ["970", "Colorado"],
+    ["971", "Oregon"],
+    ["972", "Texas"],
+    ["973", "New Jersey"],
+    ["975", "Missouri"],
+    ["978", "Massachusetts"],
+
+    ["979", "Texas"],
+    ["980", "North Carolina"],
+    ["984", "North Carolina"],
+    ["985", "Louisiana"],
+    ["989", "Michigan"]
+]
+
+};

File tw2/yui/templates/datasource.html

-<script type="text/javascript">
-    tw2_yui_datasources = {}; // TBD: only if undefined
-    var oDS = new YAHOO.util.XHRDataSource("/$w.compound_id", $w.options);
-    tw2_yui_datasources["$w.compound_id"] = oDS;
-</script>

File tw2/yui/templates/localdatasource.html

+<script type="text/javascript">
+    tw2_yui_datasources = {}; // TBD: only if undefined
+    var oDS = new YAHOO.util.LocalDataSource($w.data, $w.options);
+    tw2_yui_datasources["$w.compound_id"] = oDS;
+</script>

File tw2/yui/templates/xhrdatasource.html

+<script type="text/javascript">
+    tw2_yui_datasources = {}; // TBD: only if undefined
+    var oDS = new YAHOO.util.XHRDataSource("/$w.compound_id", $w.options);
+    tw2_yui_datasources["$w.compound_id"] = oDS;
+</script>

File tw2/yui/widgets.py

         twc.JSLink(modname=__name__, filename="static/2.7.0/datasource/datasource-min.js"),
     ]
     responseSchema = twc.Param('TBD', default={'resultsList':'result'})
-    template = "genshi:tw2.yui.templates.datasource"
-    options = {
-        'responseType': 3, # YAHOO.util.XHRDataSource.TYPE_JSON
-    }
 
     def prepare(self):
         self.safe_modify('options')
         self.options['responseSchema'] = self.responseSchema
         super(DataSource, self).prepare()
 
+
+class XHRDataSource(DataSource):
+    template = "genshi:tw2.yui.templates.xhrdatasource"
+    options = {
+        'responseType': 3, # YAHOO.util.XHRDataSource.TYPE_JSON
+    }
+
     @classmethod
     def request(self, req):
         resp = webob.Response(request=req, content_type="text/plain; charset=UTF8")
         return resp
 
 
+class LocalDataSource(DataSource):
+    template = "genshi:tw2.yui.templates.localdatasource"
+    data = twc.Param('Name of the JavaScript array to use as the data source')
+
+
 class ColorPicker(YuiWidget):
     resources = YuiWidget.resources + [
         twc.CSSLink(modname=__name__, filename="static/2.7.0/colorpicker/assets/skins/sam/colorpicker.css"),