repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
django-leonardo/django-leonardo
leonardo/module/media/admin/clipboardadmin.py
ClipboardAdmin.ajax_upload
def ajax_upload(self, request, folder_id=None): """ receives an upload from the uploader. Receives only one file at the time. """ mimetype = "application/json" if request.is_ajax() else "text/html" content_type_key = 'content_type' response_params = {content_type_key: mim...
python
def ajax_upload(self, request, folder_id=None): """ receives an upload from the uploader. Receives only one file at the time. """ mimetype = "application/json" if request.is_ajax() else "text/html" content_type_key = 'content_type' response_params = {content_type_key: mim...
receives an upload from the uploader. Receives only one file at the time.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/clipboardadmin.py#L62-L135
django-leonardo/django-leonardo
leonardo/module/web/management/commands/sync_page_themes.py
Command.set_options
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = False self.verbosity = options['verbosity'] self.symlink = "" self.clear = False ignore_patterns = [] self.ignore_patterns = list(set(ignor...
python
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = False self.verbosity = options['verbosity'] self.symlink = "" self.clear = False ignore_patterns = [] self.ignore_patterns = list(set(ignor...
Set instance variables based on an options dict
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/management/commands/sync_page_themes.py#L30-L41
django-leonardo/django-leonardo
leonardo/module/web/management/commands/sync_page_themes.py
Command.collect
def collect(self): """ Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss """ self.ignore_patterns = [ '*.png', '*.jpg', ...
python
def collect(self): """ Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss """ self.ignore_patterns = [ '*.png', '*.jpg', ...
Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/management/commands/sync_page_themes.py#L43-L91
django-leonardo/django-leonardo
leonardo/module/web/signals.py
dbtemplate_save
def dbtemplate_save(sender, instance, created, **kwargs): """create widget/page content/base theme from given db template:: /widget/icon/my_awesome.html /base/widget/my_new_widget_box.html /base/page/my_new_page_layout.html """ if created: if 'widget' in instance.name: ...
python
def dbtemplate_save(sender, instance, created, **kwargs): """create widget/page content/base theme from given db template:: /widget/icon/my_awesome.html /base/widget/my_new_widget_box.html /base/page/my_new_page_layout.html """ if created: if 'widget' in instance.name: ...
create widget/page content/base theme from given db template:: /widget/icon/my_awesome.html /base/widget/my_new_widget_box.html /base/page/my_new_page_layout.html
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/signals.py#L13-L49
django-leonardo/django-leonardo
leonardo/module/media/models/abstract.py
BaseImage.has_generic_permission
def has_generic_permission(self, request, permission_type): """ Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights. """ user = request.user if not user.is_authenticated(): return False elif ...
python
def has_generic_permission(self, request, permission_type): """ Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights. """ user = request.user if not user.is_authenticated(): return False elif ...
Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/models/abstract.py#L101-L116
frawau/aioblescan
aioblescan/plugins/eddystone.py
EddyStone.decode
def decode(self, packet): """Check a parsed packet and figure out if it is an Eddystone Beacon. If it is , return the relevant data as a dictionary. Return None, it is not an Eddystone Beacon advertising packet""" ssu=packet.retrieve("Complete uuids") found=False for x ...
python
def decode(self, packet): """Check a parsed packet and figure out if it is an Eddystone Beacon. If it is , return the relevant data as a dictionary. Return None, it is not an Eddystone Beacon advertising packet""" ssu=packet.retrieve("Complete uuids") found=False for x ...
Check a parsed packet and figure out if it is an Eddystone Beacon. If it is , return the relevant data as a dictionary. Return None, it is not an Eddystone Beacon advertising packet
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/plugins/eddystone.py#L221-L361
django-leonardo/django-leonardo
leonardo/module/media/widget/mediagallery/models.py
MediaGalleryWidget.get_directories
def get_directories(self, request): """Return directories """ queryset = self.folder.media_folder_children.all().order_by(*config.MEDIA_FOLDERS_ORDER_BY.split(",")) paginator = Paginator(queryset, self.objects_per_page) page = request.GET.get('page', None) try: ...
python
def get_directories(self, request): """Return directories """ queryset = self.folder.media_folder_children.all().order_by(*config.MEDIA_FOLDERS_ORDER_BY.split(",")) paginator = Paginator(queryset, self.objects_per_page) page = request.GET.get('page', None) try: ...
Return directories
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/widget/mediagallery/models.py#L57-L79
django-leonardo/django-leonardo
leonardo/module/media/widget/mediagallery/models.py
MediaGalleryWidget.get_template_data
def get_template_data(self, request, *args, **kwargs): '''Add image dimensions''' # little tricky with vertical centering dimension = int(self.get_size().split('x')[0]) data = {} if dimension <= 356: data['image_dimension'] = "row-md-13" if self.get_templa...
python
def get_template_data(self, request, *args, **kwargs): '''Add image dimensions''' # little tricky with vertical centering dimension = int(self.get_size().split('x')[0]) data = {} if dimension <= 356: data['image_dimension'] = "row-md-13" if self.get_templa...
Add image dimensions
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/widget/mediagallery/models.py#L81-L95
django-leonardo/django-leonardo
leonardo/decorators.py
staff_member
def staff_member(view_func): """Performs user authentication check. Similar to Django's `login_required` decorator, except that this throws :exc:`~leonardo.exceptions.NotAuthenticated` exception if the user is not signed-in. """ @functools.wraps(view_func, assigned=available_attrs(view_func)) ...
python
def staff_member(view_func): """Performs user authentication check. Similar to Django's `login_required` decorator, except that this throws :exc:`~leonardo.exceptions.NotAuthenticated` exception if the user is not signed-in. """ @functools.wraps(view_func, assigned=available_attrs(view_func)) ...
Performs user authentication check. Similar to Django's `login_required` decorator, except that this throws :exc:`~leonardo.exceptions.NotAuthenticated` exception if the user is not signed-in.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/decorators.py#L37-L50
django-leonardo/django-leonardo
leonardo/decorators.py
_decorate_urlconf
def _decorate_urlconf(urlpatterns, decorator=require_auth, *args, **kwargs): '''Decorate all urlpatterns by specified decorator''' if isinstance(urlpatterns, (list, tuple)): for pattern in urlpatterns: if getattr(pattern, 'callback', None): pattern._callback = decorator( ...
python
def _decorate_urlconf(urlpatterns, decorator=require_auth, *args, **kwargs): '''Decorate all urlpatterns by specified decorator''' if isinstance(urlpatterns, (list, tuple)): for pattern in urlpatterns: if getattr(pattern, 'callback', None): pattern._callback = decorator( ...
Decorate all urlpatterns by specified decorator
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/decorators.py#L53-L68
django-leonardo/django-leonardo
leonardo/decorators.py
catch_result
def catch_result(task_func): """Catch printed result from Celery Task and return it in task response """ @functools.wraps(task_func, assigned=available_attrs(task_func)) def dec(*args, **kwargs): # inicialize orig_stdout = sys.stdout sys.stdout = content = StringIO() tas...
python
def catch_result(task_func): """Catch printed result from Celery Task and return it in task response """ @functools.wraps(task_func, assigned=available_attrs(task_func)) def dec(*args, **kwargs): # inicialize orig_stdout = sys.stdout sys.stdout = content = StringIO() tas...
Catch printed result from Celery Task and return it in task response
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/decorators.py#L74-L90
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
compress_monkey_patch
def compress_monkey_patch(): """patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file """ from compressor.templ...
python
def compress_monkey_patch(): """patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file """ from compressor.templ...
patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L37-L62
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
input
def input(self, **kwargs): """main override which append variables import to all scss content """ with_variables = None context = kwargs.get('context', {}) if context.get('leonardo_page', None): try: context['leonardo_page']['theme'] context['leonardo_page']['color...
python
def input(self, **kwargs): """main override which append variables import to all scss content """ with_variables = None context = kwargs.get('context', {}) if context.get('leonardo_page', None): try: context['leonardo_page']['theme'] context['leonardo_page']['color...
main override which append variables import to all scss content
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L94-L119
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
hunks
def hunks(self, forced=False, context=None): """ The heart of content parsing, iterates over the list of split contents and looks at its kind to decide what to do with it. Should yield a bunch of precompiled and/or rendered hunks. """ enabled = settings.COMPRESS_ENABLED or forced for ki...
python
def hunks(self, forced=False, context=None): """ The heart of content parsing, iterates over the list of split contents and looks at its kind to decide what to do with it. Should yield a bunch of precompiled and/or rendered hunks. """ enabled = settings.COMPRESS_ENABLED or forced for ki...
The heart of content parsing, iterates over the list of split contents and looks at its kind to decide what to do with it. Should yield a bunch of precompiled and/or rendered hunks.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L122-L162
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
output
def output(self, mode='file', forced=False, context=None): """ The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly. """ output = '\n'.join(self.filter_input(forced, context=context)) ...
python
def output(self, mode='file', forced=False, context=None): """ The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly. """ output = '\n'.join(self.filter_input(forced, context=context)) ...
The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L165-L180
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
filter_input
def filter_input(self, forced=False, context=None): """ Passes each hunk (file or code) to the 'input' methods of the compressor filters. """ content = [] for hunk in self.hunks(forced, context=context): content.append(hunk) return content
python
def filter_input(self, forced=False, context=None): """ Passes each hunk (file or code) to the 'input' methods of the compressor filters. """ content = [] for hunk in self.hunks(forced, context=context): content.append(hunk) return content
Passes each hunk (file or code) to the 'input' methods of the compressor filters.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L183-L191
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
precompile
def precompile(self, content, kind=None, elem=None, filename=None, charset=None, **kwargs): """ Processes file using a pre compiler. This is the place where files like coffee script are processed. """ if not kind: return False, content attrs = self.parser.elem_attribs(elem...
python
def precompile(self, content, kind=None, elem=None, filename=None, charset=None, **kwargs): """ Processes file using a pre compiler. This is the place where files like coffee script are processed. """ if not kind: return False, content attrs = self.parser.elem_attribs(elem...
Processes file using a pre compiler. This is the place where files like coffee script are processed.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L194-L230
frawau/aioblescan
aioblescan/aioblescan.py
MACAddr.decode
def decode(self,data): """Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed ...
python
def decode(self,data): """Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed ...
Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed :param data: The data stream cont...
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/aioblescan.py#L75-L88
frawau/aioblescan
aioblescan/aioblescan.py
Packet.retrieve
def retrieve(self,aclass): """Look for a specifc class/name in the packet""" resu=[] for x in self.payload: try: if isinstance(aclass,str): if x.name == aclass: resu.append(x) else: if isi...
python
def retrieve(self,aclass): """Look for a specifc class/name in the packet""" resu=[] for x in self.payload: try: if isinstance(aclass,str): if x.name == aclass: resu.append(x) else: if isi...
Look for a specifc class/name in the packet
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/aioblescan.py#L708-L723
frawau/aioblescan
aioblescan/aioblescan.py
BLEScanRequester.send_scan_request
def send_scan_request(self): '''Sending LE scan request''' command=HCI_Cmd_LE_Scan_Enable(True,False) self.transport.write(command.encode())
python
def send_scan_request(self): '''Sending LE scan request''' command=HCI_Cmd_LE_Scan_Enable(True,False) self.transport.write(command.encode())
Sending LE scan request
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/aioblescan.py#L1277-L1280
frawau/aioblescan
aioblescan/aioblescan.py
BLEScanRequester.stop_scan_request
def stop_scan_request(self): '''Sending LE scan request''' command=HCI_Cmd_LE_Scan_Enable(False,False) self.transport.write(command.encode())
python
def stop_scan_request(self): '''Sending LE scan request''' command=HCI_Cmd_LE_Scan_Enable(False,False) self.transport.write(command.encode())
Sending LE scan request
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/aioblescan.py#L1282-L1285
django-leonardo/django-leonardo
leonardo/templatetags/thumbnail.py
thumbnail
def thumbnail(parser, token): ''' This template tag supports both syntax for declare thumbanil in template ''' thumb = None if SORL: try: thumb = sorl_thumb(parser, token) except Exception: thumb = False if EASY and not thumb: thumb = easy_thumb...
python
def thumbnail(parser, token): ''' This template tag supports both syntax for declare thumbanil in template ''' thumb = None if SORL: try: thumb = sorl_thumb(parser, token) except Exception: thumb = False if EASY and not thumb: thumb = easy_thumb...
This template tag supports both syntax for declare thumbanil in template
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/thumbnail.py#L18-L34
django-leonardo/django-leonardo
leonardo/models.py
register_widgets
def register_widgets(): """ Register all collected widgets from settings WIDGETS = [('mymodule.models.MyWidget', {'mykwargs': 'mykwarg'})] WIDGETS = ['mymodule.models.MyWidget', MyClass] """ # special case # register external apps Page.create_content_type( ApplicationWidget, APP...
python
def register_widgets(): """ Register all collected widgets from settings WIDGETS = [('mymodule.models.MyWidget', {'mykwargs': 'mykwarg'})] WIDGETS = ['mymodule.models.MyWidget', MyClass] """ # special case # register external apps Page.create_content_type( ApplicationWidget, APP...
Register all collected widgets from settings WIDGETS = [('mymodule.models.MyWidget', {'mykwargs': 'mykwarg'})] WIDGETS = ['mymodule.models.MyWidget', MyClass]
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/models.py#L17-L53
django-leonardo/django-leonardo
leonardo/module/media/utils.py
handle_uploaded_file
def handle_uploaded_file(file, folder=None, is_public=True): '''handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean ''' _folder = None if folder and isinstance(folder, Folder)...
python
def handle_uploaded_file(file, folder=None, is_public=True): '''handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean ''' _folder = None if folder and isinstance(folder, Folder)...
handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/utils.py#L5-L33
django-leonardo/django-leonardo
leonardo/module/media/utils.py
handle_uploaded_files
def handle_uploaded_files(files, folder=None, is_public=True): '''handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean ''' results = [] for f in files: result = handle_uploaded_file(f, folder, is_public) ...
python
def handle_uploaded_files(files, folder=None, is_public=True): '''handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean ''' results = [] for f in files: result = handle_uploaded_file(f, folder, is_public) ...
handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/utils.py#L36-L48
django-leonardo/django-leonardo
leonardo/module/media/server/views.py
serve_protected_file
def serve_protected_file(request, path): """ Serve protected files to authenticated users with read permissions. """ path = path.rstrip('/') try: file_obj = File.objects.get(file=path) except File.DoesNotExist: raise Http404('File not found %s' % path) if not file_obj.has_rea...
python
def serve_protected_file(request, path): """ Serve protected files to authenticated users with read permissions. """ path = path.rstrip('/') try: file_obj = File.objects.get(file=path) except File.DoesNotExist: raise Http404('File not found %s' % path) if not file_obj.has_rea...
Serve protected files to authenticated users with read permissions.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/server/views.py#L14-L28
django-leonardo/django-leonardo
leonardo/module/media/server/views.py
serve_protected_thumbnail
def serve_protected_thumbnail(request, path): """ Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image. """ source_path = thumbnail_to_original_filename(path) if not source_path: raise Http404('File not found') try: ...
python
def serve_protected_thumbnail(request, path): """ Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image. """ source_path = thumbnail_to_original_filename(path) if not source_path: raise Http404('File not found') try: ...
Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/server/views.py#L31-L52
django-leonardo/django-leonardo
leonardo/base.py
Leonardo.get_app_modules
def get_app_modules(self, apps): """return array of imported leonardo modules for apps """ modules = getattr(self, "_modules", []) if not modules: from django.utils.module_loading import module_has_submodule # Try importing a modules from the module package ...
python
def get_app_modules(self, apps): """return array of imported leonardo modules for apps """ modules = getattr(self, "_modules", []) if not modules: from django.utils.module_loading import module_has_submodule # Try importing a modules from the module package ...
return array of imported leonardo modules for apps
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/base.py#L47-L80
django-leonardo/django-leonardo
leonardo/base.py
Leonardo.urlpatterns
def urlpatterns(self): '''load and decorate urls from all modules then store it as cached property for less loading ''' if not hasattr(self, '_urlspatterns'): urlpatterns = [] # load all urls # support .urls file and urls_conf = 'elephantblog.urls' on ...
python
def urlpatterns(self): '''load and decorate urls from all modules then store it as cached property for less loading ''' if not hasattr(self, '_urlspatterns'): urlpatterns = [] # load all urls # support .urls file and urls_conf = 'elephantblog.urls' on ...
load and decorate urls from all modules then store it as cached property for less loading
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/base.py#L83-L132
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
cycle_app_reverse_cache
def cycle_app_reverse_cache(*args, **kwargs): """Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys""" value = '%07x' % (SystemRandom().randint(0, 0x10000000)) cache.se...
python
def cycle_app_reverse_cache(*args, **kwargs): """Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys""" value = '%07x' % (SystemRandom().randint(0, 0x10000000)) cache.se...
Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L31-L37
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
app_reverse
def app_reverse(viewname, urlconf=None, args=None, kwargs=None, *vargs, **vkwargs): """ Reverse URLs from application contents Works almost like Django's own reverse() method except that it resolves URLs from application contents. The second argument, ``urlconf``, has to correspond t...
python
def app_reverse(viewname, urlconf=None, args=None, kwargs=None, *vargs, **vkwargs): """ Reverse URLs from application contents Works almost like Django's own reverse() method except that it resolves URLs from application contents. The second argument, ``urlconf``, has to correspond t...
Reverse URLs from application contents Works almost like Django's own reverse() method except that it resolves URLs from application contents. The second argument, ``urlconf``, has to correspond to the URLconf parameter passed in the ``APPLICATIONS`` list to ``Page.create_content_type``:: app_re...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L45-L105
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
permalink
def permalink(func): """ Decorator that calls app_reverse() Use this instead of standard django.db.models.permalink if you want to integrate the model through ApplicationContent. The wrapped function must return 4 instead of 3 arguments:: class MyModel(models.Model): @appmodels.p...
python
def permalink(func): """ Decorator that calls app_reverse() Use this instead of standard django.db.models.permalink if you want to integrate the model through ApplicationContent. The wrapped function must return 4 instead of 3 arguments:: class MyModel(models.Model): @appmodels.p...
Decorator that calls app_reverse() Use this instead of standard django.db.models.permalink if you want to integrate the model through ApplicationContent. The wrapped function must return 4 instead of 3 arguments:: class MyModel(models.Model): @appmodels.permalink def get_abso...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L112-L125
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
reverse
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): """monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from Applic...
python
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): """monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from Applic...
monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from ApplicationContent !
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L128-L209
django-leonardo/django-leonardo
leonardo/module/web/widgets/tables.py
WidgetDimensionTable.get_formset
def get_formset(self): """Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back. """ if self.widget: queryset = self.widget.dimensions else: queryset = WidgetDimension.objects.none() ...
python
def get_formset(self): """Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back. """ if self.widget: queryset = self.widget.dimensions else: queryset = WidgetDimension.objects.none() ...
Provide the formset corresponding to this DataTable. Use this to validate the formset and to get the submitted data back.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/tables.py#L64-L79
django-leonardo/django-leonardo
leonardo/module/web/processors/page.py
add_page_if_missing
def add_page_if_missing(request): """ Returns ``feincms_page`` for request. """ try: page = Page.objects.for_request(request, best_match=True) return { 'leonardo_page': page, # DEPRECATED 'feincms_page': page, } except Page.DoesNotExist: ...
python
def add_page_if_missing(request): """ Returns ``feincms_page`` for request. """ try: page = Page.objects.for_request(request, best_match=True) return { 'leonardo_page': page, # DEPRECATED 'feincms_page': page, } except Page.DoesNotExist: ...
Returns ``feincms_page`` for request.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/page.py#L5-L18
django-leonardo/django-leonardo
leonardo/views/defaults.py
render_in_page
def render_in_page(request, template): """return rendered template in standalone mode or ``False`` """ from leonardo.module.web.models import Page page = request.leonardo_page if hasattr( request, 'leonardo_page') else Page.objects.filter(parent=None).first() if page: try: ...
python
def render_in_page(request, template): """return rendered template in standalone mode or ``False`` """ from leonardo.module.web.models import Page page = request.leonardo_page if hasattr( request, 'leonardo_page') else Page.objects.filter(parent=None).first() if page: try: ...
return rendered template in standalone mode or ``False``
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L11-L38
django-leonardo/django-leonardo
leonardo/views/defaults.py
page_not_found
def page_not_found(request, template_name='404.html'): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ response = render_in_page(request, template_name) if response: ...
python
def page_not_found(request, template_name='404.html'): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ response = render_in_page(request, template_name) if response: ...
Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/')
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L45-L64
django-leonardo/django-leonardo
leonardo/views/defaults.py
server_error
def server_error(request, template_name='500.html'): """ 500 error handler. Templates: :template:`500.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except T...
python
def server_error(request, template_name='500.html'): """ 500 error handler. Templates: :template:`500.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except T...
500 error handler. Templates: :template:`500.html` Context: None
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L68-L85
django-leonardo/django-leonardo
leonardo/views/defaults.py
bad_request
def bad_request(request, template_name='400.html'): """ 400 error handler. Templates: :template:`400.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except Te...
python
def bad_request(request, template_name='400.html'): """ 400 error handler. Templates: :template:`400.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except Te...
400 error handler. Templates: :template:`400.html` Context: None
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L89-L106
django-leonardo/django-leonardo
leonardo/views/defaults.py
permission_denied
def permission_denied(request, template_name='403.html'): """ Permission denied (403) handler. Templates: :template:`403.html` Context: None If the template does not exist, an Http403 response containing the text "403 Forbidden" (as per RFC 2616) will be returned. """ response = rende...
python
def permission_denied(request, template_name='403.html'): """ Permission denied (403) handler. Templates: :template:`403.html` Context: None If the template does not exist, an Http403 response containing the text "403 Forbidden" (as per RFC 2616) will be returned. """ response = rende...
Permission denied (403) handler. Templates: :template:`403.html` Context: None If the template does not exist, an Http403 response containing the text "403 Forbidden" (as per RFC 2616) will be returned.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L113-L133
django-leonardo/django-leonardo
leonardo/module/web/middlewares/horizon.py
HorizonMiddleware.process_request
def process_request(self, request): """Adds data necessary for Horizon to function to the request.""" # Activate timezone handling tz = request.session.get('django_timezone') if tz: timezone.activate(tz) # Check for session timeout try: timeout = ...
python
def process_request(self, request): """Adds data necessary for Horizon to function to the request.""" # Activate timezone handling tz = request.session.get('django_timezone') if tz: timezone.activate(tz) # Check for session timeout try: timeout = ...
Adds data necessary for Horizon to function to the request.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/middlewares/horizon.py#L32-L94
django-leonardo/django-leonardo
leonardo/module/web/middlewares/horizon.py
HorizonMiddleware.process_response
def process_response(self, request, response): """Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url """ if request.is_ajax() and hasattr(request, 'horizon'): queued_msgs = request.horizon['async_messages'] i...
python
def process_response(self, request, response): """Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url """ if request.is_ajax() and hasattr(request, 'horizon'): queued_msgs = request.horizon['async_messages'] i...
Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/middlewares/horizon.py#L96-L143
django-leonardo/django-leonardo
leonardo/module/web/middlewares/horizon.py
HorizonMiddleware.process_exception
def process_exception(self, request, exception): """Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully. """ if isinstance(exception, (exceptions.NotAuthorized, exceptions.NotAuthenticated))...
python
def process_exception(self, request, exception): """Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully. """ if isinstance(exception, (exceptions.NotAuthorized, exceptions.NotAuthenticated))...
Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/middlewares/horizon.py#L145-L195
django-leonardo/django-leonardo
leonardo/module/media/views.py
canonical
def canonical(request, uploaded_at, file_id): """ Redirect to the current url of a public file """ filer_file = get_object_or_404(File, pk=file_id, is_public=True) if (uploaded_at != filer_file.uploaded_at.strftime('%s') or not filer_file.file): raise Http404('No %s matches the g...
python
def canonical(request, uploaded_at, file_id): """ Redirect to the current url of a public file """ filer_file = get_object_or_404(File, pk=file_id, is_public=True) if (uploaded_at != filer_file.uploaded_at.strftime('%s') or not filer_file.file): raise Http404('No %s matches the g...
Redirect to the current url of a public file
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/views.py#L77-L86
django-leonardo/django-leonardo
leonardo/exceptions.py
check_message
def check_message(keywords, message): """Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages. """ exc_type, exc_value, exc_traceback = sys.exc_info() if set(str(exc_value...
python
def check_message(keywords, message): """Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages. """ exc_type, exc_value, exc_traceback = sys.exc_info() if set(str(exc_value...
Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/exceptions.py#L142-L150
django-leonardo/django-leonardo
leonardo/module/web/page/forms.py
SwitchableFormFieldMixin.get_switched_form_field_attrs
def get_switched_form_field_attrs(self, prefix, input_type, name): """Creates attribute dicts for the switchable theme form """ attributes = {'class': 'switched', 'data-switch-on': prefix + 'field'} attributes['data-' + prefix + 'field-' + input_type] = name return attributes
python
def get_switched_form_field_attrs(self, prefix, input_type, name): """Creates attribute dicts for the switchable theme form """ attributes = {'class': 'switched', 'data-switch-on': prefix + 'field'} attributes['data-' + prefix + 'field-' + input_type] = name return attributes
Creates attribute dicts for the switchable theme form
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/forms.py#L23-L28
django-leonardo/django-leonardo
leonardo/module/web/page/forms.py
PageCreateForm.clean_slug
def clean_slug(self): """slug title if is not provided """ slug = self.cleaned_data.get('slug', None) if slug is None or len(slug) == 0 and 'title' in self.cleaned_data: slug = slugify(self.cleaned_data['title']) return slug
python
def clean_slug(self): """slug title if is not provided """ slug = self.cleaned_data.get('slug', None) if slug is None or len(slug) == 0 and 'title' in self.cleaned_data: slug = slugify(self.cleaned_data['title']) return slug
slug title if is not provided
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/forms.py#L90-L96
django-leonardo/django-leonardo
leonardo/module/web/widgets/utils.py
get_widget_from_id
def get_widget_from_id(id): """returns widget object by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[0], res[1]) obj = model_cls.objects.get(parent=res[2], id=res[3]) except: obj = None return obj
python
def get_widget_from_id(id): """returns widget object by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[0], res[1]) obj = model_cls.objects.get(parent=res[2], id=res[3]) except: obj = None return obj
returns widget object by id example web-htmltextwidget-2-2
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/utils.py#L4-L16
django-leonardo/django-leonardo
leonardo/module/web/widgets/utils.py
get_widget_class_from_id
def get_widget_class_from_id(id): """returns widget class by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[1], res[2]) except: model_cls = None return model_cls
python
def get_widget_class_from_id(id): """returns widget class by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[1], res[2]) except: model_cls = None return model_cls
returns widget class by id example web-htmltextwidget-2-2
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/utils.py#L19-L30
django-leonardo/django-leonardo
leonardo/views/select2.py
Select2ResponseView.get
def get(self, request, *args, **kwargs): """ Return a :class:`.django.http.JsonResponse`. PR: https://github.com/applegrew/django-select2/pull/208 Example:: { 'results': [ { 'text': "foo", ...
python
def get(self, request, *args, **kwargs): """ Return a :class:`.django.http.JsonResponse`. PR: https://github.com/applegrew/django-select2/pull/208 Example:: { 'results': [ { 'text': "foo", ...
Return a :class:`.django.http.JsonResponse`. PR: https://github.com/applegrew/django-select2/pull/208 Example:: { 'results': [ { 'text': "foo", 'id': 123 } ] ...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/select2.py#L20-L57
django-leonardo/django-leonardo
leonardo/module/search/search_indexes.py
PageIndex.index_queryset
def index_queryset(self, using=None): """Used when the entire index for model is updated.""" kwargs = {"active": True} # if permissions are enabled then we want only public pages # https://github.com/leonardo-modules/leonardo-module-pagepermissions if hasattr(Page(), 'permissio...
python
def index_queryset(self, using=None): """Used when the entire index for model is updated.""" kwargs = {"active": True} # if permissions are enabled then we want only public pages # https://github.com/leonardo-modules/leonardo-module-pagepermissions if hasattr(Page(), 'permissio...
Used when the entire index for model is updated.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/search/search_indexes.py#L36-L50
django-leonardo/django-leonardo
leonardo/module/web/processors/edit.py
frontendediting_request_processor
def frontendediting_request_processor(page, request): """ Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions. """ if 'frontend_editing' not in request.GET: return response = HttpResponseRedirect(request.path) ...
python
def frontendediting_request_processor(page, request): """ Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions. """ if 'frontend_editing' not in request.GET: return response = HttpResponseRedirect(request.path) ...
Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/edit.py#L11-L40
django-leonardo/django-leonardo
leonardo/module/leonardo_auth/forms.py
SignupForm.clean
def clean(self): '''Check to make sure password fields match.''' data = super(SignupForm, self).clean() # basic check for now if 'username' in data: if User.objects.filter( username=data['username'], email=data['email']).exists(): ...
python
def clean(self): '''Check to make sure password fields match.''' data = super(SignupForm, self).clean() # basic check for now if 'username' in data: if User.objects.filter( username=data['username'], email=data['email']).exists(): ...
Check to make sure password fields match.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/leonardo_auth/forms.py#L77-L94
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.get_form
def get_form(self, request, obj=None, **kwargs): """ Returns a Form class for use in the admin add view. This is used by add_view and change_view. """ parent_id = request.REQUEST.get('parent_id', None) if parent_id: return FolderForm else: ...
python
def get_form(self, request, obj=None, **kwargs): """ Returns a Form class for use in the admin add view. This is used by add_view and change_view. """ parent_id = request.REQUEST.get('parent_id', None) if parent_id: return FolderForm else: ...
Returns a Form class for use in the admin add view. This is used by add_view and change_view.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L71-L99
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.save_form
def save_form(self, request, form, change): """ Given a ModelForm return an unsaved instance. ``change`` is True if the object is being changed, and False if it's being added. """ r = form.save(commit=False) parent_id = request.REQUEST.get('parent_id', None) if pa...
python
def save_form(self, request, form, change): """ Given a ModelForm return an unsaved instance. ``change`` is True if the object is being changed, and False if it's being added. """ r = form.save(commit=False) parent_id = request.REQUEST.get('parent_id', None) if pa...
Given a ModelForm return an unsaved instance. ``change`` is True if the object is being changed, and False if it's being added.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L101-L111
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.response_change
def response_change(self, request, obj): """ Overrides the default to be able to forward to the directory listing instead of the default change_list_view """ r = super(FolderAdmin, self).response_change(request, obj) # Code borrowed from django ModelAdmin to determine cha...
python
def response_change(self, request, obj): """ Overrides the default to be able to forward to the directory listing instead of the default change_list_view """ r = super(FolderAdmin, self).response_change(request, obj) # Code borrowed from django ModelAdmin to determine cha...
Overrides the default to be able to forward to the directory listing instead of the default change_list_view
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L113-L136
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.delete_view
def delete_view(self, request, object_id, extra_context=None): """ Overrides the default to enable redirecting to the directory view after deletion of a folder. we need to fetch the object and find out who the parent is before super, because super will delete the object and make...
python
def delete_view(self, request, object_id, extra_context=None): """ Overrides the default to enable redirecting to the directory view after deletion of a folder. we need to fetch the object and find out who the parent is before super, because super will delete the object and make...
Overrides the default to enable redirecting to the directory view after deletion of a folder. we need to fetch the object and find out who the parent is before super, because super will delete the object and make it impossible to find out the parent folder to redirect to.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L148-L177
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.get_actions
def get_actions(self, request): """ Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action. """ # If self.actions is explicitly set to None that means that we don't # want *any* actions enabled ...
python
def get_actions(self, request): """ Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action. """ # If self.actions is explicitly set to None that means that we don't # want *any* actions enabled ...
Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L584-L622
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
FolderAdmin.files_set_public_or_private
def files_set_public_or_private(self, request, set_public, files_queryset, folders_queryset): """ Action which enables or disables permissions for selected files and files in selected folders to clipboard (set them private or public). """ if not self.has_change_permission(request): ...
python
def files_set_public_or_private(self, request, set_public, files_queryset, folders_queryset): """ Action which enables or disables permissions for selected files and files in selected folders to clipboard (set them private or public). """ if not self.has_change_permission(request): ...
Action which enables or disables permissions for selected files and files in selected folders to clipboard (set them private or public).
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L684-L726
django-leonardo/django-leonardo
leonardo/module/web/__init__.py
Default.extra_context
def extra_context(self): """Add site_name to context """ from django.conf import settings return { "site_name": (lambda r: settings.LEONARDO_SITE_NAME if getattr(settings, 'LEONARDO_SITE_NAME', '') != '' else settings.SITE_...
python
def extra_context(self): """Add site_name to context """ from django.conf import settings return { "site_name": (lambda r: settings.LEONARDO_SITE_NAME if getattr(settings, 'LEONARDO_SITE_NAME', '') != '' else settings.SITE_...
Add site_name to context
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/__init__.py#L113-L123
django-leonardo/django-leonardo
leonardo/conf/base.py
ModuleConfig.get_property
def get_property(self, key): """Expect Django Conf property""" _key = DJANGO_CONF[key] return getattr(self, _key, CONF_SPEC[_key])
python
def get_property(self, key): """Expect Django Conf property""" _key = DJANGO_CONF[key] return getattr(self, _key, CONF_SPEC[_key])
Expect Django Conf property
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L21-L24
django-leonardo/django-leonardo
leonardo/conf/base.py
ModuleConfig.needs_sync
def needs_sync(self): """Indicates whater module needs templates, static etc.""" affected_attributes = [ 'css_files', 'js_files', 'scss_files', 'widgets'] for attr in affected_attributes: if len(getattr(self, attr)) > 0: return True r...
python
def needs_sync(self): """Indicates whater module needs templates, static etc.""" affected_attributes = [ 'css_files', 'js_files', 'scss_files', 'widgets'] for attr in affected_attributes: if len(getattr(self, attr)) > 0: return True r...
Indicates whater module needs templates, static etc.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L60-L70
django-leonardo/django-leonardo
leonardo/conf/base.py
ModuleConfig.demo_paths
def demo_paths(self): """returns collected demo paths excluding examples TODO: call super which returns custom paths in descriptor """ base_path = os.path.join(self.module.__path__[0], 'demo') paths = [] if os.path.isdir(base_path): for item in os.listdir(base...
python
def demo_paths(self): """returns collected demo paths excluding examples TODO: call super which returns custom paths in descriptor """ base_path = os.path.join(self.module.__path__[0], 'demo') paths = [] if os.path.isdir(base_path): for item in os.listdir(base...
returns collected demo paths excluding examples TODO: call super which returns custom paths in descriptor
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L77-L88
django-leonardo/django-leonardo
leonardo/conf/base.py
LeonardoConfig.get_attr
def get_attr(self, name, default=None, fail_silently=True): """try extra context """ try: return getattr(self, name) except KeyError: extra_context = getattr(self, "extra_context") if name in extra_context: value = extra_context[name] ...
python
def get_attr(self, name, default=None, fail_silently=True): """try extra context """ try: return getattr(self, name) except KeyError: extra_context = getattr(self, "extra_context") if name in extra_context: value = extra_context[name] ...
try extra context
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L93-L107
django-leonardo/django-leonardo
leonardo/utils/emails.py
send_templated_email
def send_templated_email(subject, template_name, context, recipients, sender=None, bcc=None, fail_silently=True, files=None): """ send_templated_mail() is a wrapper around Django's e-mail routines that allows us to easily send multipart (text/plain & text/ht...
python
def send_templated_email(subject, template_name, context, recipients, sender=None, bcc=None, fail_silently=True, files=None): """ send_templated_mail() is a wrapper around Django's e-mail routines that allows us to easily send multipart (text/plain & text/ht...
send_templated_mail() is a wrapper around Django's e-mail routines that allows us to easily send multipart (text/plain & text/html) e-mails using templates that are stored in the database. This lets the admin provide both a text and a HTML template for each message. template_name is the slug of the tem...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/emails.py#L7-L66
django-leonardo/django-leonardo
leonardo/utils/templates.py
find_all_templates
def find_all_templates(pattern='*.html', ignore_private=True): """ Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported. ...
python
def find_all_templates(pattern='*.html', ignore_private=True): """ Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported. ...
Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported.
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/templates.py#L40-L75
django-leonardo/django-leonardo
leonardo/utils/templates.py
flatten_template_loaders
def flatten_template_loaders(templates): """ Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression """ for loader in templates: if not...
python
def flatten_template_loaders(templates): """ Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression """ for loader in templates: if not...
Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/templates.py#L78-L91
django-leonardo/django-leonardo
leonardo/utils/templates.py
template_choices
def template_choices(templates, display_names=None, suffix=False): """ Given an iterable of `templates`, calculate human-friendly display names for each of them, optionally using the `display_names` provided, or a global dictionary (`TEMPLATEFINDER_DISPLAY_NAMES`) stored in the Django project's sett...
python
def template_choices(templates, display_names=None, suffix=False): """ Given an iterable of `templates`, calculate human-friendly display names for each of them, optionally using the `display_names` provided, or a global dictionary (`TEMPLATEFINDER_DISPLAY_NAMES`) stored in the Django project's sett...
Given an iterable of `templates`, calculate human-friendly display names for each of them, optionally using the `display_names` provided, or a global dictionary (`TEMPLATEFINDER_DISPLAY_NAMES`) stored in the Django project's settings. .. note:: As the resulting iterable is a lazy generator, if it needs...
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/templates.py#L94-L136
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/file.py
FileProxy.readlines
def readlines(self, sizehint=None): """Reads until EOF using :meth:`readline()`. :param sizehint: if it's present, instead of reading up to EOF, whole lines totalling approximately ``sizehint`` bytes (or more to accommodate a final whole line) :...
python
def readlines(self, sizehint=None): """Reads until EOF using :meth:`readline()`. :param sizehint: if it's present, instead of reading up to EOF, whole lines totalling approximately ``sizehint`` bytes (or more to accommodate a final whole line) :...
Reads until EOF using :meth:`readline()`. :param sizehint: if it's present, instead of reading up to EOF, whole lines totalling approximately ``sizehint`` bytes (or more to accommodate a final whole line) :type sizehint: :class:`numbers.Integral` ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/file.py#L74-L97
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/file.py
SeekableFileProxy.seek
def seek(self, offset, whence=os.SEEK_SET): """Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET` """ self....
python
def seek(self, offset, whence=os.SEEK_SET): """Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET` """ self....
Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET`
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/file.py#L138-L147
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/context.py
get_current_context_id
def get_current_context_id(): """Identifis which context it is (greenlet, stackless, or thread). :returns: the identifier of the current context. """ global get_current_context_id if greenlet is not None: if stackless is None: get_current_context_id = greenlet.getcurrent ...
python
def get_current_context_id(): """Identifis which context it is (greenlet, stackless, or thread). :returns: the identifier of the current context. """ global get_current_context_id if greenlet is not None: if stackless is None: get_current_context_id = greenlet.getcurrent ...
Identifis which context it is (greenlet, stackless, or thread). :returns: the identifier of the current context.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/context.py#L86-L102
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/context.py
store_context
def store_context(store): """Sets the new (nested) context of the current image storage:: with store_context(store): print current_store It could be set nestedly as well:: with store_context(store1): print current_store # store1 with store_context(store2):...
python
def store_context(store): """Sets the new (nested) context of the current image storage:: with store_context(store): print current_store It could be set nestedly as well:: with store_context(store1): print current_store # store1 with store_context(store2):...
Sets the new (nested) context of the current image storage:: with store_context(store): print current_store It could be set nestedly as well:: with store_context(store1): print current_store # store1 with store_context(store2): print current_st...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/context.py#L138-L161
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/migration.py
migrate
def migrate(session, declarative_base, source, destination): """Migrate all image data from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it returns:...
python
def migrate(session, declarative_base, source, destination): """Migrate all image data from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it returns:...
Migrate all image data from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it returns:: migrate(session, Base, source, destination).execute() ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/migration.py#L14-L70
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/migration.py
migrate_class
def migrate_class(session, cls, source, destination): """Migrate all image data of ``cls`` from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it ...
python
def migrate_class(session, cls, source, destination): """Migrate all image data of ``cls`` from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it ...
Migrate all image data of ``cls`` from ``source`` storage to ``destination`` storage. All data in ``source`` storage are *not* deleted. It does not execute migration by itself alone. You need to :meth:`~MigrationPlan.execute()` the plan it returns:: migrate_class(session, UserPicture, source...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/migration.py#L73-L122
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/migration.py
MigrationPlan.execute
def execute(self, callback=None): """Execute the plan. If optional ``callback`` is present, it is invoked with an :class:`~sqlalchemy_imageattach.entity.Image` instance for every migrated image. :param callback: an optional callback that takes an :class:`~sqlal...
python
def execute(self, callback=None): """Execute the plan. If optional ``callback`` is present, it is invoked with an :class:`~sqlalchemy_imageattach.entity.Image` instance for every migrated image. :param callback: an optional callback that takes an :class:`~sqlal...
Execute the plan. If optional ``callback`` is present, it is invoked with an :class:`~sqlalchemy_imageattach.entity.Image` instance for every migrated image. :param callback: an optional callback that takes an :class:`~sqlalchemy_imageattach.entity.Image` ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/migration.py#L134-L154
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.put_file
def put_file(self, file, object_type, object_id, width, height, mimetype, reproducible): """Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put ...
python
def put_file(self, file, object_type, object_id, width, height, mimetype, reproducible): """Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put ...
Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put e.g. ``'comics.cover'`` :type object_type: :class:`str` :param object_id: the object...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L29-L62
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.store
def store(self, image, file): """Stores the actual data ``file`` of the given ``image``. :: with open(imagefile, 'rb') as f: store.store(image, f) :param image: the image to store its actual data file :type image: :class:`sqlalchemy_imageattach.entity.Image`...
python
def store(self, image, file): """Stores the actual data ``file`` of the given ``image``. :: with open(imagefile, 'rb') as f: store.store(image, f) :param image: the image to store its actual data file :type image: :class:`sqlalchemy_imageattach.entity.Image`...
Stores the actual data ``file`` of the given ``image``. :: with open(imagefile, 'rb') as f: store.store(image, f) :param image: the image to store its actual data file :type image: :class:`sqlalchemy_imageattach.entity.Image` :param file: the image file to p...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L143-L165
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.delete
def delete(self, image): """Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image` """ from .entity import Image if not isinstance(image, Image): raise TypeError('image must be a sq...
python
def delete(self, image): """Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image` """ from .entity import Image if not isinstance(image, Image): raise TypeError('image must be a sq...
Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image`
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L167-L179
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.open
def open(self, image, use_seek=False): """Opens the file-like object of the given ``image``. Returned file-like object guarantees: - context manager protocol - :class:`collections.abc.Iterable` protocol - :class:`collections.abc.Iterator` protocol - :meth:`~io.RawIOBase....
python
def open(self, image, use_seek=False): """Opens the file-like object of the given ``image``. Returned file-like object guarantees: - context manager protocol - :class:`collections.abc.Iterable` protocol - :class:`collections.abc.Iterator` protocol - :meth:`~io.RawIOBase....
Opens the file-like object of the given ``image``. Returned file-like object guarantees: - context manager protocol - :class:`collections.abc.Iterable` protocol - :class:`collections.abc.Iterator` protocol - :meth:`~io.RawIOBase.read()` method - :meth:`~io.IOBase.readlin...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L181-L254
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.locate
def locate(self, image): """Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str` """ from .entity import Image if not isi...
python
def locate(self, image): """Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str` """ from .entity import Image if not isi...
Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str`
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L256-L275
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/util.py
get_minimum_indent
def get_minimum_indent(docstring, ignore_before=1): r"""Gets the minimum indent string from the ``docstring``: >>> get_minimum_indent('Hello') '' >>> get_minimum_indent('Hello\n world::\n yeah') ' ' :param docstring: the docstring to find its minimum indent :type docstring: :c...
python
def get_minimum_indent(docstring, ignore_before=1): r"""Gets the minimum indent string from the ``docstring``: >>> get_minimum_indent('Hello') '' >>> get_minimum_indent('Hello\n world::\n yeah') ' ' :param docstring: the docstring to find its minimum indent :type docstring: :c...
r"""Gets the minimum indent string from the ``docstring``: >>> get_minimum_indent('Hello') '' >>> get_minimum_indent('Hello\n world::\n yeah') ' ' :param docstring: the docstring to find its minimum indent :type docstring: :class:`str` :param ignore_before: ignore lines before...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/util.py#L16-L40
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/util.py
append_docstring
def append_docstring(docstring, *lines): """Appends the ``docstring`` with given ``lines``:: function.__doc__ = append_docstring( function.__doc__, '.. note::' '', ' Appended docstring!' ) :param docstring: a docstring to be appended :param...
python
def append_docstring(docstring, *lines): """Appends the ``docstring`` with given ``lines``:: function.__doc__ = append_docstring( function.__doc__, '.. note::' '', ' Appended docstring!' ) :param docstring: a docstring to be appended :param...
Appends the ``docstring`` with given ``lines``:: function.__doc__ = append_docstring( function.__doc__, '.. note::' '', ' Appended docstring!' ) :param docstring: a docstring to be appended :param \*lines: lines of trailing docstring :retur...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/util.py#L43-L66
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/util.py
append_docstring_attributes
def append_docstring_attributes(docstring, locals): """Manually appends class' ``docstring`` with its attribute docstrings. For example:: class Entity(object): # ... __doc__ = append_docstring_attributes( __doc__, dict((k, v) for k, v in locals()...
python
def append_docstring_attributes(docstring, locals): """Manually appends class' ``docstring`` with its attribute docstrings. For example:: class Entity(object): # ... __doc__ = append_docstring_attributes( __doc__, dict((k, v) for k, v in locals()...
Manually appends class' ``docstring`` with its attribute docstrings. For example:: class Entity(object): # ... __doc__ = append_docstring_attributes( __doc__, dict((k, v) for k, v in locals() if isinstance(v, MyDescriptor)...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/util.py#L69-L104
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
image_attachment
def image_attachment(*args, **kwargs): """The helper function, decorates raw :func:`~sqlalchemy.orm.relationship()` function, sepcialized for relationships between :class:`Image` subtypes. It takes the same parameters as :func:`~sqlalchemy.orm.relationship()`. If ``uselist`` is :const:`True`, it b...
python
def image_attachment(*args, **kwargs): """The helper function, decorates raw :func:`~sqlalchemy.orm.relationship()` function, sepcialized for relationships between :class:`Image` subtypes. It takes the same parameters as :func:`~sqlalchemy.orm.relationship()`. If ``uselist`` is :const:`True`, it b...
The helper function, decorates raw :func:`~sqlalchemy.orm.relationship()` function, sepcialized for relationships between :class:`Image` subtypes. It takes the same parameters as :func:`~sqlalchemy.orm.relationship()`. If ``uselist`` is :const:`True`, it becomes possible to attach multiple image s...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L110-L150
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.object_id
def object_id(self): """(:class:`numbers.Integral`) The identifier number of the image. It uses the primary key if it's integer, but can be overridden, and must be implemented when the primary key is not integer or composite key. .. versionchanged:: 1.1.0 Since 1.1.0,...
python
def object_id(self): """(:class:`numbers.Integral`) The identifier number of the image. It uses the primary key if it's integer, but can be overridden, and must be implemented when the primary key is not integer or composite key. .. versionchanged:: 1.1.0 Since 1.1.0,...
(:class:`numbers.Integral`) The identifier number of the image. It uses the primary key if it's integer, but can be overridden, and must be implemented when the primary key is not integer or composite key. .. versionchanged:: 1.1.0 Since 1.1.0, it provides a more default impl...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L191-L212
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.identity_attributes
def identity_attributes(cls): """A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0 """ columns = inspect(cls).primary_key names = [c.name for c...
python
def identity_attributes(cls): """A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0 """ columns = inspect(cls).primary_key names = [c.name for c...
A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L215-L226
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.identity_map
def identity_map(self): """(:class:`typing.Mapping`\ [:class:`str`, :class:`object`]) A dictionary of the values of primary key fields with their names. .. versionadded:: 1.0.0 """ pk = self.identity_attributes() values = {} for name in pk: values[na...
python
def identity_map(self): """(:class:`typing.Mapping`\ [:class:`str`, :class:`object`]) A dictionary of the values of primary key fields with their names. .. versionadded:: 1.0.0 """ pk = self.identity_attributes() values = {} for name in pk: values[na...
(:class:`typing.Mapping`\ [:class:`str`, :class:`object`]) A dictionary of the values of primary key fields with their names. .. versionadded:: 1.0.0
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L229-L240
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.make_blob
def make_blob(self, store=current_store): """Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_im...
python
def make_blob(self, store=current_store): """Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_im...
Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.store.Store` :returns: the binary d...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L275-L287
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.open_file
def open_file(self, store=current_store, use_seek=False): """Opens the file-like object which is a context manager (that means it can used for :keyword:`with` statement). If ``use_seek`` is :const:`True` (though :const:`False` by default) it guarentees the returned file-like object is a...
python
def open_file(self, store=current_store, use_seek=False): """Opens the file-like object which is a context manager (that means it can used for :keyword:`with` statement). If ``use_seek`` is :const:`True` (though :const:`False` by default) it guarentees the returned file-like object is a...
Opens the file-like object which is a context manager (that means it can used for :keyword:`with` statement). If ``use_seek`` is :const:`True` (though :const:`False` by default) it guarentees the returned file-like object is also seekable (provides :meth:`~file.seek()` method). ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L289-L321
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.locate
def locate(self, store=current_store): """Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.s...
python
def locate(self, store=current_store): """Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.s...
Gets the URL of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.store.Store` :returns: the url of the image...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L323-L338
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._mark_image_file_stored
def _mark_image_file_stored(cls, mapper, connection, target): """When the session flushes, stores actual image files into the storage. Note that these files could be deleted back if the ongoing transaction has done rollback. See also :meth:`_delete_image_file()`. """ t...
python
def _mark_image_file_stored(cls, mapper, connection, target): """When the session flushes, stores actual image files into the storage. Note that these files could be deleted back if the ongoing transaction has done rollback. See also :meth:`_delete_image_file()`. """ t...
When the session flushes, stores actual image files into the storage. Note that these files could be deleted back if the ongoing transaction has done rollback. See also :meth:`_delete_image_file()`.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L390-L412
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._mark_image_file_deleted
def _mark_image_file_deleted(cls, mapper, connection, target): """When the session flushes, marks images as deleted. The files of this marked images will be actually deleted in the image storage when the ongoing transaction succeeds. If it fails the :attr:`_deleted_images` queue will be ...
python
def _mark_image_file_deleted(cls, mapper, connection, target): """When the session flushes, marks images as deleted. The files of this marked images will be actually deleted in the image storage when the ongoing transaction succeeds. If it fails the :attr:`_deleted_images` queue will be ...
When the session flushes, marks images as deleted. The files of this marked images will be actually deleted in the image storage when the ongoing transaction succeeds. If it fails the :attr:`_deleted_images` queue will be just empty.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L415-L423
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._images_failed
def _images_failed(cls, session, previous_transaction): """Deletes the files of :attr:`_stored_images` back and clears the :attr:`_stored_images` and :attr:`_deleted_images` set when the ongoing transaction has done rollback. """ for image, store in cls._stored_images: ...
python
def _images_failed(cls, session, previous_transaction): """Deletes the files of :attr:`_stored_images` back and clears the :attr:`_stored_images` and :attr:`_deleted_images` set when the ongoing transaction has done rollback. """ for image, store in cls._stored_images: ...
Deletes the files of :attr:`_stored_images` back and clears the :attr:`_stored_images` and :attr:`_deleted_images` set when the ongoing transaction has done rollback.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L426-L435
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._images_succeeded
def _images_succeeded(cls, session): """Clears the :attr:`_stored_images` set and deletes actual files that are marked as deleted in the storage if the ongoing transaction has committed. """ for image, store in cls._deleted_images: for stored_image, _ in cls._stored_...
python
def _images_succeeded(cls, session): """Clears the :attr:`_stored_images` set and deletes actual files that are marked as deleted in the storage if the ongoing transaction has committed. """ for image, store in cls._deleted_images: for stored_image, _ in cls._stored_...
Clears the :attr:`_stored_images` set and deletes actual files that are marked as deleted in the storage if the ongoing transaction has committed.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L438-L455
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageQuery._original_images
def _original_images(self, **kwargs): """A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`] """ def test(image): if not image.original: return False for filter, value...
python
def _original_images(self, **kwargs): """A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`] """ def test(image): if not image.original: return False for filter, value...
A list of the original images. :returns: A list of the original images. :rtype: :class:`typing.Sequence`\ [:class:`Image`]
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L457-L494
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.from_raw_file
def from_raw_file(self, raw_file, store=current_store, size=None, mimetype=None, original=True, extra_args=None, extra_kwargs=None): """Similar to :meth:`from_file()` except it's lower than that. It assumes that ``raw_file`` is readable and seekable while ...
python
def from_raw_file(self, raw_file, store=current_store, size=None, mimetype=None, original=True, extra_args=None, extra_kwargs=None): """Similar to :meth:`from_file()` except it's lower than that. It assumes that ``raw_file`` is readable and seekable while ...
Similar to :meth:`from_file()` except it's lower than that. It assumes that ``raw_file`` is readable and seekable while :meth:`from_file()` only assumes the file is readable. Also it doesn't make any in-memory buffer while :meth:`from_file()` always makes an in-memory buffer and copy ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L535-L623
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.from_blob
def from_blob(self, blob, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``blob`` (byte string) for the image into the ``store``. :param blob: the byte string for the image :type blob: :class:`str` :param store: the storage to store the...
python
def from_blob(self, blob, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``blob`` (byte string) for the image into the ``store``. :param blob: the byte string for the image :type blob: :class:`str` :param store: the storage to store the...
Stores the ``blob`` (byte string) for the image into the ``store``. :param blob: the byte string for the image :type blob: :class:`str` :param store: the storage to store the image data. :data:`~sqlalchemy_imageattach.context.current_store` by...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L625-L653
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.from_file
def from_file(self, file, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the f...
python
def from_file(self, file, store=current_store, extra_args=None, extra_kwargs=None): """Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the f...
Stores the ``file`` for the image into the ``store``. :param file: the readable file of the image :type file: file-like object, :class:`file` :param store: the storage to store the file. :data:`~sqlalchemy_imageattach.context.current_store` by default...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L655-L688
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.generate_thumbnail
def generate_thumbnail(self, ratio=None, width=None, height=None, filter='undefined', store=current_store, _preprocess_image=None, _postprocess_image=None): """Resizes the :attr:`original` (scales up or down) and then store the resized thumbnail into...
python
def generate_thumbnail(self, ratio=None, width=None, height=None, filter='undefined', store=current_store, _preprocess_image=None, _postprocess_image=None): """Resizes the :attr:`original` (scales up or down) and then store the resized thumbnail into...
Resizes the :attr:`original` (scales up or down) and then store the resized thumbnail into the ``store``. :param ratio: resize by its ratio. if it's greater than 1 it scales up, and if it's less than 1 it scales down. exclusive for ``width`` and ``height`` ...
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L690-L843
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
BaseImageSet.original
def original(self): """(:class:`Image`) The original image. It could be :const:`None` if there are no stored images yet. """ images = self.query._original_images(**self.identity_map) if images: return images[0]
python
def original(self): """(:class:`Image`) The original image. It could be :const:`None` if there are no stored images yet. """ images = self.query._original_images(**self.identity_map) if images: return images[0]
(:class:`Image`) The original image. It could be :const:`None` if there are no stored images yet.
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L846-L853