Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/Extensions/utils.py
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/Extensions/utils.py	(revision 1239)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/Extensions/utils.py	(revision 1239)
@@ -0,0 +1,59 @@
+from zope.interface import alsoProvides, noLongerProvides
+
+from quills.app.utilities import recurseToInterface
+from quills.core.interfaces import IWeblogEnhanced
+from quills.core.interfaces.enabled import IPossibleWeblogEntry
+
+from Products.CMFCore.utils import getToolByName
+
+from quintagroup.quills.extras.browser.interfaces import IWeblogCategory
+from zope.component import getSiteManager
+
+def set_layout(sc_info):
+    #portal = sc_info.getPortal()
+    obj = sc_info.object
+    weblog = recurseToInterface(obj, IWeblogEnhanced)
+    if weblog:
+        updateBlogPost(obj)
+
+def updateBlogPost(obj):
+    # set default layout
+    obj.setLayout('weblogentry_view')
+    # add providing of IPossibleWeblogEntry interface
+    if not IPossibleWeblogEntry.providedBy(obj):
+        alsoProvides(obj, IPossibleWeblogEntry)
+    # allow discussion for object
+    dt = getToolByName(obj,'portal_discussion')
+    dt.overrideDiscussionFor(obj, 1)
+
+def processBlog(self, path, blogentry_types=["Document",]):
+    catalog = getToolByName(self,'portal_catalog')
+    brains = catalog(path=path, portal_type=blogentry_types)
+    for b in brains:
+        obj = b.getObject()
+        updateBlogPost(obj)
+        print b.getURL(), 'updated'
+    #raise Exception("some error")
+
+
+def processBlogSubFolders(self):
+    # update blog sub-folders
+    res = []
+    brains = self.portal_catalog(path='/'.join(self.getPhysicalPath()),
+                                 portal_type=['Large Plone Folder','Folder'])
+    context_path = '/'.join(self.getPhysicalPath())
+    brains = filter(lambda b:not b.getPath()==context_path, brains)
+    for bf in brains:
+        item_res = [bf.getPath(),0,0]
+        ob = bf.getObject()
+        if ob.hasProperty('layout'):
+            ob.manage_delProperties(['layout',])
+        ob.manage_addProperty('layout','weblogfolder_view','string')
+        if IWeblogEnhanced.providedBy(ob):
+            noLongerProvides(ob,IWeblogEnhanced)
+            item_res[1] = 1
+        if not IWeblogCategory.providedBy(ob):
+            alsoProvides(ob,IWeblogCategory)
+            item_res[2] = 1
+        res.append(item_res)
+    return res
Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/contentrules.xml
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/contentrules.xml	(revision 1239)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/contentrules.xml	(revision 1239)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<contentrules>
+ <rule name="rule-1" title="Add_blog_content" description="" enabled="True"
+    event="zope.app.container.interfaces.IObjectAddedEvent"
+    stop-after="False">
+  <conditions>
+   <condition type="plone.conditions.PortalType">
+    <property name="check_types">
+     <element>Document</element>
+    </property>
+   </condition>
+  </conditions>
+  <actions>
+   <action type="plone.actions.Workflow">
+    <property name="transition">update_layout</property>
+   </action>
+  </actions>
+ </rule>
+ <assignment name="rule-1" bubbles="True" enabled="True" location=""/>
+</contentrules>
Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/workflows/simple_publication_workflow/definition.xml
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/workflows/simple_publication_workflow/definition.xml	(revision 1239)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/profiles/default/workflows/simple_publication_workflow/definition.xml	(revision 1239)
@@ -0,0 +1,248 @@
+<?xml version="1.0"?>
+<dc-workflow workflow_id="simple_publication_workflow"
+             title="Simple Publication Workflow"
+             description=" - Simple workflow that is useful for basic web sites. - Things start out as private, and can either be submitted for review, or published directly. - The creator of a content item can edit the item even after it is published."
+             state_variable="review_state"
+             initial_state="private">
+ <permission>Access contents information</permission>
+ <permission>Change portal events</permission>
+ <permission>List folder contents</permission>
+ <permission>Modify portal content</permission>
+ <permission>View</permission>
+ <state state_id="pending" title="Pending review">
+  <description>Waiting to be reviewed, not editable by the owner.
+</description>
+  <exit-transition transition_id="make_private"/>
+  <exit-transition transition_id="publish"/>
+  <exit-transition transition_id="reject"/>
+  <exit-transition transition_id="retract"/>
+  <permission-map name="Access contents information"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+   <permission-role>Reviewer</permission-role>
+  </permission-map>
+  <permission-map name="Change portal events"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Reviewer</permission-role>
+  </permission-map>
+  <permission-map name="List folder contents"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+   <permission-role>Reviewer</permission-role>
+  </permission-map>
+  <permission-map name="Modify portal content"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Reviewer</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+   <permission-role>Reviewer</permission-role>
+  </permission-map>
+ </state>
+ <state state_id="private" title="Private">
+  <description>Can only be seen and edited by the owner.
+</description>
+  <exit-transition transition_id="publish"/>
+  <exit-transition transition_id="submit"/>
+  <exit-transition transition_id="update_layout"/>
+  <permission-map name="Access contents information"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+  </permission-map>
+  <permission-map name="Change portal events"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+  </permission-map>
+  <permission-map name="List folder contents"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+  </permission-map>
+  <permission-map name="Modify portal content"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+   <permission-role>Reader</permission-role>
+   <permission-role>Contributor</permission-role>
+  </permission-map>
+ </state>
+ <state state_id="published" title="Published">
+  <description>Visible to everyone, not editable by the owner.
+</description>
+  <exit-transition transition_id="retract"/>
+  <exit-transition transition_id="reject"/>
+  <exit-transition transition_id="update_layout"/>
+  <permission-map name="Access contents information"
+                  acquired="False">
+   <permission-role>Anonymous</permission-role>
+  </permission-map>
+  <permission-map name="Change portal events"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+  </permission-map>
+  <permission-map name="List folder contents"
+                  acquired="False">
+   <permission-role>Anonymous</permission-role>
+  </permission-map>
+  <permission-map name="Modify portal content"
+                  acquired="False">
+   <permission-role>Manager</permission-role>
+   <permission-role>Owner</permission-role>
+   <permission-role>Editor</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="False">
+   <permission-role>Anonymous</permission-role>
+  </permission-map>
+ </state>
+ <transition transition_id="publish"
+             title="Reviewer publishes content"
+             new_state="published" trigger="USER"
+             before_script="" after_script="">
+  <description>Publishing the item makes it visible to other users.
+</description>
+  <action url="%(content_url)s/content_status_modify?workflow_action=publish"
+          category="workflow">Publish</action>
+  <guard>
+   <guard-permission>Review portal content</guard-permission>
+  </guard>
+ </transition>
+ <transition transition_id="reject"
+             title="Reviewer send content back for re-drafting"
+             new_state="private" trigger="USER"
+             before_script="" after_script="">
+  <description>Sending the item back will return the item to the original author instead of publishing it. You should preferably include a reason for why it was not published.
+</description>
+  <action url="%(content_url)s/content_status_modify?workflow_action=reject"
+          category="workflow">Send back</action>
+  <guard>
+   <guard-permission>Review portal content</guard-permission>
+  </guard>
+ </transition>
+ <transition transition_id="retract"
+             title="Member retracts submission"
+             new_state="private" trigger="USER"
+             before_script="" after_script="">
+  <description>If you submitted the item by mistake or want to perform additional edits, this will take it back.
+</description>
+  <action url="%(content_url)s/content_status_modify?workflow_action=retract"
+          category="workflow">Retract</action>
+  <guard>
+   <guard-permission>Request review</guard-permission>
+  </guard>
+ </transition>
+ <transition transition_id="submit"
+             title="Member submits content for publication"
+             new_state="pending" trigger="USER"
+             before_script="" after_script="">
+  <description>Puts your item in a review queue, so it can be published on the site.
+</description>
+  <action url="%(content_url)s/content_status_modify?workflow_action=submit"
+          category="workflow">Submit for publication</action>
+  <guard>
+   <guard-permission>Request review</guard-permission>
+  </guard>
+ </transition>
+ <transition transition_id="update_layout" title=""
+             new_state="" trigger="USER" before_script=""
+             after_script="set_layout">
+  
+  <guard>
+  </guard>
+ </transition>
+ <worklist worklist_id="reviewer_queue" title="">
+  <description>Reviewer tasks</description>
+  <action url="%(portal_url)s/search?review_state=pending"
+          category="global">Pending (%(count)d)</action>
+  <guard>
+   <guard-permission>Review portal content</guard-permission>
+  </guard>
+  <match name="review_state" values="pending"/>
+ </worklist>
+ <variable variable_id="action" for_catalog="False"
+           for_status="True" update_always="True">
+  <description>Previous transition</description>
+  <default>
+   
+   <expression>transition/getId|nothing</expression>
+  </default>
+  <guard>
+  </guard>
+ </variable>
+ <variable variable_id="actor" for_catalog="False"
+           for_status="True" update_always="True">
+  <description>The ID of the user who performed the previous transition</description>
+  <default>
+   
+   <expression>user/getUserName</expression>
+  </default>
+  <guard>
+  </guard>
+ </variable>
+ <variable variable_id="comments" for_catalog="False"
+           for_status="True" update_always="True">
+  <description>Comment about the last transition</description>
+  <default>
+   
+   <expression>python:state_change.kwargs.get('comment', '')</expression>
+  </default>
+  <guard>
+  </guard>
+ </variable>
+ <variable variable_id="review_history" for_catalog="False"
+           for_status="False" update_always="False">
+  <description>Provides access to workflow history</description>
+  <default>
+   
+   <expression>state_change/getHistory</expression>
+  </default>
+  <guard>
+   <guard-permission>Request review</guard-permission>
+   <guard-permission>Review portal content</guard-permission>
+  </guard>
+ </variable>
+ <variable variable_id="time" for_catalog="False"
+           for_status="True" update_always="True">
+  <description>When the previous transition was performed</description>
+  <default>
+   
+   <expression>state_change/getDateTime</expression>
+  </default>
+  <guard>
+  </guard>
+ </variable>
+ <script script_id="set_layout" type="External Method"
+         filename=""
+         module="quintagroup.quills.extras.utils"
+         function="set_layout"/>
+</dc-workflow>
Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/base.py
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/base.py	(revision 1227)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/base.py	(revision 1239)
@@ -7,7 +7,22 @@
 
 ZOPE_DEPS = []
