Git Product home page Git Product logo

uliweb's Introduction

LOGO

Uliweb Introduction

Join the chat at https://gitter.im/limodou/uliweb

Limodou [email protected]

About Uliweb

Uliweb is a full-stacked Python based web framework. It has three main design goals, they are: reusability, configurability, and replaceability. All the functionalities revolve around these goals.

This project was created and lead by Limodou mailto:[email protected].

License

Uliweb is released under BSD license.

Infrastructure

Uliweb was not created totally from scratch. It uses some modules created by other developers, for example:

  • Werkzeug Used to handle core processes in the framework. For example: URL Mapping, Debug, Request, Response, etc.
  • SqlAlchemy The ORM based on it. Developers can access databases, or use the module separately.

I also referenced some code from other web frameworks, for example:

  • The Templating system is modified from tornado.
  • Some code inspired from Django.

I also constructed a few new "wheels" myself. For example:

  • Form processing module. Developers can use it to create HTML code, validate submitted data and convert submitted data to Python data types.
  • I18n processing including template support, language lazy process.
  • Cache & Session modules.
  • Uliorm, which is an ORM module, was built on top of SqlAlchemy. I also referenced from GAE datastore module.
  • Framework runtime process.
  • Plugin mechanism, styled after the one used in the UliPad project.

Features

  • Project Organization

    • MVT(Model View Template) development model.
    • Distributed development but unified management. Uliweb organizes a project with small apps. Each app can have its own configuration file(settings.ini), template directory, and static directory. Existing apps can be easily reused, but are treated as a compound. web application project if configured as such. Developers can also reference static files and templates between apps, thus easing inter-application data exchange. All apps in a project are loaded by default if INSTALLED_APPS is not configured in the configuration file. All separate app configuration files are automatically processed at project startup.
  • URL Mapping

    • Flexiable and powerful URL mapping. Uliweb uses werkzeug's routing module. User can easily define a URL, which in turn can be easily bound with a view function. URLs can also be created reversely according to the view function name. It supports argument definitions in URLs and default URL mapping to a view function.
  • View and Template

    • View templates can be automatically applied. If you return a dict variable from view function, Uliweb will automatically try to match and apply a template according to the view function name.
    • Environment execution mode. Each view function will be run in an environment, which eliminates the need to write many import statements. Plus there are already many objects that can be used directly, for example: request, response, etc. This is DRY and saves a lot of coding
    • Developers can directly use Python code in a template, the Python code does not neede to be indented as long as a pass statement is added at the end of each code block. Uliweb also supports child template inclusion and inheritance.
  • ORM

    • Uliorm is based on SQLAlchemy package, so you can use Model layer and SQL expression layer both.
    • Uliorm integrates with alembic package, you can use it to migirate database automatically.
  • I18n

    • Can be used in python and template files.
    • Browser language and cookie settings are supported including automatic language switching.
    • Provides a command line tool that developers can use to extract .po files. This can happen either at the app level or project level process. It can automatically merge .pot files to existing .po files.
  • Extension

    • Dispatch extension. This is a dispatch processing mechanism that utilizes different types of dispatch points. So you can write procedures to carry out special processes and bind them to these dispatch points. For example, database initicalization, I18n process initialization, etc.
    • middleware extension. It's similar to Djangos. You can configure it in configuration files. Each middleware can process the request and response objets.
    • Special function calls in the views module initial process. If you write a special function named __begin__, it'll be processed before any view function can be processed, this allows developers to do some module level processing at that point, for example: check the user authentication, etc.
  • Command Line Tools

    • Creates project, creates apps, and include the basic essential directory structure, files and code.
    • Export static files, you can export all available apps' static files to a special directory. Also supports css and js combinition and compress process.
    • Startup a development web server thats supports debugging and autoreload.
    • Apps can also have its own command line tools. For example: orm, auth, etc.
  • Deployment

    • Supports mod_wsgi in Apache.
    • Supports uwsgi.
  • Development

    • Provide a development server, and can be automatically reload when some module files are modified.
    • Enhanced debugging, you can check the error traceback, template debugging is also supported.

