Edit this section

For more information on developing and customizing MoinMoin, check MoinDev.

Not overriding do_action in MoinMoin.action.ActionBase results in TypeError

   1 ...
   2 
   3 def execute(pagename, request):
   4   print "executing MyTestAction"
   5   MyAction(pagename, request).render()
   6 
   7 class MyTestAction(ActionBase):
   8   def __init__(self, pagename, request):
   9     print "initializing MyTestAction in page", pagename
  10 
  11 ...

Now in the MoinMoin log:

2008-11-13 10:13:17,411 INFO MoinMoin.server.server_standalone:290 127.0.0.1 "GET /testMyAction HTTP/1.1" 200 -
executing MyTestAction
initializing MyTestAction in page testMyAction
2008-11-13 10:13:18,234 ERROR MoinMoin.failure:159 An exception occured.
Traceback (most recent call last):
  File "/tmp/moin-1.7.1/MoinMoin/request/__init__.py", line 1307, in run
    handler(self.page.page_name, self)
  File "/tmp/moin-1.7.1/wiki/data/plugin/action/MyTestAction.py", line 38, in execute
    MyTestAction(pagename, request).render()
  File "/tmp/moin-1.7.1/MoinMoin/action/__init__.py", line 204, in render
    success, self.error = self.do_action()
TypeError: unpack non-sequence

The comment for MoinMoin.action.ActionBase.do_action says that this method is supposed to "Do the action and either return error msg or None, if there was no error." But it seems that when render calls do_action it is distinctly expecting a Tuple, not just a single value. Either the documentation or the return type should be updated.

How to fill JSON Data in javascript Module in MoinMoin environment?

1. This cgi-stuff in cgi-bin of webserver directory works:

file: .../cgi-bin/tree.cgi:

{{{#!c:/Python24/Python.exe

JSONTEXT=""" [

]"""

print "Content-type: text/html" print print JSONTEXT }}} 2. What is the procedure to do the same in MoinMoin?

This stuff in an "action" plugin and brings back the whole page:

file: .../share/moin/data/plugin/action/tree.py

from MoinMoin.util import MoinMoinNoFooter

JSONTEXT="""
[
        {"text":"widgets","id":"source\/widgets","cls":"folder"},
        {"text":"debug.js","id":"source\/debug.js","leaf":true,"cls":"file"},
        {"text":"hs_err_pid9692.log","id":"source\/hs_err_pid9692.log","leaf":true,"cls":"file"},
        {"text":"util","id":"source\/util","cls":"folder"},
]"""

def execute(pagename, request):
        request.http_headers([
            'Content-Type: %s' % 'text/html',
        ])
        request.write('\n')
        request.write(JSONTEXT)
        raise MoinMoinNoFooter

This should work when you call the new action. For example, if your action installed in /path/to/wiki/data/plugin/action/json.py, you access /Foo?action=json.

Answer: Thanks for your reaction, I put in more details.

Here is the part of the js stuff:

Ext.onReady(function(){
    // shorthand
    var Tree = Ext.tree;

    var tree = new Tree.TreePanel('tree-div', {
        animate:true,
        loader: new Tree.TreeLoader({
            // 1. either calling via MoinMoin action
            dataUrl:'http://localhost:8080/?action=tree'
            // 2. or calling via native cgi
            //dataUrl:'http://localhost:8080/cgi-bin/tree.cgi'
        }),
        enableDD:true,
        containerScroll: true
    });

....
  1. calling via MoinMoin action stuff does not work, brings back according FireFox Debug the whole page, not only the JSON text, unable to fill JS tree

  2. calling via native cgi stuff works, brings back the JSON text only and fills correct JS tree
  3. calling via browser direct http://localhost:8080/?action=tree works and brings back the JSON text to browser.

(I'm using TwistedWeb/2.5.0)

How to implement interactive session

I am working on our intranet Wiki, and would like to warn users when they remove 'admin' privilege from a page (particularly for those users who inadvertently remove 'admin' from their own homepages). I have found the place in the class PageEditor, saveText method where I can determine that the old_acl differs from the new_acl, and that the old_acl had 'admin' privilege and the new_acl does not. I can then raise an appropriate exception, which caught by wikiaction.do_savepage method. What I now need is a means of presenting the user with a dialog that asks

Do you really want to remove 'admin' privilege? [Yes][No]

and returns his answer. In the case of No, I would like to replace the new_acl with the old_acl. Any suggestions? Is there a type of dialog form that I could use? - -- JohnSimonson 2005-04-19 13:21:15

I don't think you really want to annoy people with "do you really" questions. Try to find another solution that does not require this kind of questions. Also, moin is not well suited to this interactive answer, question, answer, question style.

In this case I think you need some kind of automatic admin rights for user home pages and sub pages. This can be achieved with a simple security policy class. One example is here: NickWelch/RelativeGroups on the bottom of the page. -- NirSoffer 2005-04-23 22:34:03

}}}

