473,696 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MoinMoin WikiName and python regexes


hi-

i know nada about python so please forgive me if this is way off base. i'm
trying to fix a bug in MoinMoin whereby

WordsWithTwoCap sInARowLike
^^
^^
^^

do not become WikiNames. this is because the the wikiname pattern is
basically

/([A-Z][a-z]+){2,}/

but should be (IMHO)

/([A-Z]+[a-z]+){2,}/

however, the way the patterns are constructed like

word_rule = ur'(?:(?<![%(l)s])|^)%(parent)s( ?:%(subpages)s( ?:[%(u)s][%(l)s]+){2,})+(?![%(u)s%(l)s]+)' % {
'u': config.chars_up per,
'l': config.chars_lo wer,
'subpages': config.allow_su bpages and (wikiutil.CHILD _PREFIX + '?') or '',
'parent': config.allow_su bpages and (ur'(?:%s)?' % re.escape(PAREN T_PREFIX)) or '',
}
and i'm not that familiar with python syntax. to me this looks like a map
used to bind variables into the regex - or is it binding into a string then
compiling that string into a regex - regexs don't seem to be literal objects
in pythong AFAIK... i'm thinking i need something like

word_rule = ur'(?:(?<![%(l)s])|^)%(parent)s( ?:%(subpages)s( ?:[%(u)s]+[%(l)s]+){2,})+(?![%(u)s%(l)s]+)' % {
^
^
^
'u': config.chars_up per,
'l': config.chars_lo wer,
'subpages': config.allow_su bpages and (wikiutil.CHILD _PREFIX + '?') or '',
'parent': config.allow_su bpages and (ur'(?:%s)?' % re.escape(PAREN T_PREFIX)) or '',
}

and this seems to work - but i'm wondering what the 's' in '%(u)s' implies?
obviously the u is the char range (unicode?)... but what's the 's'?

i'm looking at

http://docs.python.org/lib/re-syntax.html
http://www.amk.ca/python/howto/regex/

and coming up dry. sorry i don't have more time to rtfm - just want to
implement this simple fix and get on to fcgi configuration! ;-)

cheers.

-a
--
=============== =============== =============== =============== =============== ====
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple. My religion is kindness.
| --Tenzin Gyatso
=============== =============== =============== =============== =============== ====

Jul 19 '05 #1
6 2761
Don
Ara.T.Howard wrote:

hi-

i know nada about python so please forgive me if this is way off base.
i'm trying to fix a bug in MoinMoin whereby

WordsWithTwoCap sInARowLike
^^
^^
^^

do not become WikiNames. this is because the the wikiname pattern is
basically

[snip]

PHPWiki has the same "feature", BTW. (Sorry, couldn't get MoinMoin to work
on Sourceforge, had to use PHPWiki).

-Don

Jul 19 '05 #2
Ara.T.Howard wrote:
(...)
and i'm not that familiar with python syntax. to me this looks like a map
used to bind variables into the regex - or is it binding into a string then
compiling that string into a regex - regexs don't seem to be literal
objects
in pythong AFAIK... i'm thinking i need something like

word_rule =
ur'(?:(?<![%(l)s])|^)%(parent)s( ?:%(subpages)s( ?:[%(u)s]+[%(l)s]+){2,})+(?![%(u)s%(l)s]+)'
% {
^
^
^
'u': config.chars_up per,
'l': config.chars_lo wer,
'subpages': config.allow_su bpages and (wikiutil.CHILD _PREFIX +
'?') or '',
'parent': config.allow_su bpages and (ur'(?:%s)?' %
re.escape(PAREN T_PREFIX)) or '',
}

and this seems to work - but i'm wondering what the 's' in '%(u)s' implies?
obviously the u is the char range (unicode?)... but what's the 's'?


an example may help here:
a = 123
'%04d' % a '0123' '%f' % a '123.000000' '%s' % a '123'