Commuity

Links

LOGO

uliweb's People

Contributors

gitter-badger avatar limodou avatar zebozhuang avatar zhangchunlin avatar zhangclb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uliweb's Issues

_generate_etag will get exception with unicode filename which cannot encode by ascii

For example for the file path: u'/home/zhangclb/Dropbox/life/dudu/201804_\u7167\u7247/TIM\u56fe\u724720180428103333.jpg'
will get this kind of exception:

u'/home/zhangclb/Dropbox/life/dudu/201804_\u7167\u7247/TIM\u56fe\u724720180428103333.jpg'
Traceback (most recent call last):
  File "/home/zhangclb/oss/uliweb/uliweb/contrib/staticfiles/wsgi_staticfiles.py", line 91, in __call__
    return self.app(environ, start_response)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1505, in __call__
    response = self._open(environ)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1450, in _open
    response = self.call_view(mod, handler_cls, handler, req, res, kwargs=values)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 993, in call_view
    result = self.call_handler(handler, request, response, env, wrap, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1104, in call_handler
    result = self._call_function(handler, request, response, env, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1097, in _call_function
    result = handler(*args, **kwargs)
  File "/home/zhangclb/sandbox/mmscope/mmscope/apps/mmfile/views.py", line 77, in img_thumbnail
    return filedown(request.environ,filename=filename,real_filename=real_filename)
  File "/home/zhangclb/oss/uliweb/uliweb/utils/filedown.py", line 176, in filedown
    etag = _generate_etag(mtime, file_size, real_filename)
  File "/home/zhangclb/oss/uliweb/uliweb/utils/filedown.py", line 25, in _generate_etag
    adler32(real_filename) & 0xffffffff
UnicodeEncodeError: 'ascii' codec can't encode characters in position 40-41: ordinal not in range(128)127.0.0.1 - - [2018-05-22 18:02:37] "GET /mmfile/img_thumbnail?id=2 HTTP/1.1" 500 95120 0.354206

uliweb升级至0.1.4时日志异常

通过 git pull 更新了 uliweb 后 通过 python setup.py install 安装后,uliweb 的日志出现了一些异常(之前是0.1.3)

使用 uliweb runserver 启动项目,控制台只打印如下日志,而且打印了两次,如果是更新了代码 reload ,也只打印这样的信息(但是项目运行正常)

[INFO]  * Loading DebuggedApplication...
[INFO]  * Loading DebuggedApplication...

而且如果在 python 中

import uliweb
/usr/local/lib/python2.7/dist-packages/Uliweb-0.1.4-py2.7.egg/uliweb/utils/common.py:62: UserWarning: Module werkzeug was already imported from /usr/local/lib/python2.7/dist-packages/Uliweb-0.1.4-py2.7.egg/uliweb/lib/werkzeug/init.pyc, but /usr/local/lib/python2.7/dist-packages/Werkzeug-0.8.3-py2.7.egg is being added to sys.path
import pkg_resources as pkg

打印出这么一堆东西

Dump should support whole database

I'll want to add --project argument for uliweb dump and default it'll dump whole database. Now it'll only dump the application models but not whole database at all.

SoapView 生成 wsdl 的 location 错误

settings.ini

soap_weizhang = '/services/service/weizhang', 'services.views_weizhang.WeiZhangSo    apView.soap'                           

nginx conf

    location /rydata {
        include uwsgi_params;
        uwsgi_pass unix:///tmp/uwsgi-rydata.sock;
        uwsgi_param SCRIPT_NAME /rydata;
        uwsgi_modifier1 30;
    }

这样我访问页面是正常的 http://localhost:7000/rydata/services/somepage

但是调用service 方法就会报错 实际上方法请求的地址是 http://localhost:7000/services/service/weizhang ...

没有自动加上前缀 /rydata
而且只是请求 service 方法有问题,其它一切正常。

<wsdl:port binding="tns:RytechWeiZhangDataServiceBinding" name="RytechWeiZhangDataService">
<soap:address location="http://localhost:7000/services/service/weizhang"/>
</wsdl:port>

正确的应该是 http://localhost:7000/rydata/services/service/weizhang

try to use multiple database but get exception

settings:

[MODELS]
gerritsyncsession = 'gitfetchdata.models.GerritSyncSession', 'external'

Traceback (most recent call last):
  File "/home/zhangclb/oss/uliweb/uliweb/core/dispatch.py", line 112, in call
    _f(sender, *args, **kw)
  File "/home/zhangclb/oss/uliweb/uliweb/contrib/orm/__init__.py", line 63, in after_init_apps
    raise Exception("Model path should be a string but %r found" % model_path)
TypeError: not all arguments converted during string formatting

https://github.com/limodou/uliweb/blob/master/uliweb/contrib/orm/__init__.py#L62

So is there any problem with my settings?

Cannot set Form.errors['_']

In uliweb_apps.login.views.login:

            msg = form.errors.get('_', '') or _('Login failed!')

So I want to update form.errors with key '_' to change the error message, when I invoke like that

self.errors.update({"_":u"注册失败:用户已存在"})

in the validate_username() of a form, but I cannot get this error in the view, because the dict form.errors have been replace with a different one, refer uliweb/uliweb/form/uliform.py Form.validate()

        if errors:
            self.ok = False
            self.errors = errors
            self.data = new_data

I think if modify as below will fix the problem:

        if errors:
            self.ok = False
            self.errors.update(errors)
            self.data = new_data

默认配置中日志格式format_package错误

[LOG.Formatters] 
format_full = "[%(levelname)s %(name)s %(asctime)-15s %(filename)s,%(lineno)d] %(message)s"
format_simple = "[%(levelname)s] %(message)s"
format_package = "[%(levelname)s %(name)] %(message)s"

format_package%(name) 应为 %(name)s

mapping_only 设计为可以配置

现在 __mapping_only__ 是定义在Model上的,但是对于存在多个项目复用的情况时,如果数据库还是复用,就会存在不方便指定 __mapping_only__ 的情况。因此考虑在settings.ini的配置中増加可以修改此属性的配置机制。同时还要考虑以前的多数据库配置。

JSON类型的字段里不能存放中文

相关的log如下
前面打印出来的字段都是unicode的,但是最后保存入数据库的时候好像会转成utf8

u'2015-01-21 17:04:33 \u7684\u5c4f\u5e55\u622a\u56fe.png'
{u'upload_src_filename': u'2015-01-21 17:04:33 \u7684\u5c4f\u5e55\u622a\u56fe.png', u'upload_src_frelpath': 'upload_src/src_tar'}
Traceback (most recent call last):
  File "/home/zhangclb/oss/uliweb/uliweb/contrib/staticfiles/wsgi_staticfiles.py", line 91, in __call__
    return self.app(environ, start_response)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1485, in __call__
    response = self._open(environ)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1430, in _open
    response = self.call_view(mod, handler_cls, handler, req, res, kwargs=values)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 973, in call_view
    result = self.call_handler(handler, request, response, env, wrap, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1084, in call_handler
    result = self._call_function(handler, request, response, env, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1077, in _call_function
    result = handler(*args, **kwargs)
  File "/home/zhangclb/devel/oscport/apps/oscscan/views.py", line 119, in api_upload_src_tar
    upload_src_filename = self.project.save_src_tar(request.files)
  File "/home/zhangclb/devel/oscport/apps/oscscan/models.py", line 90, in save_src_tar
    self.save()
  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 4010, in save
    result = do_(self.table.update(_cond).values(**d), self.get_session())
  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 629, in do_
    result = conn.execute(query, *(args or ()))
  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 365, in execute
    return self.connection.execute(query, *args)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/base.py", line 720, in execute
    return meth(self, multiparams, params)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/sql/elements.py", line 317, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/base.py", line 817, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/base.py", line 947, in _execute_context
    context)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/base.py", line 1108, in _handle_dbapi_exception
    exc_info
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/util/compat.py", line 185, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/base.py", line 940, in _execute_context
    context)
  File "/home/zhangclb/oss/sqlalchemy/lib/sqlalchemy/engine/default.py", line 435, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. u'UPDATE oscproject SET src_code_params=? WHERE oscproject.id = ?' ('{"upload_src_filename":"2015-01-21 17:04:33 \xe7\x9a\x84\xe5\xb1\x8f\xe5\xb9\x95\xe6\x88\xaa\xe5\x9b\xbe.png","upload_src_frelpath":"upload_src/src_tar"}', 3)

Implement an async tasks process app

For some long running tasks, push them to async execution.

Just define common module level function or class with __call__ method, and call it like functions.async_call('path.to.function', *args, **kwargs) or functions.async_call(function, *args, **kwargs)

pysimplesoap未能正确映射 bool 类型

如果在 soap 的类型映射中,如果使用了 bool 类型,pysimple soap 无法将 python 原生的 bool 类型转换成 boolean 类型。

returns={ 'enabled': bool }
{ 'enabled': True }  # Got None

uliweb 中pysimplesoap 版本过低,pysimplesoap-1.05a,而此问题在此之后才得到修正,见 issue

orm autocreat bug

以官方文档为例:
非web项目中(直接python shell中执行就看到了)

from uliweb.orm import *

class User(Model):
    name = Field(unicode)

Model->ModelMetaclass->init()->cls.bind(auto_create=auto_create)。由于找不到数据库链接信息,出错。

AttributeError: 'instancemethod' object has no attribute '__rule_skip__'

在最新版本上的uliweb上,在settings里加上:

[EXPOSES]
index = '/tools/', 'cmdmap.views.CmdMap.index'

结果运行调试服务器报错:

...
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 634, in init
    self.install_exposes()
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1204, in install_exposes
    expose(args[0], name=name)(args[1])
  File "/home/zhangclb/oss/uliweb/uliweb/core/rules.py", line 357, in __call__
    self.parse(f)
  File "/home/zhangclb/oss/uliweb/uliweb/core/rules.py", line 198, in parse
    f.__rule_skip__ = False
AttributeError: 'instancemethod' object has no attribute '__rule_skip__'

我打印repo(f)的结果是

 <unbound method CmdMap.index>

如何定义 URL 映射 '/'

我为 app services 定义了 url 前缀

[URL]
services = '/services'

这样 services 下的所有 URL 都会自动加上前缀 /services

此时如何定义 / 这样不带 appname 的 url?

ManyToMany的索引増加对第二个字段的处理

目前对于ManyToMany的关系表,会自动建一个a_id, b_id的索引,结果按b_id来查找时,此索引无效,所以考虑増加对b_id创建索引。对于through的表,只有在选择属性时才会进行初始化,因此对于alembic,syncdb之类的操作无效,因此要考虑如何处理(考虑在orm app处理之后再进行扫描?)

Mysql 5.6, createsuperuser Incorrect datetime

这台环境是windows,
mysql 5.6.17

python 2.7.6 stackless
mysqldb 1.2.5 final
SQLAlchemy 0.9.8

报错如下:
cursor.execute(statement, parameters)
File "D:\Python27\lib\site-packages\MySQLdb\cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "D:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defau
lterrorhandler
raise errorclass, errorvalue
sqlalchemy.exc.OperationalError: (OperationalError) (1292, "Incorrect datetime v
alue: '2015-01-01 09:04:00.991000+00:00' for column 'date_join' at row 1") 'INSE
RT INTO user (username, nickname, email, password, is_superuser, date_join, imag
e, active, locked, weibo, blog, qq, description, sex) VALUES (%s, %s, %s, %s, %s
, %s, %s, %s, %s, %s, %s, %s, %s, %s)' ('fy', '', '123', 'sha1$bdc8a$b5493834a7c
5d1a99ed0bcb369663eed12aaf987', 0, datetime.datetime(2015, 1, 1, 9, 4, 0, 991000
, tzinfo=), '', 0, 0, '', '', '', u'', '')

Add #{appname} support in settings.ini

You can write something like this in values:

[MODELS]
user = '#{appname}.models.User'

If the current app is uliweb.contrib.auth, so above value will be converted to 'uliweb.contrib.auth.models.User'

uliweb/contrib/auth/models.py

运行总提示错误,修改:return get_href(self.image) 成:
functions.get_href 就好了。

    if self.image:
        return get_href(self.image)
    else:
        return functions.url_for_static('images/user%dx%d.jpg' % (50, 50))

执行 uliweb syncdb 显示 Unknown command: 'syncdb'

执行 uliweb syncdb

(global)..[liusenyuan@Coolbits-MacBook-Air] - [~/computer/python/uliweb_zc] - [Thu Mar 20, 11:01]                                      
..[$] <( (git)-[master]-)> uliweb syncdb
Unknown command: 'syncdb'
Type 'uliweb help' for usage.
Many commands will only run at project directory, maybe the directory is not right.

多SOAP时未能正确读取SOAP配置

if not __soap_dispatcher__:
            location = "%s://%s%s" % (
                request.environ['wsgi.url_scheme'],
                request.environ['HTTP_HOST'],
                request.path)
            namespace = functions.get_var('SOAP/namespace', location)
            documentation = functions.get_var('SOAP/documentation')
            dispatcher = SoapDispatcher(
                name = functions.get_var('SOAP/name'),
                location = location,
                action = '', # SOAPAction
                namespace = namespace,
                prefix=functions.get_var('SOAP/prefix'),
                documentation = documentation,
                exception_handler = partial(exception_handler, response=response),
                ns = True)

functions.get_var('SOAP/name') 永远读取的是 SOAP 下的配置,配置的其它SOAP,比如 SOAP_A 中的 namespace,prefix等配置无法正确读取。

Uliweb doesn't support oracle VARCHAR2

I use "uliweb reflectdb" on a oracle db, the file generate have this line:

from sqlalchemy.dialects.oracle import VARCHAR2

which is inserted by this source code: https://github.com/limodou/uliweb/blob/master/uliweb/contrib/orm/commands.py#L1237

But when I run "uliweb sql", it output error:

  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 4456, in bind
    c = f.create(cls)
  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 1659, in create
    f_type = self._create_type()
  File "/home/zhangclb/oss/uliweb/uliweb/orm/__init__.py", line 1878, in _create_type
    f_type = self.type_class(self.max_length, convert_unicode=True, **self.type_attrs)
TypeError: 'str' object is not callable

And I try to print self.type_class, it is "VARCHAR2"

at last I found the source code generated by reflectdb is like that:

    job_name = Field(str, max_length=250, nullable=False, index=True, type_class='VARCHAR2')

After modify to type_class=VARCHAR2 , it became OK

uliweb load raise UnboundLocalError

If run 'uliweb load'

[ERROR root 2015-12-23 16:39:08,755] There are something wrong when loading table [usbinfcommit]
Traceback (most recent call last):
  File "/home/zhangclb/oss/uliweb/uliweb/contrib/orm/commands.py", line 778, in handle
    _f(t, filename, msg)
UnboundLocalError: local variable 'msg' referenced before assignment

If run 'uliweb load -v', it will be OK

application.template and get SyntaxError exception

使用 application.template 的代码:

@expose('/')
def index():
    return application.template("test.html",vars={"test":"test"})

模板里面如果有

{{=print()}}

则会报错:

[ERROR [21944] root 2017-01-12 14:14:56,549 /home/zhangclb/oss/uliweb/uliweb/core/template.py,583] test.html code:
 1  def _tt_execute():  # test.html:0
 2      _tt_buffer = []  # test.html:0
 3      _tt_append = _tt_buffer.append  # test.html:0
 4      def _tt_write(t, escape=True):  # test.html:0
 5          if escape:  # test.html:0
 6              _tt_append(xhtml_escape(_tt_utf8(t)))  # test.html:0
 7          else:  # test.html:0
 8              _tt_append(_tt_utf8(t))  # test.html:0
 9              pass  # test.html:0
10          pass  # test.html:0
11      def out_write(value):  # test.html:0
12          _tt_append(_tt_utf8(value))  # test.html:0
13          pass  # test.html:0
14      _tt_tmp = escape(url_for("test.views.index"))  # test.html:1
15      if isinstance(_tt_tmp, _tt_string_types):  # test.html:1
16          _tt_tmp = _tt_utf8(_tt_tmp)  # test.html:1
17      else:  # test.html:1
18          _tt_tmp = _tt_utf8(str(_tt_tmp))  # test.html:1
19          pass  # test.html:1
20      _tt_append(_tt_tmp)  # test.html:1
21      _tt_append('\n<hr>\n')  # test.html:3
22      _tt_tmp = escape(locals())  # test.html:3
23      if isinstance(_tt_tmp, _tt_string_types):  # test.html:3
24          _tt_tmp = _tt_utf8(_tt_tmp)  # test.html:3
25      else:  # test.html:3
26          _tt_tmp = _tt_utf8(str(_tt_tmp))  # test.html:3
27          pass  # test.html:3
28      _tt_append(_tt_tmp)  # test.html:3
29      _tt_append('\n<hr>\n')  # test.html:5
30      _tt_tmp = escape(globals())  # test.html:5
31      if isinstance(_tt_tmp, _tt_string_types):  # test.html:5
32          _tt_tmp = _tt_utf8(_tt_tmp)  # test.html:5
33      else:  # test.html:5
34          _tt_tmp = _tt_utf8(str(_tt_tmp))  # test.html:5
35          pass  # test.html:5
36      _tt_append(_tt_tmp)  # test.html:5
37      _tt_append('\n<hr>\n')  # test.html:7
38      _tt_tmp = escape(print())  # test.html:7
39      if isinstance(_tt_tmp, _tt_string_types):  # test.html:7
40          _tt_tmp = _tt_utf8(_tt_tmp)  # test.html:7
41      else:  # test.html:7
42          _tt_tmp = _tt_utf8(str(_tt_tmp))  # test.html:7
43          pass  # test.html:7
44      _tt_append(_tt_tmp)  # test.html:7
45      return _tt_utf8('').join(_tt_buffer)  # test.html:0
Traceback (most recent call last):
  File "/home/zhangclb/oss/uliweb/uliweb/contrib/staticfiles/wsgi_staticfiles.py", line 91, in __call__
    return self.app(environ, start_response)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1505, in __call__
    response = self._open(environ)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1450, in _open
    response = self.call_view(mod, handler_cls, handler, req, res, kwargs=values)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 993, in call_view
    result = self.call_handler(handler, request, response, env, wrap, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1104, in call_handler
    result = self._call_function(handler, request, response, env, args, kwargs)
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 1097, in _call_function
    result = handler(*args, **kwargs)
  File "/home/zhangclb/sandbox/uliweb/test_template2/apps/test/views.py", line 6, in index
    return application.template("test.html",vars={"test":"test"})
  File "/home/zhangclb/oss/uliweb/uliweb/core/SimpleFrame.py", line 833, in template
    default_template=default_template)
  File "/home/zhangclb/oss/uliweb/uliweb/core/template.py", line 833, in load
    t = self._create_template(name, filename, layout=layout)
  File "/home/zhangclb/oss/uliweb/uliweb/core/template.py", line 914, in _create_template
    comment=self.comment)
  File "/home/zhangclb/oss/uliweb/uliweb/core/template.py", line 578, in __init__
    "exec", dont_inherit=True)