Import text into MoinMoin 1.3

I want to import external text into some page automatically, without editing the page.

Solution

Try ScriptMarket/AppendTextScript. For more information on storage format read MoinDev/Storage. For example code check PageEditor.py.

Modifying "Make this page belong to category" format

I want that the categories line will starts with "Categories:". This will make it easier to find categories on categories pages and make the data on the page more clear.

Solution

This requires patching the code in wikiaction.py. Grep for categories and you will find the lines that handle categories. The modification should not be hard if you know Python. After you create a nice patch, probably factoring this out of the current function into a small and nice function, add a feature request for this with the patch. Generally it make sense and maybe other developers will like to use the patch.

Themes test

Is there theme test page where almost all "objects" (sidebar, dialog, messages ...) are visible?

Answer

No, but pages like SyntaxReference try to use many syntax options and thereby trigger many CSS classes.

CVS backend

I've been tasked with creating a wiki that uses CVS as a backend for managing documentation at my company. Developers want CVS to be "the one" source of truth. They also want to be able to work offline, without using a Web browser at all, in their own text editors. Meanwhile, a lot of other people in the company could really benefit from using the wiki interface. Is there any way I can add this functionality to MoinMoin, or do I need to use an existing project like Pyle, which doesn't seem quite as mature?

Thanks for the response. Yes, an infrastructure for adding new backends would be helpful. Committing moin's data dir to a cvs repository won't be sufficient because it doesn't help with people committing to CVS directly, especially when there are conflicts. As much as I hate it, unless Pyle can meet my needs, I may be on my own.


CategoryFeatureRequest

Solution

CVS is not the answer, it is the question. ;) And there is no easy way currently to let moin use CVS as backend without a big hack of the code (we don't recommend that). We plan to make some backend module in 2.0, then maybe adding such stuff will be easier (but we won't implement a CVS backend ourselves).

What you should be able to do right now is to just commit moin's data dir to a cvs repository (e.g. by some external cron script). Not nice, but should work.


CategoryFeatureRequest

svk might help

One idea is to add support for svk, http://svk.elixus.org/ to moinmoin. svk builds on svn, subversion, the successor system for cvs. With subversion, one could, for example, store different versions of pages in the source control system, instead of having one file for each version. svk adds the ability to synchronize between subversion repositories. One could, for example, make a copy of the repository on a laptop, make changes offline, and then, later, merge those changes automatically into the online wiki. Keeping two different wikis synchronized could also be done by svk.

As mentioned above, it should be possible to commit moinmoin data to a svn repository.

SavePage hook

Would it be possible to have a hook in PageEditor at the spot where the raw page data is actually saved (for example in _write_file())? I am writing some extensions that extend and index the link structure, so such a hook would be a great benefit for me. I have noticed that the subject has been brought up some times in this wiki, but I'd like to know whether you are going to implement it, are having doubts or other plans, or have decided against it.

Macro that extracts macro calls: how to execute those?