+
+try:
+    import quintagroup.plonecomments
+except ImportError:
+    QPC_PACKAGE = False
+    from Products import qPloneComments
+else:
+    QPC_PACKAGE = True
+
 PLONE_INSTALL = ['QuillsEnabled', 'AutocompleteWidget', 
                  'quintagroup.plonecomments', 'quintagroup.quills.extras']
 PLONE_DEPS = ['QuillsEnabled', 'AutocompleteWidget']
+
+if QPC_PACKAGE:
+    PLONE_INSTALL += ['quintagroup.plonecomments',]
+else:
+    PLONE_INSTALL += ['qPloneComments',]
+    PLONE_DEPS    += ['qPloneComments',]
 
 @onsetup
@@ -19,13 +34,15 @@
     # and its dependencies
     fiveconfigure.debug_mode = True
-    import quintagroup.plonecomments
     import quintagroup.quills.extras
-    zcml.load_config('configure.zcml', quintagroup.plonecomments)
-    zcml.load_config('overrides.zcml', quintagroup.plonecomments)
     zcml.load_config('configure.zcml', quintagroup.quills.extras)
     zcml.load_config('overrides.zcml', quintagroup.quills.extras)
+    if QPC_PACKAGE:
+        import quintagroup.plonecomments
+        zcml.load_config('configure.zcml', quintagroup.plonecomments)
+        zcml.load_config('overrides.zcml', quintagroup.plonecomments)
+        ztc.installPackage('quintagroup.plonecomments')
+
     fiveconfigure.debug_mode = False
 
