Ticket #193: page_msg_patch_not_complete1.txt

File page_msg_patch_not_complete1.txt, 27.7 KB (added by JensDiemer, 22 months ago)

not complete page_msg refactory

Line 
1Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/index.py
2===================================================================
3--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/index.py (revision 1580)
4+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/index.py (working copy)
5@@ -82,6 +82,8 @@
6     # django template engine:
7     content = replace_add_data(context, content)
8 
9+    print "XXX", request.page_msg
10+
11     return HttpResponse(content)
12 
13 
14@@ -97,10 +99,11 @@
15 
16     context = RequestContext(request)
17 
18-    context["page_msg"] = PageMessages(context)
19+    request.page_msg = PageMessages(context)
20 
21     # Redirect every "warning" messages into the page_msg:
22-    redirect_warnings(context["page_msg"])
23+#    redirect_warnings(request.page_msg)
24+    redirect_warnings(request.page_msg)
25 
26     context["PAGE"] = current_page_obj
27     context["URLs"] = URLs(context)
28@@ -121,9 +124,17 @@
29     add_dynamic_context(request, context)
30 
31     # Add the context to the reponse object.
32-    # Used in PyLucid.middlewares.additional_content
33+    # Used in PyLucid middlewares
34     request.CONTEXT = context
35 
36+    # TODO: remove Backwards-incompatible changes in >v0.8.5
37+    msg = (
38+        'Error, see: <a href="'
39+        'http://www.pylucid.org/_goto/121/changes/#20-05-2008-page_msg'
40+        '">pylucid.org - Backwards-incompatible changes - page_msg</a>'
41+    )
42+    context["messages"] = [mark_safe(msg)]
43+
44     return context
45 
46 
47Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/BaseInstall.py
48===================================================================
49--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/BaseInstall.py   (revision 1580)
50+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/BaseInstall.py   (working copy)
51@@ -129,10 +129,10 @@
52         self.context = get_base_context(request)
53 
54         self.page_msg = PageMessages(self.context)
55-        self.context["page_msg"] = self.page_msg
56+        self.request.page_msg = self.page_msg
57 
58-        # Redirect every "warning" messages into context["page_msg"]:
59-        redirect_warnings(self.context["page_msg"])
60+        # Redirect every "warning" messages into request.page_msg:
61+        redirect_warnings(self.request.page_msg)
62 
63     #___________________________________________________________________________
64 
65@@ -144,7 +144,7 @@
66         self.context["no_menu_link"] = True
67 
68         if msg and msg != "": # insert the messages:
69-            self.context["page_msg"].write(msg)
70+            self.request.page_msg.write(msg)
71 
72         return render_to_response(
73             "install_generate_hash.html", self.context
74@@ -171,7 +171,7 @@
75         except Exception, msg:
76             # Cookie is not set or the salt hash value compair failed
77             if DEBUG:
78-                self.context["page_msg"].write("DEBUG: %s" % msg)
79+                self.request.page_msg.write("DEBUG: %s" % msg)
80         else:
81             # access ok -> start the normal _install view() method
82             return self.view(*args)
83@@ -189,7 +189,7 @@
84                     check_password_hash(password_hash)
85                 except WrongPassword, msg:
86                     # Display the form again
87-                    self.context["page_msg"].write(msg)
88+                    self.request.page_msg.write(msg)
89                 else:
90                     # Password is ok. -> process the normal _instal view()
91                     response = self.view(*args)
92@@ -204,7 +204,7 @@
93         self.context["salt"] = data["salt"]
94 
95         self.context["no_menu_link"] = True # no "back to menu" link
96-#        self.context["page_msg"].write(_("Please input the password"))
97+#        self.request.page_msg.write(_("Please input the password"))
98         return render_to_response("install_login.html", self.context)
99 
100    #___________________________________________________________________________
101Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/update.py
102===================================================================
103--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/update.py        (revision 1580)
104+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/install/update.py        (working copy)
105@@ -18,12 +18,20 @@
106 from django.contrib.auth.models import User
107 
108 #______________________________________________________________________________
109+
110+import re
111+from PyLucid.tools.Diff import diff_lines
112+
113+page_msg_re = re.compile(r""".*?({% if messages %}.*?{% endif %})*.?(?uims)""")
114+new_page_msg = "<!-- page_messages -->"
115+
116 class Update2(BaseInstall):
117     def view(self):
118         self._redirect_execute(self._update_tables)
119+        self._redirect_execute(self._update_templates)
120 
121         return self._simple_render(
122-            headline="Update PyLucid from v0.8.0 to v0.8.1"
123+            headline="Update PyLucid from v0.8.0 to v0.8.5"
124         )
125 
126     def _update_tables(self):
127@@ -39,10 +47,21 @@
128             else:
129                 print "OK"
130 
131+    def _update_templates(self):
132+        print "update templates:"
133+        templates = Template.objects.all()
134+        for template in templates:
135+            new_content = old_content = template.content
136+
137+            for match in page_msg_re.findall(old_content):
138+                new_content = new_content.replace(match, new_page_msg)
139+
140+            diff = diff_lines(old_content, new_content)
141+            print diff
142 
143 def update2(request):
144     """
145-    1. update from v0.8.0 to v0.8.1
146+    1. update from v0.8.0 to v0.8.5
147     """
148     return Update2(request).start_view()
149 
150@@ -427,18 +446,9 @@
151     "|"
152     "<lucid(Function):(.*?)>(.*?)</lucidFunction>"
153 )
154-PAGE_MSG_TAG = """\
155-  {% if messages %}
156-    <fieldset id="page_msg"><legend>page message</legend>
157-    {% for message in messages %}
158-      {{ message }}<br />
159-    {% endfor %}
160-    </fieldset>
161-  {% endif %}\
162-"""
163 
164 CHANGE_TAGS = {
165-    "page_msg": PAGE_MSG_TAG,
166+    "page_msg": "<!-- page_messages -->",
167     "script_login": "{{ login_link }}",
168     "robots": "{{ robots }}",
169     "powered_by": "{{ powered_by }}",
170Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagemessages.py
171===================================================================
172--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagemessages.py      (revision 0)
173+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagemessages.py      (revision 0)
174@@ -0,0 +1,54 @@
175+ # -*- coding: utf-8 -*-
176+
177+"""
178+    PyLucid page messages
179+    ~~~~~~~~~~~~~~~~~~~~~
180+
181+    Last commit info:
182+    ~~~~~~~~~~~~~~~~~
183+    $LastChangedDate: $
184+    $Rev: $
185+    $Author: $
186+
187+    :copyleft: 2008 by Jens Diemer
188+    :license: GNU GPL v3, see LICENSE.txt for more details.
189+"""
190+
191+from PyLucid.tools.content_processors import render_string_template
192+from PyLucid.middlewares.utils import is_html, replace_content
193+
194+TAG = u"<!-- page_messages -->"
195+
196+TEMPLATE = \
197+u"""<fieldset id="page_msg"><legend>page message</legend>
198+{% for message in page_msg %}
199+    {{ message }}<br />
200+{% endfor %}
201+</fieldset>"""
202+
203+class PageMessagesMiddleware(object):
204+    def process_response(self, request, response):
205+        """
206+        insert all page messages into the html page.
207+        """
208+        if not is_html(response):
209+            # No HTML Page -> do nothing
210+            return response
211+
212+        try:
213+            # get PyLucid.system.page_msg.PageMessages():
214+            page_msg = request.page_msg
215+        except AttributeError, e:
216+            message_string = "Error getting page_msg: %s" % e
217+        else:
218+            if len(page_msg) == 0:
219+                # There exists no page messages
220+                message_string = ""
221+            else:
222+                message_string = render_string_template(
223+                    TEMPLATE, context={"page_msg": page_msg}
224+                )
225+
226+        response = replace_content(response, TAG, message_string)
227+
228+        return response
229Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagestats.py
230===================================================================
231--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagestats.py (revision 1580)
232+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/pagestats.py (working copy)
233@@ -24,6 +24,7 @@
234 from django.db import connection
235 
236 from PyLucid.template_addons.filters import human_duration
237+from PyLucid.middlewares.utils import is_html, replace_content
238 
239 # Save the start time of the current running pyhon instance
240 start_overall = time()
241@@ -50,7 +51,7 @@
242         calculate the statistic and replace it into the html page.
243         """
244         # Put only the statistic into HTML pages
245-        if not "html" in response._headers["content-type"][1]:
246+        if not is_html(response):
247             # No HTML Page -> do nothing
248             return response
249 
250@@ -68,25 +69,18 @@
251             'queries' : queries,
252         }
253 
254-        content = response.content
255-        if not isinstance(content, unicode):
256-            # FIXME: In my shared webhosting environment is response.content a
257-            # string and not unicode. Why?
258-            from django.utils.encoding import force_unicode
259-            try:
260-                content = force_unicode(content)
261-            except:
262-                return response
263-
264-#        content = self.debug_sql_queries(content)
265+        # insert the page statistic
266+        response = replace_content(response, TAG, stat_info)
267 
268-        # insert the page statistic
269-        new_content = content.replace(TAG, stat_info)
270-        response.content = new_content
271+        #response = self.debug_sql_queries(response)
272 
273         return response
274 
275-    def debug_sql_queries(self, content):
276+    def debug_sql_queries(self, response):
277+        """
278+        Insert all SQL queries.
279+        ONLY for developers!
280+        """
281         show_only = ("PyLucid_plugin", "PyLucid_preference2")
282         sql_info = "<h2>Debug SQL queries:</h2>"
283         if show_only:
284@@ -105,5 +99,7 @@
285             sql = sql.replace(' WHERE "', '\nWHERE "')
286             sql_info += "\n%s\n%s\n" % (time, sql)
287         sql_info += "</pre></body>"
288-        content = content.replace("</body>", sql_info)
289-        return content
290\ No newline at end of file
291+
292+        response = replace_content(response, "</body>", sql_info)
293+
294+        return response
295\ No newline at end of file
296Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/utils.py
297===================================================================
298--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/utils.py     (revision 0)
299+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/middlewares/utils.py     (revision 0)
300@@ -0,0 +1,47 @@
301+ # -*- coding: utf-8 -*-
302+
303+"""
304+    PyLucid shared middleware utils
305+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306+
307+    Last commit info:
308+    ~~~~~~~~~~~~~~~~~
309+    $LastChangedDate: $
310+    $Rev: $
311+    $Author: $
312+
313+    :copyleft: 2008 by Jens Diemer
314+    :license: GNU GPL v3, see LICENSE.txt for more details.
315+"""
316+
317+def is_html(response):
318+    """
319+    returns a Bool if the response is a html page or not.
320+    """
321+    if not "html" in response._headers["content-type"][1]:
322+        # Isn't a HTML page
323+        return False
324+    else:
325+        # Is a HTML Page
326+        return True
327+
328+def replace_content(response, old, new):
329+    """
330+    -replace 'old' with 'new' in the response content.
331+    -returns the response object
332+    """
333+    content = response.content
334+    if not isinstance(content, unicode):
335+        # FIXME: In my shared webhosting environment is response.content a
336+        # string and not unicode. Why?
337+        from django.utils.encoding import force_unicode
338+        try:
339+            content = force_unicode(content)
340+        except:
341+            return response
342+
343+    # replace
344+    new_content = content.replace(old, new)
345+    response.content = new_content
346+
347+    return response
348Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/models.py
349===================================================================
350--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/models.py        (revision 1580)
351+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/models.py        (working copy)
352@@ -578,6 +578,10 @@
353         """
354         evaluate the pformat string into a dict and return it.
355         """
356+        if self.pref_data_string == None:
357+            # Plugin has no preferences inserted
358+            return None
359+
360         data_dict = data_eval(self.pref_data_string)
361         preference_cache[self.plugin_name] = data_dict
362         return data_dict
363Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/admin_menu/admin_menu.py
364===================================================================
365--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/admin_menu/admin_menu.py        (revision 1580)
366+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/admin_menu/admin_menu.py        (working copy)
367@@ -28,6 +28,8 @@
368         """
369         Render the front menu
370         """
371+        self.page_msg("from admin menu!")
372+
373         current_page_id  = self.current_page.id
374         edit_link = self.URLs.adminLink("PyLucid/page/%s/" % current_page_id)
375 
376Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links.py
377===================================================================
378--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links.py        (revision 1580)
379+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links.py        (working copy)
380@@ -35,16 +35,34 @@
381 
382 
383 from PyLucid.system.BasePlugin import PyLucidBasePlugin
384-from PyLucid.models import Page, Preference
385+from PyLucid.models import Page, Plugin
386 
387 class back_links(PyLucidBasePlugin):
388 
389-    def lucidTag(self, print_last_page=False, print_index=False, index="Index"):
390+    def lucidTag(self, **kwargs):
391         """
392         generate the backlinks
393+        TODO: **kwargs only for Backwards-incompatible changes info
394         """
395+        if self.request.debug == True and kwargs != {}:
396+            self.page_msg(
397+                "DeprecationWarning:"
398+                " kwargs in back_links plugin are obsolete. Please remove them."
399+            )
400+            return
401+
402+        # Get the preferences from the database:
403+        preferences = self.get_preferences()
404+        if preferences == None:
405+            # preferences not in database -> reinit required
406+            if self.request.debug == True:
407+                self.page_msg.red(
408+                    "reinit 'back_links' plugin required!"
409+                )
410+                return
411+
412         current_page = self.context["PAGE"]
413-        if print_last_page == True:
414+        if preferences["print_last_page"] == True:
415             print_page = current_page
416         else:
417             print_page = current_page.parent
418@@ -52,7 +70,7 @@
419                 # There exist no higher-ranking page
420                 return ""
421 
422-        data = self.backlink_data(print_page)
423+        data = self._backlink_data(print_page)
424         data.reverse()
425 
426         context = {
427@@ -57,12 +75,12 @@
428 
429         context = {
430             "pages": data,
431-            "print_index": print_index,
432-            "index": index,
433+            "print_index": preferences["print_index"],
434+            "index": preferences["index"],
435         }
436         self._render_template("back_links", context)#, debug=True)
437 
438-    def backlink_data(self, parent_page):
439+    def _backlink_data(self, parent_page):
440         """
441         make a list of all pages in the current way back to the index page.
442         """
443Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links_cfg.py
444===================================================================
445--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links_cfg.py    (revision 1580)
446+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/back_links/back_links_cfg.py    (working copy)
447@@ -11,6 +11,29 @@
448 """
449 
450 #_____________________________________________________________________________
451+# preferences
452+
453+from django import newforms as forms
454+from django.utils.translation import ugettext as _
455+
456+class PreferencesForm(forms.Form):
457+    print_last_page = forms.BooleanField(
458+        initial = False,
459+        help_text = _(
460+            "if == True: then the actual page will be the last page in the bar."
461+            " Otherwise the parentpage."
462+        ),
463+    )
464+    print_index = forms.BooleanField(
465+        initial = False,
466+        help_text = _('If == True: display a link to the index ("/")'),
467+    )
468+    index = forms.CharField(
469+        initial = _("Index"),
470+        help_text = _('the name that is printed for the indexpage'),
471+    )
472+
473+#_____________________________________________________________________________
474 # plugin administration data
475 
476 plugin_manager_data = {
477Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/filemanager/filemanager.py
478===================================================================
479--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/filemanager/filemanager.py      (revision 1580)
480+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/filemanager/filemanager.py      (working copy)
481@@ -251,7 +251,7 @@
482     def __init__(self, context):
483         self.context     = context
484         self.request     = context["request"]
485-        self.page_msg    = context["page_msg"]
486+        self.page_msg    = request.page_msg
487 
488     def new_dir_path(self, path_info, must_exist=True):
489         """
490Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/main_menu/main_menu.py
491===================================================================
492--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/main_menu/main_menu.py  (revision 1580)
493+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/plugins_internal/main_menu/main_menu.py  (working copy)
494@@ -41,6 +41,8 @@
495         """
496         write the current opened tree menu
497         """
498+        self.page_msg("from main_menu")
499+
500         current_page = self.context["PAGE"]
501         self.current_page_id  = current_page.id
502 
503Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/settings_example.py
504===================================================================
505--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/settings_example.py      (revision 1580)
506+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/settings_example.py      (working copy)
507@@ -86,6 +86,8 @@
508     # Insert a statistic line into the generated page:
509     'PyLucid.middlewares.pagestats.PageStatsMiddleware',
510 
511+    'PyLucid.middlewares.pagemessages.PageMessagesMiddleware',
512+
513     # PyLucidCommonMiddleware loads the django middlewares:
514     #    - 'django.contrib.sessions.middleware.SessionMiddleware'
515     #    - 'django.contrib.auth.middleware.AuthenticationMiddleware'
516Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/BasePlugin.py
517===================================================================
518--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/BasePlugin.py     (revision 1580)
519+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/BasePlugin.py     (working copy)
520@@ -51,11 +51,11 @@
521         self.plugin_name = self.__class__.__name__
522         self.internal_page = InternalPage(context, self.plugin_name)
523 
524+        self.request    = context["request"]
525+        self.response   = response
526         self.context    = context
527-        self.response   = response
528 
529-        self.request    = context["request"]
530-        self.page_msg   = context["page_msg"]
531+        self.page_msg   = self.request.page_msg
532         self.URLs       = context["URLs"]
533 
534         self.current_page = self.context["PAGE"]
535@@ -60,6 +60,18 @@
536 
537         self.current_page = self.context["PAGE"]
538 
539+        self.__preference_cache = None
540+
541+    def get_preferences(self):
542+        """
543+        returns the preferences from the database as a dict
544+        """
545+        if self.__preference_cache == None:
546+            self.__preference_cache = Plugin.objects.get_preferences(
547+                self.plugin_name
548+            )
549+        return self.__preference_cache
550+
551     def build_menu(self):
552         """
553         Build a simple menu for all plugin methods witch have a "menu_section"
554Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/internal_page.py
555===================================================================
556--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/internal_page.py  (revision 1580)
557+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/internal_page.py  (working copy)
558@@ -36,8 +36,9 @@
559     "custom_internal_page_root" - filesystem path to customized internal pages
560     """
561     def __init__(self, context, plugin_name):
562-        self.page_msg   = context["page_msg"]
563-        self.URLs       = context["URLs"]
564+        self.request     = context["request"]
565+        self.page_msg    = self.request.page_msg
566+        self.URLs        = context["URLs"]
567 
568         self.plugin_name = plugin_name
569 
570Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/markups/tinyTextile.py
571===================================================================
572--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/markups/tinyTextile.py    (revision 1580)
573+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/markups/tinyTextile.py    (working copy)
574@@ -24,9 +24,9 @@
575 
576     Last commit info:
577     ~~~~~~~~~~~~~~~~~
578-    $LastChangedDate$
579-    $Rev$
580-    $Author$
581+    $LastChangedDate:2008-05-13 18:26:55 +0200 (Di, 13 Mai 2008) $
582+    $Rev:1561 $
583+    $Author:JensDiemer $
584 
585     :copyleft: 2007-2008 by Jens Diemer
586     :license: GNU GPL v3, see LICENSE.txt for more details.
587@@ -33,7 +33,7 @@
588 """
589 
590 
591-__version__ = "$Rev$"
592+__version__ = "$Rev:1561 $"
593 
594 import sys, re
595 
596@@ -45,7 +45,7 @@
597     def __init__(self, out_obj, context):
598         self.out = out_obj
599         self.context = context
600-        self.page_msg   = context["page_msg"]
601+        self.page_msg = context["request"].page_msg
602 
603         # Blockelements
604         self.block_rules = self._compile_rules([
605Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/page_msg.py
606===================================================================
607--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/page_msg.py       (revision 1580)
608+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/page_msg.py       (working copy)
609@@ -45,14 +45,14 @@
610     http://www.djangoproject.com/documentation/authentication/#messages
611     """
612     def __init__(self, context):
613+        request = context["request"]
614+
615         try:
616-            self.messages = context["messages"]
617-        except KeyError:
618-            # No django messages inserted by RequestContext
619-            # In the _install section we use no RequestContext ;)
620+            self.messages = request.user.get_and_delete_messages()
621+        except AttributeError:
622+            # In the _install section we have no user
623             self.messages = []
624 
625-        request = context["request"]
626         self.debug_mode = getattr(request, "debug", False)
627 
628         self._charset = settings.DEFAULT_CHARSET
629@@ -84,7 +84,7 @@
630         msg = '<span style="color:%s;">%s</span>' % (
631             color, self.prepare(*msg)
632         )
633-
634+        print "page_msg:", msg
635         #~ self.request.user.message_set.create(message=msg)
636         msg = mark_safe(msg) # turn djngo auto-escaping off
637         self.messages.append(msg)
638@@ -156,6 +156,17 @@
639             return repr(txt)
640 
641     #________________________________________________________________
642+
643+    def __repr__(self):
644+        return "page messages: %s" % repr(self.messages)
645+
646+    def __str__(self):
647+        return "pages messages: %s" % ", ".join(self.messages)
648+
649+    def __unicode__(self):
650+        return u"page messages: %s" % u", ".join(self.messages)
651+
652+    #________________________________________________________________
653     # Some methods for the django template engine:
654 
655     def __iter__(self):
656Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/plugin_manager.py
657===================================================================
658--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/plugin_manager.py (revision 1580)
659+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/plugin_manager.py (working copy)
660@@ -52,7 +52,7 @@
661         msg = "Error run plugin/plugin '%s.%s: %s" % (
662             plugin_name, method_name, msg
663         )
664-        context["page_msg"](msg)
665+        request.page_msg(msg)
666         msg2 = '<i title="(Error details in page messages.)">["%s.%s" error.]</i>' % (
667             plugin_name, method_name
668         )
669@@ -58,7 +58,7 @@
670         )
671         local_response.write(msg2)
672 
673-#    context["page_msg"](plugin_name, method_name)
674+#    request.page_msg(plugin_name, method_name)
675     try:
676         plugin = Plugin.objects.get(plugin_name=plugin_name)
677     except Plugin.DoesNotExist, e:
678@@ -72,7 +72,7 @@
679         plugin_name = plugin.plugin_name,
680         debug = request.debug,
681     )
682-#    context["page_msg"](plugin_config.plugin_manager_data)
683+#    request.page_msg(plugin_config.plugin_manager_data)
684     try:
685         method_cfg = plugin_config.plugin_manager_data[method_name]
686     except KeyError:
687@@ -81,7 +81,7 @@
688         error("Can't get config for the method '%s'." % method_name)
689         return
690 
691-#    context["page_msg"](method_cfg)
692+#    request.page_msg(method_cfg)
693     if method_cfg["must_login"]:
694         # User must be login to use this method
695         # http://www.djangoproject.com/documentation/authentication/
696@@ -145,9 +145,9 @@
697             raise
698 
699         msg = "Run plugin %s.%s Error" % (plugin_name, method_name)
700-        context["page_msg"].red("%s:" % msg)
701+        request.page_msg.red("%s:" % msg)
702         import sys, traceback
703-        context["page_msg"]("<pre>%s</pre>" % traceback.format_exc())
704+        request.page_msg("<pre>%s</pre>" % traceback.format_exc())
705         return msg + "(Look in the page_msg)"
706 
707 
708Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/URLs.py
709===================================================================
710--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/URLs.py   (revision 1580)
711+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/system/URLs.py   (working copy)
712@@ -10,7 +10,7 @@
713 
714     The view put a instance in context["URLs"]. The BasePlugin bind the class
715     to self. So every plugin can easy access the methods with self.URLs.
716-   
717+
718     more info: http://pylucid.org/_goto/62/self-URLs/
719 
720     Last commit info:
721@@ -101,7 +101,7 @@
722     def __init__(self, context):
723         self.context     = context
724         self.request     = context["request"]
725-        self.page_msg    = context["page_msg"]
726+        self.page_msg    = self.request.page_msg
727 
728         self.current_plugin = None
729 
730Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/tools/content_processors.py
731===================================================================
732--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/tools/content_processors.py      (revision 1580)
733+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/tools/content_processors.py      (working copy)
734@@ -127,7 +127,8 @@
735     Makrups IDs defined in
736         ./PyLucid/models.py
737     """
738-    page_msg = context["page_msg"]
739+    request  = context["request"]
740+    page_msg = request.page_msg
741 
742     if markup_no == 2: # textile
743         content = apply_tinytextile(content, context)
744Index: /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/urls.py
745===================================================================
746--- /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/urls.py  (revision 1580)
747+++ /home/jens/workspace/PyLucid_trunk/pylucid/PyLucid/urls.py  (working copy)
748@@ -116,6 +116,7 @@
749 # A normal CMS page url simply consists of the page shortcuts.
750 # The shortcuts contains only these chars: [a-zA-Z0-9_/-]
751 urls += (r'([\w/-]*)', 'PyLucid.index.index'),
752+urls += (r'^$', 'PyLucid.index.index'),
753 
754 
755 urlpatterns = patterns('', *urls)