repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
eve | tests/endpoints.py | .py | # -*- coding: utf-8 -*-
import os
from datetime import datetime
from uuid import UUID
import pytest
import simplejson as json
from werkzeug.routing import BaseConverter
from eve import Eve
from eve.io.base import BaseJSONEncoder
from eve.io.mongo import Validator
from eve.utils import config
from . import TestBase, ... | 367 | 13,439 |
eve | tests/config.py | .py | # -*- coding: utf-8 -*-
import os
import eve
from eve.exceptions import ConfigException, SchemaException
from eve.flaskapp import Eve, RegexConverter
from eve.io.base import DataLayer
from eve.io.mongo import Mongo, Validator
from . import TestBase
from .test_settings import MONGO_HOST, MONGO_PORT
class TestConfig... | 560 | 23,122 |
eve | tests/versioning.py | .py | # -*- coding: utf-8 -*-
import copy
import time
from bson import ObjectId
from eve import ETAG, STATUS, STATUS_OK
from . import TestBase
from .test_settings import MONGO_DBNAME
from .utils import DummyEvent
class TestVersioningBase(TestBase):
def setUp(self):
self.versioned_field = "ref"
self.... | 1,509 | 59,445 |
eve | tests/response.py | .py | # -*- coding: utf-8 -*-
import os
from ast import literal_eval
import simplejson as json
import eve
from . import TestBase
class TestResponse(TestBase):
def setUp(self):
super().setUp()
self.r = self.test_client.get("/%s/" % self.empty_resource)
def test_response_data(self):
respo... | 110 | 4,073 |
eve | tests/suite_generator.py | .py | from datetime import datetime
class EmbeddedDoc:
def __init__(self, _id):
self._id = _id
self._created = datetime.utcnow()
| 8 | 145 |
eve | tests/test_io/media.py | .py | import base64
from io import BytesIO
from unittest import TestCase
from bson import ObjectId
from eve import ETAG, ISSUES, STATUS, STATUS_ERR, STATUS_OK
from eve.io.media import MediaStorage
from eve.io.mongo import GridFSMediaStorage
from tests import MONGO_DBNAME, TestBase
class TestMediaStorage(TestCase):
de... | 506 | 19,486 |
eve | tests/test_io/flask_pymongo.py | .py | import pytest
from pymongo import MongoClient
from pymongo.errors import OperationFailure
from eve.io.mongo.flask_pymongo import PyMongo
from tests import TestBase
from tests.test_settings import (
MONGO1_DBNAME,
MONGO1_PASSWORD,
MONGO1_USERNAME,
MONGO_HOST,
MONGO_PORT,
)
class TestPyMongo(TestBa... | 84 | 2,843 |
eve | tests/test_io/multi_mongo.py | .py | # -*- coding: utf-8 -*-
from datetime import datetime
import pytest
import simplejson as json
from bson import ObjectId
from pymongo import MongoClient
from pymongo.errors import OperationFailure
import eve
from eve.auth import BasicAuth
from tests import TestBase
from tests.test_settings import (
MONGO1_DBNAME,
... | 266 | 9,668 |
eve | tests/test_io/mongo.py | .py | # -*- coding: utf-8 -*-
from datetime import datetime
from unittest import TestCase
import simplejson as json
from bson import ObjectId, decimal128
from bson.dbref import DBRef
from cerberus import SchemaError
from eve.io.mongo import Mongo, MongoJSONEncoder, Validator
from eve.io.mongo.parser import ParseError, pars... | 485 | 16,744 |
eve | tests/methods/delete.py | .py | import copy
import simplejson as json
from bson import ObjectId
from eve import ETAG
from eve.methods.delete import deleteitem_internal
from eve.utils import ParsedRequest
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestDelete(TestBase):
def s... | 837 | 33,374 |
eve | tests/methods/post.py | .py | from base64 import b64decode
from io import BytesIO
import simplejson as json
from bson import ObjectId
from werkzeug.datastructures import MultiDict
from eve import DATE_CREATED, ETAG, ISSUES, LAST_UPDATED, STATUS, STATUS_OK
from eve.methods.post import post, post_internal
from eve.utils import str_type
from tests i... | 1,210 | 48,922 |
eve | tests/methods/patch_atomic_concurrency.py | .py | import sys
import simplejson as json
import eve.methods.common
from eve.utils import config
from tests import TestBase
"""
Atomic Concurrency Checks
Prior to commit 54fd697 from 2016-November, ETags would be verified
twice during a patch. One ETag check would be non-atomic by Eve,
then again atomically by MongoDB ... | 77 | 2,583 |
eve | tests/methods/patch.py | .py | import simplejson as json
from bson import ObjectId
from pymongo import ReadPreference
from eve import ETAG, ISSUES, LAST_UPDATED, STATUS, STATUS_OK
from eve.methods.patch import patch_internal
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestPatch(... | 941 | 36,607 |
eve | tests/methods/common.py | .py | import time
from collections import OrderedDict # noqa
from datetime import datetime
from random import shuffle
import simplejson as json
from bson import ObjectId, decimal128
from bson.dbref import DBRef
from eve.methods.common import normalize_dotted_fields, serialize, sort_per_resource
from eve.utils import confi... | 776 | 29,165 |
eve | tests/methods/get.py | .py | import base64
import time
from datetime import datetime, timedelta
from io import BytesIO
import simplejson as json
from bson import ObjectId
from bson.dbref import DBRef
from bson.son import SON
from werkzeug.datastructures import ImmutableMultiDict, MultiDict
from eve.methods.get import get_internal, getitem_intern... | 2,445 | 98,080 |
eve | tests/methods/put.py | .py | import simplejson as json
from bson import ObjectId
from bson.dbref import DBRef
from eve import ETAG, ISSUES, LAST_UPDATED, STATUS, STATUS_OK
from eve.methods.put import put_internal
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestPut(TestBase):
... | 684 | 27,021 |
eve | tests/methods/ratelimit.py | .py | import time
from tests import TestBase
class TestRateLimit(TestBase):
def setUp(self):
super().setUp()
try:
from redis import ConnectionError, Redis
self.app.redis = Redis()
try:
self.app.redis.flushdb()
except ConnectionError:
... | 69 | 2,271 |
eve | eve/default_settings.py | .py | # -*- coding: utf-8 -*-
"""
eve.settings
~~~~~~~~~~~~
Default API settings. These can be overridden by editing this file or, more
appropriately, by using a custom settings module (see the optional
'settings' argument or the EVE_SETTING environment variable).
:copyright: (c) 2017 by Nicola Iar... | 280 | 9,793 |
eve | eve/logging.py | .py | from __future__ import absolute_import
import logging
from flask import request
# TODO right now we are only logging exceptions. We should probably
# add support for some INFO and maybe DEBUG level logging (like, log each time
# a endpoint is hit, etc.)
class RequestFilter(logging.Filter):
"""Adds Flask's requ... | 49 | 1,325 |
eve | eve/render.py | .py | # -*- coding: utf-8 -*-
"""
eve.render
~~~~~~~~~~
Implements proper, automated rendering for Eve responses.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import datetime
import re
import time
from collections import OrderedDict # noqa
from functools im... | 566 | 18,530 |
eve | eve/utils.py | .py | # -*- coding: utf-8 -*-
"""
eve.utils
~~~~~~~~~
Utility functions and classes.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import hashlib
import sys
from copy import deepcopy
from datetime import datetime, timedelta
from importlib import import_module... | 571 | 19,308 |
eve | eve/exceptions.py | .py | # -*- coding: utf-8 -*-
"""
eve.exceptions
~~~~~~~~~~~~~~
This module implements Eve custom exceptions.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
class ConfigException(Exception):
"""Raised when errors are found in the configuration settings (u... | 26 | 485 |
eve | eve/__init__.py | .py | # -*- coding: utf-8 -*-
"""
Eve
~~~
An out-of-the-box REST Web API that's as dangerous as you want it to be.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
.. versionchanged:: 0.5
'SERVER_NAME' removed.
'QUERY_WHERE' added.
'QUERY_SO... | 90 | 2,044 |
eve | eve/auth.py | .py | # -*- coding: utf-8 -*-
"""
eve.auth
~~~~~~~~
Allow API endpoints to be secured via BasicAuth and derivates.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from functools import wraps
from flask import abort
from flask import current_app as app
from flas... | 331 | 11,761 |
eve | eve/endpoints.py | .py | # -*- coding: utf-8 -*-
"""
eve.endpoints
~~~~~~~~~~~~~
This module implements the API endpoints. Each endpoint (resource, item,
home) invokes the appropriate method handler, returning its response
to the client, properly rendered.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, se... | 294 | 8,669 |
eve | eve/flaskapp.py | .py | # -*- coding: utf-8 -*-
"""
eve.flaskapp
~~~~~~~~~~~~
This module implements the central WSGI application object as a Flask
subclass.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import copy
import fnmatch
import os
import sys
import warnings
from ty... | 1,118 | 42,796 |
eve | eve/versioning.py | .py | from flask import abort
from flask import current_app as app
from werkzeug.exceptions import BadRequestKeyError
from eve.utils import ParsedRequest, config, debug_error_message
def versioned_id_field(resource_settings):
"""Shorthand to add two commonly added versioning parameters.
.. versionadded: 0.4
"... | 408 | 15,287 |
eve | eve/validation.py | .py | # -*- coding: utf-8 -*-
"""
eve.validation
~~~~~~~~~~~~~~
Helper module. Allows eve submodules (methods.patch/post) to be fully
datalayer-agnostic. Specialized Validator classes are implemented in the
datalayer submodules.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE... | 178 | 6,430 |
eve | eve/methods/delete.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.delete
~~~~~~~~~~~~~~~~~~
This module implements the DELETE method.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import copy
from flask import abort
from flask import current_app as app
from eve.auth import req... | 258 | 9,400 |
eve | eve/methods/post.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.post
~~~~~~~~~~~~~~~~
This module implements the POST method, supported by the resources
endpoints.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from cerberus.validator import DocumentError
from flask import ... | 310 | 11,479 |
eve | eve/methods/__init__.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods
~~~~~~~~~~~
This package implements the HTTP methods supported by Eve.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from eve.methods.delete import delete, deleteitem
# flake8: noqa
from eve.methods.get import get... | 19 | 432 |
eve | eve/methods/patch.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.patch
~~~~~~~~~~~~~~~~~
This module implements the PATCH method.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from copy import deepcopy
from cerberus.validator import DocumentError
from flask import abort
from f... | 289 | 10,530 |
eve | eve/methods/common.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.common
~~~~~~~~~~~~~~~~~~
Utility functions for API methods implementations.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import base64
import re
import time
from collections import Counter
from copy import copy
f... | 1,535 | 57,271 |
eve | eve/methods/get.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.get
~~~~~~~~~~~~~~~
This module implements the API 'GET' methods, supported by both the
resources and single item endpoints.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from __future__ import division
import... | 704 | 24,994 |
eve | eve/methods/put.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.put
~~~~~~~~~~~~~~~
This module implements the PUT method.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from cerberus.validator import DocumentError
from flask import abort
from flask import current_app as app
fr... | 251 | 10,057 |
eve | eve/io/media.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.media
~~~~~~~~~~~~
Media storage for Eve-powered APIs.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
class MediaStorage():
"""The MediaStorage class provides a standardized API for storing files,
along with a ... | 63 | 2,255 |
eve | eve/io/__init__.py | .py | # -*- coding: utf-8 -*-
"""
eve.io
~~~~~~
This package implements the data layers supported by Eve.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
# flake8: noqa
from eve.io.base import ConnectionException, DataLayer
| 15 | 283 |
eve | eve/io/base.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.base
~~~~~~~~~~~
Standard interface implemented by Eve data layers.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import datetime
from copy import copy
import simplejson as json
from flask import abort, request
from e... | 540 | 21,576 |
eve | eve/io/mongo/geo.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.geo
~~~~~~~~~~~~~~~~~~~
Geospatial functions and classes for mongo IO layer
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from eve.utils import config
class GeoJSON(dict):
def __init__(self, json):
t... | 148 | 4,154 |
eve | eve/io/mongo/parser.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.parser
~~~~~~~~~~~~~~~~~~~
This module implements a Python-to-Mongo syntax parser. Allows the MongoDB
data-layer to seamlessly respond to a Python-like query.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
imp... | 156 | 4,452 |
eve | eve/io/mongo/media.py | .py | """
eve.io.mongo.media
~~~~~~~~~~~~~~~~~~
GridFS media storage for Eve-powered APIs.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from bson import ObjectId
from flask import Flask
from gridfs import GridFS
from eve.io.media import MediaStorage
from eve.... | 106 | 3,304 |
eve | eve/io/mongo/flask_pymongo.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.flask_pymongo
~~~~~~~~~~~~~~~~~~~
Flask extension to create Mongo connection and database based on
configuration.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from bson import UuidRepresentation
from flask im... | 136 | 4,962 |
eve | eve/io/mongo/__init__.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo
~~~~~~~~~~~~
This package implements the MongoDB data layer.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
# flake8: noqa
from eve.io.mongo.mongo import Mongo, MongoJSONEncoder, ensure_mongo_indexes
from eve.io.m... | 17 | 403 |
eve | eve/io/mongo/mongo.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.mongo (eve.io.mongo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The actual implementation of the MongoDB data layer.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import ast
import decimal
import itertools
from collections ... | 1,182 | 42,804 |
eve | eve/io/mongo/validation.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.validation
~~~~~~~~~~~~~~~~~~~~~~~
This module implements the mongo Validator class, used to validate that
objects incoming via POST/PATCH requests conform to the API domain.
An extension of Cerberus Validator.
:copyright: (c) 2017 by Nicola Iarocci.
... | 301 | 10,949 |
eve | examples/notifications_settings.py | .py | # -*- coding: utf-8 -*-
SETTINGS = {"DEBUG": True, "DOMAIN": {"test": {}}}
| 3 | 75 |
eve | examples/notifications.py | .py | # -*- coding: utf-8 -*-
from __future__ import print_function
"""
Custom event notifications
~~~~~~~~~~~~~~~~~~~~~~~~~~
Flask supports callback functions via decorators such as
`before_request` and `after_request`. Being a subclass of Flask, Eve
supports this mechanism too, and it's pretty darn po... | 45 | 1,244 |
eve | examples/security/hmac.py | .py | # -*- coding: utf-8 -*-
"""
Auth-HMAC
~~~~~~~~~
Securing an Eve-powered API with HMAC based Authentication.
The ``eve.auth.HMACAuth`` class allows for custom Amazon S3-like
authentication, which is basically a very secure custom authentication
scheme built around the `Authorization` header.
... | 76 | 2,865 |
eve | examples/security/bcrypt.py | .py | # -*- coding: utf-8 -*-
"""
Auth-BCrypt
~~~~~~~~~~~
Securing an Eve-powered API with Basic Authentication (RFC2617).
This script assumes that user accounts are stored in a MongoDB collection
('accounts'), and that passwords are stored as BCrypt hashes. All API
resources/methods will be secure... | 44 | 1,330 |
eve | examples/security/token.py | .py | # -*- coding: utf-8 -*-
"""
Auth-Token
~~~~~~~~~~
Securing an Eve-powered API with Token based Authentication.
Token based authentication can be considered a specialized version of Basic
Authentication. The Authorization header tag will contain the auth token.
This script assumes that user a... | 44 | 1,481 |
eve | examples/security/roles.py | .py | # -*- coding: utf-8 -*-
"""
Auth-SHA1/HMAC-Roles
~~~~~~~~~~~~~~~~~~~~
Securing an Eve-powered API with Basic Authentication (RFC2617) and user
roles.
This script assumes that user accounts are stored in an 'accounts' MongoDB
collection, that passwords are stored as SHA1/HMAC hashes and that u... | 48 | 1,635 |
eve | examples/security/sha1-hmac.py | .py | # -*- coding: utf-8 -*-
"""
Auth-SHA1/HMAC
~~~~~~~~~~~~~~
Securing an Eve-powered API with Basic Authentication (RFC2617).
This script assumes that user accounts are stored in a MongoDB collection
('accounts'), and that passwords are stored as SHA1/HMAC hashes. All API
resources/methods will ... | 42 | 1,378 |
eve | examples/security/settings_security.py | .py | # -*- coding: utf-8 -*-
SETTINGS = {
"DEBUG": True,
"MONGO_HOST": "localhost",
"MONGO_PORT": 27017,
"MONGO_DBNAME": "test_db",
"DOMAIN": {
"accounts": {
"username": {"type": "string", "minlength": 5, "maxlength": 20},
"password": {"type": "string", "minlength": 5, "m... | 18 | 584 |
django-cms | manage.py | .py | #!/usr/bin/env python
import os
import sys
import warnings
from cms.exceptions import DontUsePageAttributeWarning
warnings.filterwarnings("ignore", category=DontUsePageAttributeWarning)
def consume_option(argv, name):
"""Pop ``--name value`` from ``argv`` and return the value (or ``None``)."""
if name in ar... | 66 | 1,779 |
django-cms | setup.py | .py | #!/usr/bin/env python
from setuptools import setup
setup()
| 5 | 60 |
django-cms | testserver.py | .py | #!/usr/bin/env python
import os
import sys
import tempfile
import warnings
import dj_database_url
from cms.exceptions import DontUsePageAttributeWarning
def gettext(s):
return s
warnings.filterwarnings("ignore", category=DontUsePageAttributeWarning)
permission = True
port = 8000
for arg in sys.argv:
if ... | 315 | 11,532 |
django-cms | docs/django_settings.py | .py | import os
from pathlib import Path
BASE_DIR = Path(__file__).resolve()
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.staticfiles',
'django.contrib.messages',
'treebeard... | 57 | 1,665 |
django-cms | docs/_ext/djangocms.py | .py | def setup(app):
app.add_crossref_type(
directivename = "setting",
rolename = "setting",
indextemplate = "pair: %s; setting",
)
app.add_crossref_type(
directivename = "templatetag",
rolename = "ttag",
indextemplate = "pair: %s; template tag"
)
| 12 | 317 |
django-cms | cms/toolbar_base.py | .py | from django.forms import MediaDefiningClass
from cms.exceptions import LanguageError
from cms.utils import get_current_site, get_language_from_request
from cms.utils.i18n import get_language_code
class CMSToolbar(metaclass=MediaDefiningClass):
supported_apps = None
def __init__(self, request, toolbar, is_cu... | 40 | 1,227 |
django-cms | cms/plugin_base.py | .py | import fnmatch
import json
import re
from collections.abc import Callable
from functools import lru_cache
from django import forms
from django.contrib import admin, messages
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, ValidationError
from django.http import HttpRequest, HttpResponse
fr... | 932 | 40,045 |
django-cms | cms/context_processors.py | .py | from functools import cache
from django.utils.functional import lazy
from cms.utils.conf import get_cms_setting
from cms.utils.page import get_page_template_from_request
def cms_settings(request):
"""
Adds cms-related variables to the context.
"""
from menus.menu_pool import MenuRenderer
@cache... | 32 | 969 |
django-cms | cms/exceptions.py | .py | class PluginAlreadyRegistered(Exception):
pass
class PluginNotRegistered(Exception):
pass
class PluginLimitReached(Exception):
"""Gets triggered when a placeholder has reached its plugin limit."""
pass
class AppAlreadyRegistered(Exception):
pass
class ToolbarAlreadyRegistered(Exception):
... | 86 | 1,311 |
django-cms | cms/cms_toolbars.py | .py | from django.conf import settings
from django.contrib import admin
from django.contrib.auth import get_permission_codename, get_user_model
from django.contrib.auth.models import AnonymousUser
from django.contrib.sites.models import Site
from django.urls import NoReverseMatch, Resolver404, resolve, reverse
from django.ut... | 735 | 30,101 |
django-cms | cms/cms_wizards.py | .py | from django.utils.translation import gettext_lazy as _
from cms.models import Page
from cms.utils.page_permissions import user_can_add_page, user_can_add_subpage
from .forms.wizards import CreateCMSPageForm, CreateCMSSubPageForm
from .wizards.wizard_base import Wizard
class CMSPageWizard(Wizard):
def user_has_... | 57 | 1,910 |
django-cms | cms/apps.py | .py | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class CMSConfig(AppConfig):
name = 'cms'
verbose_name = _("django CMS")
default_auto_field = 'django.db.models.AutoField'
def ready(self):
from cms.utils.setup import setup, setup_cms_apps
setup(... | 15 | 347 |
django-cms | cms/plugin_processors.py | .py | from django.utils.safestring import mark_safe
def plugin_meta_context_processor(instance, placeholder, context):
return {
'plugin': {
'counter': instance._render_meta.index + 1,
'counter0': instance._render_meta.index,
'revcounter': instance._render_meta.total - instanc... | 22 | 883 |
django-cms | cms/plugin_pool.py | .py | import fnmatch
from collections import defaultdict
from functools import lru_cache
from operator import attrgetter
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.template import TemplateDoesNotExist, TemplateSyntaxError
from django.template.defaultfilters import slugif... | 408 | 17,965 |
django-cms | cms/app_registration.py | .py | import inspect
from functools import cache
from importlib import import_module
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import module_has_submodule
from cms.app_base import CMSAppConfig, CMSAppExtension
from cms.constants import CMS_CONFIG_N... | 204 | 8,214 |
django-cms | cms/__main__.py | .py | """
Invokes djangocms when the cms module is run as a script.
Example: python -m cms mysite
"""
from cms.management import djangocms
if __name__ == "__main__":
djangocms.execute_from_command_line()
| 10 | 204 |
django-cms | cms/app_base.py | .py | from abc import ABCMeta, abstractmethod
class CMSApp:
"""Base class for creating apphooks. Apphooks live in a file called ``cms_apps.py``.
To create an AppHook subclass ``CMSApp`` in ``cms_apps.py``
::
class MyAppHook(CMSApp):
name = "Problem solver"
"""
#: list of urlconfs: ex... | 260 | 9,715 |
django-cms | cms/constants.py | .py | """
Collection of important constants used throughout django CMS.
"""
#: The token used to identify when a user selects "inherit" as template for a page.
TEMPLATE_INHERITANCE_MAGIC = 'INHERIT'
REFRESH_PAGE = 'REFRESH_PAGE'
"""
Supplied to ``on_close`` arguments to refresh the current page when the frame is closed, f... | 91 | 2,729 |
django-cms | cms/cms_config.py | .py | from collections.abc import Iterable
from functools import cached_property
from logging import getLogger
from django.core.exceptions import ImproperlyConfigured
from cms.app_base import CMSAppConfig, CMSAppExtension
from cms.cms_wizards import cms_page_wizard, cms_subpage_wizard
from cms.models import PageContent
fro... | 88 | 3,652 |
django-cms | cms/views.py | .py | from urllib.parse import quote, urlsplit, urlunsplit
from django.apps import apps
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login
from django.contrib.auth.views import redirect_to_login
from django.contrib.contenttypes.models import ContentType
from django.core... | 436 | 18,521 |
django-cms | cms/cms_menus.py | .py | import re
from collections import defaultdict
from collections.abc import Generator, Iterable
from django.utils.functional import SimpleLazyObject
from cms import constants
from cms.apphook_pool import apphook_pool
from cms.models import Page, PageContent, PagePermission, PageUrl
from cms.toolbar.utils import get_obj... | 527 | 22,460 |
django-cms | cms/urls.py | .py |
from django.conf import settings
from django.urls import URLResolver, include, path, re_path
from django.urls.resolvers import RegexPattern
from django.utils.functional import cached_property
from cms import views
from cms.constants import SLUG_REGEXP
if settings.APPEND_SLASH:
regexp = r'^(?P<slug>%s)/$' % SLUG_... | 53 | 1,592 |
django-cms | cms/toolbar_pool.py | .py | from collections import OrderedDict
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import autodiscover_modules, import_string
from cms.exceptions import ToolbarAlreadyRegistered, ToolbarNotRegistered
from cms.utils.conf import get_cms_setting
class ToolbarPool:
def __in... | 66 | 2,208 |
django-cms | cms/apphook_pool.py | .py | import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import autodiscover_modules, import_string
from django.utils.translation import gettext as _
from cms.app_base import CMSApp
from cms.exceptions import AppAlreadyRegistered
from cms.utils.conf import get_cms_setti... | 103 | 3,040 |
django-cms | cms/page_rendering.py | .py | from django.conf import settings
from django.http import Http404, HttpResponseRedirect
from django.template.response import TemplateResponse
from django.urls import Resolver404, resolve, reverse
from cms import __version__, constants
from cms.cache.page import set_page_cache
from cms.models import EmptyPageContent
fro... | 99 | 3,664 |
django-cms | cms/cms_plugins.py | .py | from django.utils.translation import gettext_lazy as _
from cms.models.placeholderpluginmodel import PlaceholderReference
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
class PlaceholderPlugin(CMSPluginBase):
name = _("Placeholder")
parent_classes = ['0'] # so you will not... | 20 | 530 |
django-cms | cms/plugin_rendering.py | .py | import contextlib
import logging
import sys
from collections import OrderedDict
from collections.abc import Generator
from functools import partial
from typing import Any
from classytags.utils import flatten_context
from django.conf import settings
from django.contrib.sites.models import Site
from django.db import mod... | 799 | 31,315 |
django-cms | cms/api.py | .py | """
Python APIs for creating CMS content. This is done in :mod:`cms.api` and not
on the models and managers, because the direct API via models and managers is
slightly counterintuitive for developers.
The api for both Pages and Plugins has changed significantly since django CMS
Version 4.
Also, the functions defined ... | 729 | 26,845 |
django-cms | cms/templates.py | .py | from django.template.loader import get_template
from django.utils.functional import cached_property
class TemplatesCache:
def __init__(self):
self._cached_templates = {}
def get_cached_template(self, template):
# we check if template quacks like a Template, as generic Template and engine-spe... | 32 | 1,039 |
django-cms | cms/menu_bases.py | .py | from django.core.exceptions import ValidationError
from django.db.models import Q
from cms.apphook_pool import apphook_pool
from cms.models import Page
from menus.base import Menu
class CMSAttachMenu(Menu):
"""Base class that can be subclassed to allow your app to attach its own menus."""
cms_enabled = True
... | 52 | 1,627 |
django-cms | cms/appresolver.py | .py | from collections import OrderedDict
from importlib import import_module
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.db import OperationalError, ProgrammingError
from django.urls import NoReverseMatch, Resolver404, URLResolver, reverse
from django.url... | 291 | 10,990 |
django-cms | cms/management/djangocms.py | .py | import os
import sys
from django.core.management import load_command_class
def execute_from_command_line(argv=None):
"""Run the startcmsproject management command."""
# Prepare arguments
argv = argv or sys.argv[:]
argv[0] = os.path.basename(argv[0])
if argv[0] == "__main__.py":
argv[0] =... | 25 | 697 |
django-cms | cms/management/commands/cms.py | .py | from collections import OrderedDict
import cms
from .subcommands.base import SubcommandsCommand
from .subcommands.check import CheckInstallation
from .subcommands.copy import CopyCommand
from .subcommands.delete_orphaned_plugins import DeleteOrphanedPluginsCommand
from .subcommands.list import ListCommand
from .subco... | 34 | 1,084 |
django-cms | cms/management/commands/startcmsproject.py | .py | #!/usr/bin/env python
import argparse
import difflib
import io
import json
import os
import re
import shlex
import shutil
import subprocess
import sys
import tarfile
import urllib.error
import urllib.request
import zipfile
from django.core.checks.security.base import SECRET_KEY_INSECURE_PREFIX
from django.core.managem... | 1,293 | 60,676 |
django-cms | cms/management/commands/subcommands/copy.py | .py | from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.core.management import CommandError
from django.db import transaction
from cms.api import copy_plugins_to_language
from cms.management.commands.subcommands.base import SubcommandsCommand
from cms.models import Empty... | 203 | 8,832 |
django-cms | cms/management/commands/subcommands/uninstall.py | .py | from django.core.management.base import LabelCommand
from cms.models import Page
from cms.models.pluginmodel import CMSPlugin
from .base import SubcommandsCommand
class UninstallApphooksCommand(LabelCommand):
args = 'APPHOK_NAME'
command_name = 'apphooks'
label = 'apphook name (eg SampleApp)'
help_s... | 70 | 2,483 |
django-cms | cms/management/commands/subcommands/list.py | .py | from cms.models import Page
from cms.models.pluginmodel import CMSPlugin
from cms.plugin_pool import plugin_pool
from .base import SubcommandsCommand
class ListApphooksCommand(SubcommandsCommand):
help_string = 'Lists all apphooks in pages'
command_name = 'apphooks'
def handle(self, *args, **options):
... | 136 | 4,733 |
django-cms | cms/management/commands/subcommands/check.py | .py | from django.core.management.base import CommandError
from cms.utils.check import FileOutputWrapper, check
from .base import SubcommandsCommand
class CheckInstallation(SubcommandsCommand):
help_string = 'Checks your settings and environment'
command_name = 'check'
def handle(self, *args, **options):
... | 15 | 417 |
django-cms | cms/management/commands/subcommands/delete_orphaned_plugins.py | .py | from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from django.db.models import Exists, OuterRef
from cms.management.commands.subcommands.list import plugin_report
from cms.models.placeholdermodel import Placeholder
from cms.models.pluginmodel import CMSPlugin
from .base impo... | 122 | 5,116 |
django-cms | cms/management/commands/subcommands/tree.py | .py | from collections import OrderedDict
from django.db import IntegrityError
from cms.models.pagemodel import Page, PageUrl
from .base import SubcommandsCommand
def get_descendants(root):
"""
Returns a generator of primary keys which represent
descendants of the given node ID (root_id)
"""
# Note t... | 111 | 3,648 |
django-cms | cms/management/commands/subcommands/base.py | .py | import os
from collections import OrderedDict
from django.core.management.base import BaseCommand, CommandParser
from django.core.management.color import color_style, no_style
def add_builtin_arguments(parser):
parser.add_argument(
'--noinput',
action='store_false',
dest='interactive',
... | 106 | 4,050 |
django-cms | cms/signals/__init__.py | .py | import warnings
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.db.models import signals
from django.dispatch import Signal
from cms.models import (
GlobalPagePermission,
PagePermission,
PageUser,
PageUserGroup,
)... | 129 | 4,510 |
django-cms | cms/signals/permissions.py | .py | from django.contrib.auth import get_user_model
from cms.cache.permissions import clear_user_permission_cache
from cms.models import PageUser, PageUserGroup
from menus.menu_pool import menu_pool
User = get_user_model()
def post_save_user(instance, raw, created, **kwargs):
"""Signal called when new user is create... | 116 | 3,348 |
django-cms | cms/signals/pagecontent.py | .py | """
Signal handlers for PageContent model operations.
"""
import logging
from django.db.models.signals import post_save
from django.dispatch import receiver
from cms.models.contentmodels import PageContent
from cms.signals.apphook import set_restart_trigger
logger = logging.getLogger(__name__)
@receiver(post_save,... | 38 | 1,299 |
django-cms | cms/signals/apphook.py | .py | import logging
import sys
from django.core.management import color_style
from django.core.signals import request_finished
from django.urls import clear_url_caches
from cms.utils.apphook_reload import mark_urlconf_as_changed
logger = logging.getLogger(__name__)
DISPATCH_UID = 'cms-restart'
def trigger_server_resta... | 50 | 1,389 |
django-cms | cms/signals/log_entries.py | .py | import json
from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import gettext_lazy as _
from cms import operations
from cms.models import Page, PageType
_page_operations_map = {
operations.MOVE_PAGE... | 154 | 4,852 |
django-cms | cms/extensions/admin.py | .py | from django.contrib import admin
from django.contrib.admin.options import csrf_protect_m
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.urls import reverse
from cms.models import Page, PageContent
from cms.utils.page_permissions import user_can_change_page
... | 110 | 4,248 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.