that "s" tells python to convert the number as string. the form %(key)s
tells python to lookup a dictionary "key" and format the found value
into a string:
d = {'key': 123}
'%(key)s' % d

'123'

so in your code there's some keys named 'u', 'l', 'subpages', etc. and
their values are substitued into that big RE, replacing the
corresponding key names.

HTH.

--
deelan <http://www.deelan.com/>
Jul 19 '05 #3

"Ara.T.Howa rd" <Ar**********@n oaa.gov> wrote in message
news:Pi******** *************** ********@harp.n gdc.noaa.gov...
i'm trying to fix a bug in MoinMoin whereby
A 'bug' is a discrepancy between promise (specification) and perfomance
(implementation ). Have you really found such -- does MoinMoin not follow
the Wiki standard -- or are you just trying to customize MoinMoin to your
different specification.
WordsWithTwoCap sInARowLike
^^
do not become WikiNames.


Would your proposed change to make the above into an Wiki name also make
all-cap sequences like NATO, FTP, and API into WikiNames and do you really
want that? If WikiNum, appearing one place, were also mistyped as WikeNUm
(from holding down the shift key too long, which I do occasionally), should
the latter become a separate WikiName? I can certainly understand why the
Wike designers might have answered both questions 'No."

Terry J. Reedy

Jul 19 '05 #4
On Wed, 8 Jun 2005, Terry Reedy wrote:

"Ara.T.Howa rd" <Ar**********@n oaa.gov> wrote in message
news:Pi******** *************** ********@harp.n gdc.noaa.gov...
i'm trying to fix a bug in MoinMoin whereby
A 'bug' is a discrepancy between promise (specification) and perfomance
(implementation ). Have you really found such -- does MoinMoin not follow
the Wiki standard -- or are you just trying to customize MoinMoin to your
different specification.


well, according to the specification at

http://moinmoin.wikiwikiweb.de/WikiN...%28wikiname%29

ThisIsAWikiName

there seems to be general agreement here

http://wikka.jsnx.com/WikiName
http://twiki.org/cgi-bin/view/TWiki/WikiWord

though not a wikis agree.

in moinmoin others have noted the inconsistency and filed a bug as noted in

http://moinmoin.wikiwikiweb.de/MoinM...%28wikiname%29

the problem being that the specification is simply vague here and does not
specifically prohibit AWikiName.
WordsWithTwoCap sInARowLike
^^
do not become WikiNames.
Would your proposed change to make the above into an Wiki name also make
all-cap sequences like NATO, FTP, and API into WikiNames


it wouldn't since

NATO !~ /^([A-Z]+[a-z]+){2,}$/
FTP !~ /^([A-Z]+[a-z]+){2,}$/
API !~ /^([A-Z]+[a-z]+){2,}$/

the pattern is

word = one, or more, upper case letters followed by one, or more, lower case
letters

wikiword = at least two words together

so

FOobar is not a link

but

AFooBar is
If WikiNum, appearing one place, were also mistyped as WikeNUm (from holding
down the shift key too long, which I do occasionally), should the latter
become a separate WikiName? I can certainly understand why the Wike
designers might have answered both questions 'No."


perhaps - it's just inconsistent the way it is now.

cheers.
-a
--
=============== =============== =============== =============== =============== ====
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple. My religion is kindness.
| --Tenzin Gyatso
=============== =============== =============== =============== =============== ====

Jul 19 '05 #5
Ara.T.Howard wrote:
i know nada about python so please forgive me if this is way off base. i'm
trying to fix a bug in MoinMoin whereby

WordsWithTwoCap sInARowLike


I don't think there is such a thing as the perfect "hyperlink vs
just-text" convention. In MoinMoin, you can force a custom link using e.g.:

[wiki:WebsiteSec urity this is the link text to WebsiteSecurity so call
it whatever you want such as WebsiteSecuriti es]

This custom linking, whilst obviously not ideal, solves the problems
mentioned at http://www.c2.com/cgi/wiki?WikiName

