bugfix
This commit is contained in:
parent
449dbb17ac
commit
e5d6fb4d15
17
README.md
17
README.md
@ -448,3 +448,20 @@ else it will raise HTTPException exception
|
|||||||
#### request['run_ns']
|
#### request['run_ns']
|
||||||
global environment now can access from request['run_ns'], it contains all the globals variable in ServerEnv and related variables of request
|
global environment now can access from request['run_ns'], it contains all the globals variable in ServerEnv and related variables of request
|
||||||
|
|
||||||
|
### 1.0.9
|
||||||
|
|
||||||
|
#### MySession class
|
||||||
|
add MySession class for script to get or set data to session
|
||||||
|
|
||||||
|
usage
|
||||||
|
|
||||||
|
```
|
||||||
|
s = MySession(request)
|
||||||
|
messages = s.messages
|
||||||
|
if not messages:
|
||||||
|
messages = []
|
||||||
|
messages.append("ergegrtgh")
|
||||||
|
s.messages = messages
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ from aiohttp.web import (
|
|||||||
)
|
)
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from aiohttp_session import get_session
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
@ -81,6 +82,12 @@ def server_error(errcode):
|
|||||||
E = exceptions.get(errcode, HTTPException)
|
E = exceptions.get(errcode, HTTPException)
|
||||||
raise E()
|
raise E()
|
||||||
|
|
||||||
|
class MySession(DictObject):
|
||||||
|
def __init__(self, request, **kw):
|
||||||
|
super().__init__(**kw)
|
||||||
|
self.request = request
|
||||||
|
self.update(get_session(request))
|
||||||
|
|
||||||
def basic_auth_headers(user, passwd):
|
def basic_auth_headers(user, passwd):
|
||||||
ba = BasicAuth(login=user, password=passwd)
|
ba = BasicAuth(login=user, password=passwd)
|
||||||
return {
|
return {
|
||||||
@ -311,6 +318,7 @@ def initEnv():
|
|||||||
g.partial = partial
|
g.partial = partial
|
||||||
g.StreamHttpClient = StreamHttpClient
|
g.StreamHttpClient = StreamHttpClient
|
||||||
g.server_error = server_error
|
g.server_error = server_error
|
||||||
|
g.MySession = MySession
|
||||||
|
|
||||||
def set_builtins():
|
def set_builtins():
|
||||||
all_builtins = [ i for i in dir(builtins) if not i.startswith('_')]
|
all_builtins = [ i for i in dir(builtins) if not i.startswith('_')]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user