Kirill Simonov avatar Kirill Simonov committed 50eea26 Merge

Merged.

Comments (0)

Files changed (11)

doc/guide/config.rst

 For example, the ``autolimit`` extension truncates at ``limit`` number
 of rows.  The default is 10k, but this ``limit`` can be set::
 
-  $ htsql-ctl shell -E tweak.autolimit;limit=10 pgsql:htsql_regress
+  $ htsql-ctl shell -E tweak.autolimit:limit=10 pgsql:htsql_regress
 
-  ^ this is wrong; how do you set parameters again?
+If more than one parameter is possible, use "," to seperate them::
 
+  $ htsql-ctl shell -E tweak.hello:repeat=3,address=home pgsql:htsql_regress 
 
 Config Files
 ------------

src/htsql_tweak/autolimit/__init__.py

 class TweakAutolimitAddon(Addon):
 
     name = 'tweak.autolimit'
-    hint = """truncates all results to a given number of rows"""
+    hint = """limit # of rows returned by queries"""
     help = """
       To help deployments ensure against accidental denial of
       service, this plugin automatically truncates output from

src/htsql_tweak/cors/__init__.py

 class TweakCORSAddon(Addon):
 
     name = 'tweak.cors'
+    hint = """permit cross site scripting"""
+    help = """
+      This plugin adds CORS headers in order to enable cross
+      site scripting for public data servers.  This permits
+      modern browsers to bypass JSONP and other hacks used
+      to work around XSS protection.
+    """
 
 

src/htsql_tweak/hello/__init__.py

 #
 
 
+from htsql.context import context
 from htsql.adapter import adapts, named
-from htsql.addon import Addon
+from htsql.addon import Addon, Parameter
 from htsql.tr.fn.bind import BindCommand
 from htsql.tr.binding import CommandBinding
 from htsql.tr.signature import NullarySig
 from htsql.cmd.command import Command
 from htsql.cmd.act import Act, RenderAction
+from htsql.validator import PIntVal, ChoiceVal
 
 
 class HelloCmd(Command):
 
     def __call__(self):
         status = "200 OK"
+        address = context.app.tweak.hello.address
+        repeat = context.app.tweak.hello.repeat
+        line = "Hello, " + address.capitalize() + "!\n"
         headers = [('Content-Type', "text/plain; charset=UTF-8")]
-        body = ["Hello, World!"]
+        body = [line * repeat]
         return (status, headers, body)
 
 
 class TweakHelloAddon(Addon):
+    
+    name = 'tweak.hello'
+    hint = """example plugin and command"""
+    help = """
+      This is an example plugin and command.  It has two parameters
+      ``address`` which defaults to 'world' and ``repeat`` which
+      defaults to 1.  The plugin registers a command ``/hello()``
+      that prints "Hello, X!" several times.  It can be started 
+      using a command line::
 
-    name = 'tweak.hello'
+       htsql-ctl shell htsql_regress -E tweak.hello:address=mom,repeat=3
 
+    """
 
+    parameters = [
+            Parameter('repeat', PIntVal(), default=1),
+            Parameter('address', ChoiceVal(['mom','home','world']), 
+                                 default='world')
+    ]
+

src/htsql_tweak/meta/__init__.py

 class TweakMetaAddon(Addon):
 
     name = 'tweak.meta'
+    hint = """meta-data introspection database"""
+    help = """
+      This plugin provides a command ``/meta()`` that is an
+      in-memory database providing introspection ability.
+      The introspection permits listing of tables, columns,
+      and links.  For example, ``/meta(/table)`` lists all
+      of the tables in the current database.
+    """
 
     prerequisites = []
 

src/htsql_tweak/shell/__init__.py

 
     name = 'tweak.shell'
     prerequisites = ['tweak.resource']
+    hint = """registers visual /shell() command"""
+    help = """
+      This command creates a command line editor in Javascript
+      that can let users edit multi-line queries using a web-browser.
+    """
 
     parameters = [
             Parameter('server_root', StrVal(r'^https?://.+$')),

src/htsql_tweak/shell/default/__init__.py

 class TweakShellDefaultAddon(Addon):
 
     name = 'tweak.shell.default'
+    hint = """makes /shell() be default command"""
+    help = """
+      This plugin makes the default formatter be the command shell,
+      rather than plain HTML.  Of course ``/:html`` format is still
+      available, but must be provided explicitly.
+    """
 
     parameters = [
             Parameter('on_root', BoolVal(), default=True),

src/htsql_tweak/sqlalchemy/__init__.py

     prerequisites = []
     postrequisites = ['htsql']
     name = 'tweak.sqlalchemy'
-    hint = """provides glue to SQLAlchemy engine and model"""
+    hint = """adapts to SQLAlchemy engine and model"""
     help = """
       This plugin provides SQLAlchemy integration in two ways.
       First, if the dburi is omitted, it attempts to use the

src/htsql_tweak/timeout/__init__.py

 class TweakTimeoutAddon(Addon):
 
     name = 'tweak.timeout'
+    hint = """limit query execution time"""
+    help = """
+      To help deployments ensure against accidental denial of
+      service, this plugin automatically limits all queries to
+      a given number of seconds (the default is 60s).  This 
+      plugin is currently only supported by PostgreSQL.
+    """
 
     parameters = [
             Parameter('timeout', PIntVal(is_nullable=True),

src/htsql_tweak/timeout/pgsql/__init__.py

 class TweakTimeoutPGSQLAddon(Addon):
 
     name = 'tweak.timeout.pgsql'
+    hint = """implements query timeout for PostgreSQL"""
+    help = """
+      This plugin is used to set the query timeout using PostgreSQL
+      specific connection parameter.
+    """
     prerequisites = ['engine.pgsql']
 
 

src/htsql_tweak/view/__init__.py

 class TweakViewAddon(Addon):
 
     name = 'tweak.view'
+    hint = """guesses links for views"""
+    help = """
+      This plugin attempts to guess at various links 
+      between views and tables (where foreign keys are
+      not defined).  This is only supported in PostgreSQL.
+    """
 
     @classmethod
     def get_extension(cls, app, attributes):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.