-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
345 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[run] | ||
source = masonite | ||
|
||
[report] | ||
ignore_errors = True | ||
omit = | ||
*/tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ storage/compiled/ | |
uploads/test.jpg | ||
bootstrap/cache/*.html | ||
bootstrap/cache/*.txt | ||
/uploads/ | ||
/uploads/ | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# Masonite | ||
Core files for the python framework | ||
|
||
[![Build Status](https://travis-ci.org/MasoniteFramework/core.svg?branch=master)](https://travis-ci.org/MasoniteFramework/core) <img src="https://img.shields.io/badge/coverage-79%25-green.svg"> | ||
[![Build Status](https://travis-ci.org/MasoniteFramework/core.svg?branch=master)](https://travis-ci.org/MasoniteFramework/core) | ||
|
||
[![Coverage Status](https://coveralls.io/repos/github/MasoniteFramework/core/badge.svg?branch=master)](https://coveralls.io/github/MasoniteFramework/core?branch=master) | ||
|
||
To get started with this repo, [read the CONTRIBUTING.md file on the masonite repo](https://github.com/josephmancuso/masonite/blob/master/CONTRIBUTING.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
'ably': { | ||
'secret': os.getenv('ABLY_SECRET') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" | ||
Session configuration | ||
""" | ||
|
||
DRIVER = 'memory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ class BroadcastContract(ABC): | |
|
||
@abstractmethod | ||
def ssl(self): pass | ||
|
||
@abstractmethod | ||
def channel(self): pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
class QueueContract(ABC): | ||
|
||
@abstractmethod | ||
def push(self): pass | ||
def push(self): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class SessionContract(ABC): | ||
|
||
@abstractmethod | ||
def get(self): pass | ||
|
||
@abstractmethod | ||
def set(self): pass | ||
|
||
@abstractmethod | ||
def has(self): pass | ||
|
||
@abstractmethod | ||
def all(self): pass | ||
|
||
@abstractmethod | ||
def flash(self): pass | ||
|
||
@abstractmethod | ||
def reset(self): pass | ||
|
||
@abstractmethod | ||
def helper(self): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,3 @@ def store(self): pass | |
|
||
@abstractmethod | ||
def store_prepend(self): pass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import os | ||
|
||
from masonite.exceptions import FileTypeException | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from masonite.contracts.SessionContract import SessionContract | ||
|
||
|
||
class SessionCookieDriver(SessionContract): | ||
""" | ||
Session from the memory driver | ||
""" | ||
|
||
def __init__(self, Environ, Request): | ||
""" | ||
Constructor | ||
""" | ||
|
||
self.environ = Environ | ||
self.request = Request | ||
|
||
def get(self, key): | ||
""" | ||
Get a session from object _session | ||
""" | ||
|
||
cookie = self.request.get_cookie('s_{0}'.format(key)) | ||
if cookie: | ||
return cookie | ||
|
||
return None | ||
|
||
def set(self, key, value): | ||
""" | ||
Set a new session in object _session | ||
""" | ||
|
||
self.request.cookie('s_{0}'.format(key), value) | ||
|
||
def has(self, key): | ||
""" | ||
Check if a key exists in the session | ||
""" | ||
|
||
if self.get(key): | ||
return True | ||
return False | ||
|
||
def all(self): | ||
""" | ||
Get all session data | ||
""" | ||
|
||
return self.__collect_data() | ||
|
||
def __collect_data(self): | ||
""" | ||
Collect data from session and flash data | ||
""" | ||
|
||
cookies = {} | ||
if 'HTTP_COOKIE' in self.environ and self.environ['HTTP_COOKIE']: | ||
cookies_original = self.environ['HTTP_COOKIE'].split(';') | ||
for cookie in cookies_original: | ||
if cookie.startswith('s_'): | ||
data = cookie.split("=") | ||
cookie_value = self.request.get_cookie(data[0]) | ||
cookies[data[0][2:]] = cookie_value | ||
return cookies | ||
|
||
def flash(self, key, value): | ||
""" | ||
Add temporary data to the session | ||
""" | ||
|
||
self.request.cookie('s_{0}'.format(key), value, expires='2 seconds') | ||
|
||
def reset(self, flash_only=False): | ||
""" | ||
Reset object _session | ||
""" | ||
cookies = self.__collect_data() | ||
for cookie in cookies: | ||
self.request.delete_cookie('s_{0}'.format(cookie)) | ||
|
||
def helper(self): | ||
""" | ||
Used to create builtin helper function | ||
""" | ||
|
||
return self |
Oops, something went wrong.