This seems better than producing endless confusing variations on the
"standard" (be it formal, actual, or simply obviously desired).

I'm not convinced of the usefulness of MoinMoin's "subpages" idea, while
we're on the (related) subject - they seem to create more problems than
they solve:
http://moinmoin.wikiwikiweb.de/HelpOnEditing/SubPages
Jul 19 '05 #6
On Wed, 8 Jun 2005 09:49:51 -0600, "Ara.T.Howa rd" <Ar**********@n oaa.gov> wrote:

hi-

i know nada about python so please forgive me if this is way off base. i'm
trying to fix a bug in MoinMoin whereby

WordsWithTwoCap sInARowLike
^^
^^
^^

do not become WikiNames. this is because the the wikiname pattern is
basically

/([A-Z][a-z]+){2,}/

but should be (IMHO)

/([A-Z]+[a-z]+){2,}/ That would take care of the example above, but does it change an official spec?

however, the way the patterns are constructed like

word_rule = ur'(?:(?<![%(l)s])|^)%(parent)s( ?:%(subpages)s( ?:[%(u)s][%(l)s]+){2,})+(?![%(u)s%(l)s]+)' % {
'u': config.chars_up per,
'l': config.chars_lo wer,
'subpages': config.allow_su bpages and (wikiutil.CHILD _PREFIX + '?') or '',
'parent': config.allow_su bpages and (ur'(?:%s)?' % re.escape(PAREN T_PREFIX)) or '',
}
and i'm not that familiar with python syntax. to me this looks like a map
used to bind variables into the regex - or is it binding into a string then
compiling that string into a regex - regexs don't seem to be literal objects
in pythong AFAIK... i'm thinking i need something like

word_rule = ur'(?:(?<![%(l)s])|^)%(parent)s( ?:%(subpages)s( ?:[%(u)s]+[%(l)s]+){2,})+(?![%(u)s%(l)s]+)' % {
^
^
^
'u': config.chars_up per,
'l': config.chars_lo wer,
'subpages': config.allow_su bpages and (wikiutil.CHILD _PREFIX + '?') or '',
'parent': config.allow_su bpages and (ur'(?:%s)?' % re.escape(PAREN T_PREFIX)) or '',
}

and this seems to work - but i'm wondering what the 's' in '%(u)s' implies?
obviously the u is the char range (unicode?)... but what's the 's'? 'u' doesn't stand for unicode here. It is the key to look up config.chars_up per from the dict. That could
be unicode, and probably is. The 's' is the final part of a formatting spec which says how to convert the
data looked up, and 's' is for string, which doesn't change string data (unless, and UIAM, a conversion to unicode is required).

All of the above is making use of the % operator of strings, as in the expression
fmt % data
where fmt is a string containing ordinary characters and formatting specs in the form
of substrings escaped by a leading character '%'. The formatting specs take two basic
alternative forms: %<spec> or %(name)<spec>. If any '%' is followed by a parenthesized name,
as in '%(u)s' it means that the data to be formatted is retrieved from data['u'] for the latter example.
If there is no parenthesized name, the data is retrieved from data[i] where data must be a tuple and
i is the positional count of format specs in fmt. In some cases where there is no ambiguity,
and there is only one datum, data[0] may be written as the non-tuple value expression, e.g.,
instead of (123,) that data could be written as (123,)[0] or plain 123.

In the word_rule above, %(u)s uses 'u' as a key to get data from the dictionary { 'u': config.chars_up per, ...}
to substitute in the [%(u)s] as a string (that's what the 's' specifies), so config.chars_up per will
presumably have had a string value such as u'ABC..Z' and that will then be inserted in place of the %(u)s to
get u'...[ABC..Z]...' (if fmt is unicode, the resulting string will be unicode, UIAM)

i'm looking at

http://docs.python.org/lib/re-syntax.html
http://www.amk.ca/python/howto/regex/
See also
http://www.python.org/doc/current/li...q-strings.html
(which IMO should be easier to find, but if you click on the index square
at the top right of any library reference page, you can see a "%formattin g" link)
and coming up dry. sorry i don't have more time to rtfm - just want to
implement this simple fix and get on to fcgi configuration! ;-)

