pagetools.widgets package

Subpackages

Submodules

pagetools.widgets.admin module

class pagetools.widgets.admin.BaseWidgetAdmin(model, admin_site)[source]

Bases: ModelAdmin

property media
response_add(request, obj, *args, **kwargs)[source]

Determine the HttpResponse for the add_view stage.

response_change(request, obj, *args, **kwargs)[source]

Determine the HttpResponse for the change_view stage.

save_as = True
save_model(request, obj, form, change)[source]

Given a model instance save it to the database.

class pagetools.widgets.admin.ContentWidgetAdmin(model, admin_site)[source]

Bases: BaseWidgetAdmin, TinyMCEMixin

property media
class pagetools.widgets.admin.PageTypeAdmin(model, admin_site)[source]

Bases: ModelAdmin

property media
model

alias of PageType

class pagetools.widgets.admin.TemplateTagWidgetAdmin(model, admin_site)[source]

Bases: BaseWidgetAdmin

get_readonly_fields(request, obj=None)[source]

Hook for specifying custom readonly fields.

property media
class pagetools.widgets.admin.TypeAreaAdmin(model, admin_site)[source]

Bases: ModelAdmin

get_readonly_fields(request, obj=None)[source]

Hook for specifying custom readonly fields.

inlines = (<class 'pagetools.widgets.admin.WidgetInAreaAdmin'>,)
property media
render_change_form(request, context, add=False, change=False, form_url='', obj=None)[source]
save_model(request, obj, form, change)[source]

Given a model instance save it to the database.

class pagetools.widgets.admin.WidgetInAreaAdmin(parent_model, admin_site)[source]

Bases: TabularInline

extra = 0
fields = ('adminedit_url', 'enabled', 'position')
max_num = 0
property media
model

alias of WidgetInArea

readonly_fields = ('adminedit_url',)
sortable_field_name = 'position'

pagetools.widgets.context_processors module

pagetools.widgets.context_processors.base_pagetype(request)[source]
pagetools.widgets.context_processors.pagetype_from_view(request)[source]

pagetools.widgets.models module

class pagetools.widgets.models.BaseWidget(*args, **kwargs)[source]

Bases: Model

class Meta[source]

Bases: object

abstract = False
adapter

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

get_content(context, request)[source]
get_template_name(context)[source]
get_title(context)[source]
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

render(context, request)[source]
template_name = 'widgets/basewidget.html'
title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pagetools.widgets.models.ContentWidget(*args, **kwargs)[source]

Bases: BaseWidget

A wiget with a text area

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

adapter

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

content

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_content(context, request)[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pagetools.widgets.models.PageType(*args, **kwargs)[source]

Bases: Model

A key that defines which additional context should be added to the context.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
page_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

pagetype_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

parent

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

parent_id
typearea_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pagetools.widgets.models.TemplateTagWidget(*args, **kwargs)[source]

Bases: BaseWidget

Renders a TemplateTag

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

adapter

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

get_content(context, request)[source]
get_renderclasskey_display(*, field=<django.db.models.fields.CharField: renderclasskey>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

key_choices = [('latest_question', 'latest_question'), ('subscribe', 'subscribe')]
load_templatetag_instance()[source]

Set the TemplateTag-like instance

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
renderclasskey

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pagetools.widgets.models.TypeArea(*args, **kwargs)[source]

Bases: LangModel

An area associated with a PageType

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

area

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

get_area_display(*, field=<django.db.models.fields.CharField: area>)
get_lang_display(*, field=<django.db.models.fields.CharField: lang>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lang

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pagetools.models.LangManager object>
pagetype

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

pagetype_id
widgets

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pagetools.widgets.models.WidgetInArea(*args, **kwargs)[source]

Bases: Model

A widget associated with an area

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

adminedit_url()[source]
content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_type_id
enabled

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_content(contextdict, request)[source]
get_title()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

object_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

typearea

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

typearea_id

pagetools.widgets.settings module

pagetools.widgets.utils module

pagetools.widgets.utils.get_areas_for_type(pagetype, contextdict, request, tmpdict=None)[source]
pagetools.widgets.utils.itersubclasses(cls)[source]

Generator over all subclasses of a given class, in depth first order.

>>> list(itersubclasses(int)) == [bool]
True
>>> class A(object): pass
>>> class B(A): pass
>>> class C(A): pass
>>> class D(B,C): pass
>>> class E(D): pass
>>>
>>> for cls in itersubclasses(A):
...     print(cls.__name__)
B
D
E
C
>>> # get ALL (new-style) classes currently defined
>>> [cls.__name__ for cls in itersubclasses(object)] 
['type', ...'tuple', ...]
pagetools.widgets.utils.type_or_none(typename)[source]

pagetools.widgets.views module

class pagetools.widgets.views.WidgetPagelikeMixin[source]

Bases: WidgetViewMixin

A WidgetViewMixin that tries to find the pagetype_name by kwargs or attribute

get_pagetype_name(**kwargs)[source]
class pagetools.widgets.views.WidgetViewMixin[source]

Bases: object

Add areas context data.

Expects a get_pagetype_name method, see WidgetPagelikeMixin See ::class::pagetools.widgets.models.WidgetInArea

add_pagetype_promise = True

If set, the widget context processor will not adding areas

get_context_data(**kwargs)[source]
get_pagetype(ptname=None, **kwargs)[source]

Module contents