Skip to content
Browse files

Update docs to use declarative-style.

  • Loading branch information...
1 parent 3d674bb commit 6a92e44c2a6ef34e0a4e4869cb3d567bb878919c @dnouri dnouri committed Mar 14, 2012
Showing with 33 additions and 33 deletions.
  1. +8 −9 docs/developer-manual.rst
  2. +24 −23 kotti/resources.py
  3. +1 −1 kotti/views/file.py
View
17 docs/developer-manual.rst
@@ -29,9 +29,16 @@ Document content type serves as an example here:
from kotti.resources import Content
class Document(Content):
+ __tablename__ = 'documents'
+ __mapper_args__ = dict(polymorphic_identity='document')
+
+ id = Column(Integer(), ForeignKey('contents.id'), primary_key=True)
+ body = Column(UnicodeText())
+ mime_type = Column(String(30))
+
type_info = Content.type_info.copy(
name=u'Document',
- title=u'Document',
+ title=_(u'Document'),
add_view=u'add_document',
addable_to=[u'Document'],
)
@@ -41,14 +48,6 @@ Document content type serves as an example here:
self.body = body
self.mime_type = mime_type
- documents = Table('documents', metadata,
- Column('id', Integer, ForeignKey('contents.id'), primary_key=True),
- Column('body', UnicodeText()),
- Column('mime_type', String(30)),
- )
-
- mapper(Document, documents, inherits=Content, polymorphic_identity='document')
-
You can configure the list of active content types in Kotti by
modifying the :ref:`kotti.available_types` setting.
View
47 kotti/resources.py
@@ -135,8 +135,11 @@ class Node(Base, ContainerMixin, PersistentACLMixin):
id = Column(Integer(), primary_key=True)
type = Column(String(30), nullable=False)
- __mapper_args__ = dict(polymorphic_on=type,
- polymorphic_identity='node', with_polymorphic='*')
+ __mapper_args__ = dict(
+ polymorphic_on=type,
+ polymorphic_identity='node',
+ with_polymorphic='*',
+ )
parent_id = Column(ForeignKey('nodes.id'))
position = Column(Integer())
@@ -231,6 +234,15 @@ class Content(Node):
__tablename__ = 'contents'
__mapper_args__ = dict(polymorphic_identity='content')
+ id = Column('id', Integer, ForeignKey('nodes.id'), primary_key=True)
+ default_view = Column(String(50))
+ description = Column(UnicodeText())
+ language = Column(Unicode(10))
+ owner = Column(Unicode(100))
+ creation_date = Column(DateTime())
+ modification_date = Column(DateTime())
+ in_navigation = Column(Boolean())
+
type_info = TypeInfo(
name=u'Content',
title=u'type_info title missing', # BBB
@@ -242,15 +254,6 @@ class Content(Node):
],
)
- id = Column('id', Integer, ForeignKey('nodes.id'), primary_key=True)
- default_view = Column(String(50))
- description = Column(UnicodeText())
- language = Column(Unicode(10))
- owner = Column(Unicode(100))
- creation_date = Column(DateTime())
- modification_date = Column(DateTime())
- in_navigation = Column(Boolean())
-
def __init__(self, name=None, parent=None, title=u"", annotations=None,
default_view=None, description=u"", language=None,
owner=None, creation_date=None, modification_date=None,
@@ -267,45 +270,43 @@ def __init__(self, name=None, parent=None, title=u"", annotations=None,
class Document(Content):
-
__tablename__ = 'documents'
__mapper_args__ = dict(polymorphic_identity='document')
+ id = Column(Integer(), ForeignKey('contents.id'), primary_key=True)
+ body = Column(UnicodeText())
+ mime_type = Column(String(30))
+
type_info = Content.type_info.copy(
name=u'Document',
title=_(u'Document'),
add_view=u'add_document',
addable_to=[u'Document'],
)
- id = Column(Integer(), ForeignKey('contents.id'), primary_key=True)
- body = Column(UnicodeText())
- mime_type = Column(String(30))
-
def __init__(self, body=u"", mime_type='text/html', **kwargs):
super(Document, self).__init__(**kwargs)
self.body = body
self.mime_type = mime_type
class File(Content):
-
__tablename__ = 'files'
__mapper_args__ = dict(polymorphic_identity='file')
+ id = Column(Integer(), ForeignKey('contents.id'), primary_key=True)
+ data = Column(LargeBinary())
+ filename = Column(Unicode(100))
+ mimetype = Column(String(100))
+ size = Column(Integer())
+
type_info = Content.type_info.copy(
name=u'File',
title=_(u'File'),
add_view=u'add_file',
addable_to=[u'Document'],
)
- id = Column(Integer(), ForeignKey('contents.id'), primary_key=True)
- data = Column(LargeBinary())
- filename = Column(Unicode(100))
- mimetype = Column(String(100))
- size = Column(Integer())
-
def __init__(self, data=None, filename=None, mimetype=None, size=None,
**kwargs):
super(File, self).__init__(**kwargs)
View
2 kotti/views/file.py
@@ -51,7 +51,7 @@ def inline_view(context, request, disposition='inline'):
],
app_iter=context.data,
)
-
+
return res
def attachment_view(context, request):

0 comments on commit 6a92e44

Please sign in to comment.
Something went wrong with that request. Please try again.