Giter Club home page Giter Club logo

basium's People

Contributors

lowinger42 avatar

Watchers

 avatar

Forkers

wader

basium's Issues

Add verify/modifyTable for sqlite driver

Move most of the code to the basium.py file, driver will just handle low-level operations

Sqlite cannot change/rename/delete columns, so a new database needs to be created and the data copied

Handle different versions of API

When API changes, handle compability with older versions

Client must inform server of what API version it wants to use, for example with an extension header.

Add decorator, for returning json formatted data

Simplify returning JSON formatted data

@JSON
def handlepost():
# do processing, create a dictionary
d = { "error": 0, "data": 23 }
# dictionary will be json encoded and returned using the basium_orm JSON encoder
return d

Add decorators fo webpages

Better security, explicit declare what functions can be called

file api.py

@url
def _table():
.....

@default_url
def default():
.....

add template system for HTML generation

Today the HTML output is generated by python code.
This is complicated to use, and changes to pages are work intensive to do

By using a template system, logic and HTML code can be separated and
updated independently.

Write as a plugin, so different template system can be used.

new handler of URLs and routing to functions

Current router is very limited, and can't even handle a default index.html

The new router must handle .py extensions transparent, and default pages
Byh using different URLs, different functions should be called in the same module

if no matching function exist, default() is called. User can then create static methods, and
the rest is handled by one function, for example to process REST table CRUD

Implement as a pluggable module, so developer can implement custom URL routers

Examples:
/
calls index() in default.py

/main (main.py exist)
calls index() in main.py

/main (main.py DOES NOT exist)
calls main() in default.py

/module1/show (module1.py exist)
calls show() in module1.py

/module1/show (module1.py DOES NOT exist)
error 404, not found

/dir1/module/y
calls y() in /dir1/module.py

If len(url) == 0
/index.py index()

if len(url) == 1
/index.py function url[0]

if len(url) == 2:
if isdir(url[0]):
/url[0]/index.py function url[1]
else:
/url[0].py function url[1]

if len(url) >2:

search for non-dir, then handle the rest of the URLs as above

Implement order in query

The query.order() can be be combined with filter, and multiple order() are ok

Usage:
user = User()
query = db.query()
query.filter(user.q.age, ">=", 17)
query.order(user.q.age)
result = db.load(query)

query = db.query()
query.filter(user.q.age, "<", 18)
query.order(user.q.name)
query.order(user.q.age, desc=True)
result = db.load(query)

add custom status pages

The status pages "404 Page not found" is very basic,
add support for customized pages.

Point to a directory, in which there are files matching
the status code.

status 404 -> 404.html or 404.py, then just return the content.

views, create a mapping from compiled code back to source, for line numbers

Errors in core ends up with a stack trace from the compiled view, which makes it hard to find the error in the source being compiled.

This only needs to be active during development/debug flag, for performance reasons

Possible solutions:

  • add comment at each compiled line, with lineno
  • create a separate map file with line:line mappings

add N:M joins

Very often tables has relations between them, a common one is N:M

This can be simulated with python code, but it is much simpler and faster to let
the underlying driver do all work.

To handle the N:M, a separate (hidden) table with the _id from each table must be used.

logging under apache, only log message

With current logger the following ends up in log
[Sun Jul 14 06:37:38 2013] [error] 2013-07-14 06:37:38,772 DEBUG Insert one row in table 'protocolparam'

date, time, level is duplicated

Add scripted database modification

There is no way to automatically detect if a column has been renamed,
this must be manually handled.

Create a table _system and store actual version of each table, and changes (as log lines)
when a modification that cannot be handled automatically should be done, a script is written that handles this.
Script should work on a high level, all low-level database specific items is handled by the driver. If not a script for each driver is needed.

override default tablename

The table used is default the class name, lower cased. There may be situations
where this is less than desired, if for example some characters are not supported by
the driver/underlying backing store.

class BasiumTest(basium_model.Model).
_tableName = 'basium_test'
name = basium_model.VarcharCol()

add session support

Add to basium_wsgihandler

  • create, handle session
  • Start with memory based
  • create as plugin, so more session handlers can be written, with other backing store

Add to basium_driver_json

  • receive new cookie, send in each request

add autoreload of modules

Today, if an dynamic loaded module/page is loaded by the wsgi handler, the imported modules are not reloaded if the change. The user needs to restart the wsgi server to force a reload.

A simple approach is to use a Rollback importer, as described here
http://pyunit.sourceforge.net/notes/reloading.html

This should be combined with a debug/release flag, no reloading is needed when running release code.

add debug flag

Used during development. If true and included modules gives an error, show stacktrace

During production, the stack trace can possibly return "secret" information so the debug flag should be set to False

add 1:N joins

Very often tables has relations between them, the most common one is 1:N

This can be simulated with python code, but it is much simpler and faster to let
the underlying driver do all work.

A new list object is defined.

class Groups(basium_model.Model):
    name = basium_model.VarcharCol()
    flags = basium_model.IntCol()

class Users(basium_model.Model):
    name = basium_model.VarcharCol()
    password = basium_model.VarcharCol()
    groups = basium_model.List(Groups)

Whe loading a object from database, the corresponding List is filled with related objects

result = basium.load(Users(3))

this loads the Users object with _id 3, and all related objects

result.data
   name "anders"
   password "secret"
   groups = [ groups object, groups object ]

todo: where is the relation created/stored? Possibly when a Class is referenced in .List() ?

Create mapper object, instead of monkey-patching the model class

Pros:
A model instance is not tied to a specific sql driver, so working with for example a local db and a remote over json gets easier

Example:
customer = remotedb.load(Customer(22))
localdb.store(customer[0])

This is also the reason the model object should not have .load/.store methods, it would lock the instance to a specific database driver.

The mapper can be used in custom code, for example in the wsgi api.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.