SyntaxError: invalid syntax (test.html, line 38)

test_template2.zip

There should be simple way to define multi database Model definition

In order to simplify the duplication of multi databases. For example, I can add parameter to connection definition, for example:

[ORM]
CONNECTIONS = {
    'test': {
        'CONNECTION':'mysql://root:limodou@localhost/test2?charset=utf8',
        'CONNECTION_TYPE':'short',
        'DUPLICATION':'default',
    }
}

'DUPLICATION':'default' means this connection will be duplication of default connection, so you don't need to config each Model to multi connection like that:

[MODELS_CONFIG]
user = {'engines':['default', 'test']}

For new style, you don't need to define like above any more, just define duplication of 'default', that's enough.

MySql中定义主键为自增长无效

Uliweb 0.1.7

class IPBlackList(Model):
    __tablename__ = 'svc_blacklist'

    id        = Field(int, primary_key=True, autoincrement=True)
    service   = Field(str, max_length=255)
    rule      = Field(str, max_length=255)
    stime     = Field(datetime.datetime)
    etime     = Field(datetime.datetime)

生成的 SQL

CREATE TABLE svc_blacklist (
    id INTEGER, 
    service VARCHAR(255), 
    rule VARCHAR(255), 
    stime DATETIME, 
    etime DATETIME, 
    PRIMARY KEY (id)
)