I have a macro that selects all ocurrences of the [[Card(...]] macro in a given page. The problem is that the selected lines containing macros do not get rendered themselves, i.e. I see the macro invocation code [[Card(...]] instead of the output it should produce when rendered. I have posted a raw draft of the code at AlvaroTejero/ActionFilter

Dynamic Navigation Button

I'm planning to write a simple plugin to support a dynamic button in the 'navi_bar'. It will take a user to a different part of the site based on the value of the Apache REMOTE_USER environment variable. Could someone point me to an example of a simple plugin I can look at? Any tips would be appreciated.

Could a theme execute a macro in it's toolbar

Is it possible to add to a theme a macro call like Hits which is always executed on a page? -- ReimarBauer 2005-10-21 21:13:05

A theme can import a macro and execute it, like any other code, but you will have to create the correct environment for the macro, which may be hard. The easiest solution is to get a parser and then format a macro call :)

Parser = wikiutil.importPlugin(self.request.cfg, 'parser', 'wiki', 'Parser')
Parser('[[MyMacro]]', self.request).format(self.request.formatter)

Ok, easy but on an ?action=AttachFile of a page the Formatter instance is different. Is this a bug? or what is the reason for this?

args = ("Formatter instance has no attribute 'page'",)

self.request.formatter.page = d["page"]

Is there an example how to add this to page_footer in wikiconfig.py too? -- ReimarBauer 2005-10-22 08:47:18

How to write a Colorized parser

Looking into the cpluplus parser I thought it is easy to write one for idl. But now it uses to few colorcodes. Do I have to add css code? In the comments of the cpluplus parser are some css statements but I have not found them in the theme css code base. If I have to put some css code to somewhere - where ? -- ReimarBauer 2005-10-25 20:48:33

So I first had to find out how to set self._ignore_case = 1 Can I control from within the parser which color is used for what? At the moment I do something like

self.addWords(reserved_words,'Special')
self.addReserved(special_words)

I would prefer color red for the special words.

The parser is quite finished by now or it is finished with the same intelligence as the one from kate/kwrite. Probably it could be better. Any idea how to destinguish between a reserved_words like save and /save? Only the first one should be colorcoded. -- ReimarBauer 2005-10-27 19:00:51

How can I recognize in a macro which moin version is used?

How is it possible to get the moin version from within a parser or macro (action). While I work on my tools now I would like to add the code change for 1.5 too.

How do you apply a patch ?

How do I apply those .patch files I find on this website ? -- RemyRoy 2006-01-30 18:41:39

I'm using windows and I found this interesting link about the patch utility for windows: http://drupal.org/node/23409 -- RemyRoy 2006-01-30 19:26:50

Checking user agent ??

I've been working on a custom skin for my wiki, and I wonder if I can get the user-agent of the browser in the python code?? I want to be able to do some changes if a mobile device tries to surf on the page.

How generate the user ID ?

I would like generate the user ID in php for my web site, it's possible ? Thanks

How to specifiy additional body-attributes in a theme.py-file?

I want to adapt some "foreign", already existing CSS-files to my moin wiki and create a new theme by that. To get it work, I would have to specifiy some extra body attributes (an id, class and onload attribute). Afterwards the body-line should look like this: "<body id="contentseite" class="artikel" onload="liveSearchInit()">" How can I achieve that in my theme.py file?

How can I became a returnvalue, if a page already exist?

I want to write a macro, to import pages automatically. To realise the macro, I have to check the pages.

How to apply a patch?

I found a patch realise a modification I wanted. But now I don't know, how to apply the patch..

There is some commandline tool which is called "patch". This tools generates a patched file from a diff file and the unpatched version of a file.

XMLRPC getPage for nonexisting Page

I try to check if a Page in my Wiki exists so I tried something like

   1 Page='SomePage'
   2 pagecheck = xmlrpclib.ServerProxy("http://test:test@mydoc:8088/Myone/"+Page+"/?action=xmlrpc2")
   3 test = pagecheck.getPageInfo(Page)

I hoped to get somethin back, either in pagecheck or in test but my Script just exit without any error after xmlrpclib.ServerProxy

Any Clues ??

-- Matthias 14.05.2007

Where to browse the development of the MoinMoin sourcecode?

The material available at http://moin.cvs.sourceforge.net/moin/ seems to be rather outdated. :-( Where can someone interested in browsing the diffs between different releases have a look at the MoinMoin CVS? Background of this question: Recently we switched from MoinMoin 1.3.4 (Debian 3.1 Sarge) to MoinMoin 1.5.2 (Ubuntu 6.06 LTS Dapper Drake) due to a server change and had difficulties to get our heavily customized theme going again. -- Peter Funk 2024-11-25 01:19:53

MoinMoin: MoinMoinQuestions/Developing (last edited 2009-01-28 20:41:14 by p57B06605)