cheers.

-a
--
============== =============== =============== =============== =============== =====
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple. My religion is kindness.
| --Tenzin Gyatso
============== =============== =============== =============== =============== =====


Regards,
Bengt Richter
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2005
by: asdf sdf | last post by:
ActiveState python 2.3.2 Win2k Pro SP4 Apache 2.0 browsing all of http://moinmaster.wikiwikiweb.de/HelpForBeginners in vain. Running http://localhost/mywiki?test yields: MoinMoin CGI Diagnosis ======================
46
3280
by: Reinhold Birkenfeld | last post by:
Hello, another Perl/Python question: the subject says it all. Perl is going to change dramatically to become a more powerful and easier to (read|write) language. Is Python taking a similar step (-> Python 3) some time in the near future? Reinhold
4
40894
by: ferg | last post by:
I've checked all the FAQs and help - spent a couple of hours on this now and it's really bugging me. I've got Moin 1.3.5 installed on IIS 5.0. I can view and edit pages without any problems, but cannot create new pages - either trough the GUI, or by creating a new WikiName and clicking on it. I'm stumped as to whether this is a Moin ACL problem (played around a lot with this, but to no avail) or perhaps an IIS config problem (though...
1
2037
by: funny_leech | last post by:
Please tell me if there's a better group to post this in-- I've been trying to get a MoinMoin installation up-and-running for the last two days. I've installed the latest MoinMoin version, mod_python (v. 2.3.4) is running, using Apache on a White Box Enterprise Linux VPS installation. So the basic MoinMoin install looks good--I can import it into Python no problem. It's when I create a Wiki and run the test page that I get problems....
2
2531
by: gdetre | last post by:
Dear all, My lab has been using a Movable Type blog for internal communication and announcement for a couple of years, but we've now seen the light and I've set up a MoinMoin wiki. Everything's installed beautifully, so I'm writing scripts to export all our Movable Type blog posts to wiki pages. So far so good. The only issue I'm having relates to Unicode. MoinMoin and python are pretty unforgiving about files that contain Unicode...
0
1066
by: Marcus | last post by:
Apologies if this seems like it's off-topic, but since moinmoin is written in Python, I am hoping to solicit some good thoughts in this group. The problem: I'm setting up a wiki farm (small software company, my personal use as a PIM, hobby site). I may also deploy (customized) wikis to small/medium companies. I've been researching wikis recently, and I really like three: Moinmoin, Mediawiki, and SocialText (well, Trac, too, but ...). ...
1
1584
by: Daniel Klein | last post by:
I have a pressing need to get a wiki up and running in a fairly short timeframe. I did some investigations and the Python MoinMoin wiki seemed to be the best choice for me based on simplicity, the fact that I am already familiar with Python :-), it's free <double :-) >, and the installation was a snap! I'm having one initial problem however... When I edit a page and click 'Save', the next page that displays is an 'HTTP 500' error. I...
2
1776
by: kyosohma | last post by:
Hi, I am working on a new site about Python to help document some of the modules that don't have much for documentation. Anyway, I chose to use MoinMoin because it has very easy-to-use code display with line numbers that toggle on and off. The question I have is how do I configure MoinMoin to force users to login before making changes and still allow the user to choose if he/ she wants to sign the edit or not? It looks like Python.org...
1
1326
by: John [H2O] | last post by:
I've installed MoinMoin easily enough, but i have two problems now. 1) Some pages, namely the initial FrontPage, fail to load completely.... 2) It seems after logging in, if I navigate away from the login page, I get logged out immediately. I'm runing 1.13 on Fedora 9 with Apache 2 and ReWriteRules... all seemed well initially...
0
9142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9008
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8875
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8849
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5855
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3030
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2313
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1989
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.