-    ztc.installPackage('quintagroup.plonecomments')
 
 for p in PLONE_INSTALL:
@@ -34,2 +51,4 @@
 setup_quillsextras_policy()
 ptc.setupPloneSite(products=PLONE_INSTALL)
+
+import patches
Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/extras_fixedBugs.rst
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/extras_fixedBugs.rst	(revision 1227)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/extras_fixedBugs.rst	(revision 1239)
@@ -873,5 +873,5 @@
 
     >>> browser.contents
-    '...<h2>...Issue #202...</h2>...'
+    '...<h2...>...Issue #202...</h2>...'
        
 
Index: quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/patches.py
===================================================================
--- quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/patches.py	(revision 1239)
+++ quintagroup.quills.extras/trunk/quintagroup/quills/extras/tests/patches.py	(revision 1239)
@@ -0,0 +1,25 @@
+#
+# PATCH DEFERRED CONTENT RULE EXECUTION ON ADDING AT OBJECTS
+#
+# this behavior not suite for testing quills because of
+# in tests it uses addEntry method, which perform adding
+# blog post with only one invokeFactory method without
+# following steps (performed in TTW plone operation)
+#
+
+from plone.app.contentrules import handlers as pcrh
+def patched_added(event):
+    """When an object is added, execute rules assigned to its new parent.
+
+    There is special handling for Archetypes objects.
+    """
+    if pcrh.is_portal_factory(event.object):
+        return
+
+    # The object added event executes too early for Archetypes objects.
+    # We need to delay execution until we receive a subsequent IObjectInitializedEvent
+
+    pcrh.init()
+    pcrh.execute(event.newParent, event)
+
+pcrh.added = patched_added