Javascript string issue because of string strip operation of uliweb template

example code below
in the line: ' ref="input"' ,if the space char removed, javascript will treat '[return]r' as '\r'

Can reproduce with this static file test.zip can run server with "python -mSimpleHTTPServer" in the directory

Vue.component('currency-input', {
  template: '\
    <span>\
      $\
      <input\
        ref="input"\
        v-bind:value="value"\
        v-on:input="updateValue($event.target.value)"\
      >\
    </span>\
  ',
  props: ['value'],
  methods: {
    // 不是直接更新值,而是使用此方法来对输入值进行格式化和位数限制
    updateValue: function (value) {
      var formattedValue = value
        // 删除两侧的空格符
        .trim()
        // 保留 2 位小数
        .slice(
          0,
          value.indexOf('.') === -1
            ? value.length
            : value.indexOf('.') + 3
        )
      // 如果值尚不合规,则手动覆盖为合规的值
      if (formattedValue !== value) {
        this.$refs.input.value = formattedValue
      }
      // 通过 input 事件带出数值
      this.$emit('input', Number(formattedValue))
    }
  }
})

开发时运行uliweb runserver错误

D:\projects\www\xxxxx>uliweb runserver
[INFO] * Loading DebuggedApplication...
[INFO] * Running on http://localhost:8000/
[INFO] * Restarting with reloader
c:\python27\python.exe: can't open file 'C:\Python27\Scripts\uliweb': [Errno 2] No such file or directory

无论是git clone源码安装还是pip安装都报上面的错误. 实际Scripts目录下是有uliweb.exe文件的.
makeproject,makeapp等命令都可以正常工作

配置多个SOAP时,如果禁用默认的SOAPVIEW

[EXPOSES]
soap1 = '/services/weizhang', 'services.views_weizhang.WeiZhangSoapView.soap'

[SOAP_WEIZHANG]
namespace = 'rytech.data.services.weizhang'
documentation = 'RongYiTech Data Web Service :: WeiZhang'
name = 'RytechWeiZhangDataService'
prefix = 'rys'

这是我的配置,但是事实上生成了两个 soap url

/SOAP uliweb.contrib.soap.views.SoapView.soap
/services/weizhang services.views_weizhang.WeiZhangSoapView.soap

有没有办法禁用/SOAP 这个默认的 SoapView

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.