Skip to content

Instantly share code, notes, and snippets.

View silenius's full-sized avatar
🤘

Julien Cigar silenius

🤘
View GitHub Profile
SELECT
content.id AS content_id,
content.content_type_id AS content_content_type_id,
content.container_id AS content_container_id,
document.content_id AS document_content_id,
document.some_doc_col AS document_some_doc_col,
document_translation.language_id AS document_transl ation_language_id,
content_translation.language_id AS content_translation_language_id,
document_translation.content_id AS document_translation_content_id,
content_translation.content_id AS content_translation_content_id,
SELECT content.id AS content_id, content.added AS content_added, content.updated AS content_updated, content.effective AS content_effective, content.expiration AS content_expiration, content.exclude_nav AS content_exclude_nav, content.inherits_parent_acl AS content_inherits_parent_acl, content.weight AS content_weight, content.is_fts AS content_is_fts, content.props AS content_props, content.content_type_id AS content_content_type_id, content.owner_id AS content_owner_id, content.state_id AS content_state_id, content.container_id AS content_container_id, document.content_id AS document_content_id, account_1.id AS account_1_id, account_1.login AS account_1_login, account_1.password AS account_1_password, account_1.first_name AS account_1_first_name, account_1.last_name AS account_1_last_name, account_1.email AS account_1_email, account_1.created AS account_1_created, account_1.enabled AS account_1_enabled, account_1.lost_token AS account_1_lost_token, state_1.id AS state_1_id, state_1.name AS state_1_name, sta
import logging
from sqlalchemy import orm
from sqlalchemy import sql
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.hybrid import hybrid_property
@view_config(request_method='GET', name='children',
accept='application/json')
def children(self):
schema = FolderSchema(only=('id', 'title'))
depth = None
class Encoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Folder):
return schema.dump(obj)
julien@x1:~/ > python3.7 -m venv foo
julien@x1:~/ > source foo/bin/activate
(foo) julien@x1:~/ > pip install setuptools==44.1.0 Collecting setuptools==44.1.0 Using cached setuptools-44.1.0-py2.py3-none-any.whl (583 kB) Installing collected packages: setuptools
@view_config(request_method='GET', renderer='json',
name='hierarchy', accept='application/json')
def hierarchy(self):
schema = FolderSchema(only=('id', 'title'))
class Encoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Folder):
return schema.dump(obj)
return super().default(obj)
(...)
tabs = dbsession.query(
Folder
).join(
root, root.c.id == Folder.id
).add_columns(
root.c.level.label('level')
).order_by(
root.c.container_id, root.c.level.desc(), root.c.weight.desc()
@silenius
silenius / foo.py
Last active February 25, 2021 12:01
@view_config(request_method='GET', renderer='string',
name='hierarchy', accept='application/json')
def hierarchy(self):
from amnesia.modules.folder import Folder
from amnesia.modules.folder.services import get_children
from amnesia.modules.folder.validation import FolderSchema
from pyramid.renderers import JSON
from pyramid.response import Response
schema = FolderSchema(only=('id', 'title'))
@silenius
silenius / ckan.sh
Last active February 12, 2021 16:03
julien@x1:~/ > python3.7 -m venv ckan
julien@x1:~/ > source ckan/bin/activate
(ckan) julien@x1:~/ > python --version
Python 3.7.9
(ckan) julien@x1:~/ > pip install setuptools==44.1.0
Collecting setuptools==44.1.0
Downloading setuptools-44.1.0-py2.py3-none-any.whl (583 kB)
|████████████████████████████████| 583 kB 7.0 MB/s
fw1 {
vnet;
vnet.interface = "epair0b";
vnet.interface += "epair1b";
vnet.interface += "epair2b";
devfs_ruleset = "501";
#allow.raw_sockets = "1";
#allow.chflags = "1";
exec.prestart += "ifconfig epair0 create up";