Checking string for specific characters
Hello, I need to create some filenames from the titles of some objects. In order to make these filenames correct, I need to create a function that checks the title string in order to see if there are any "non-allowed" characters in the string and strip them. Right know I am doing a string.replace for the characters that aren't allowed, but it would be much easier to specify what characters that _is_ allowed. I guess the function that adds a new object to Zope does it ... but I cannot find that function. -- Gitte Wange Jensen Sys Admin, Developer and a lot more MMmanager.org Aps, Denmark Phone: +45 29 72 79 72 Email: gitte@mmmanager.org Web: www.mmmanager.org Quote of the day: I strongly believe that trying to be clever is detrimental to your health. - Linus Torvalds
What about using a PythonScript ? Either you iterate over all single character and match it against a given string containing all valid characters or use a regular expression. In this case you use allow_module() to allow using the re module inside PythonScripts. Andreas ----- Original Message ----- From: "Gitte Wange" <gitte@mmmanager.org> To: "Zope mailinglist" <zope@zope.org> Sent: Monday, October 08, 2001 04:44 Subject: [Zope] Checking string for specific characters
Hello,
I need to create some filenames from the titles of some objects. In order to make these filenames correct, I need to create a function that checks the title string in order to see if there are any "non-allowed" characters in the string and strip them.
Right know I am doing a string.replace for the characters that aren't allowed, but it would be much easier to specify what characters that _is_ allowed.
I guess the function that adds a new object to Zope does it ... but I cannot find that function.
-- Gitte Wange Jensen
Sys Admin, Developer and a lot more MMmanager.org Aps, Denmark
Phone: +45 29 72 79 72 Email: gitte@mmmanager.org Web: www.mmmanager.org
Quote of the day: I strongly believe that trying to be clever is detrimental to your health.
- Linus Torvalds
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
bad =' ()[]{}ÄÅÁÀÂÃäåáàâãÇçÉÈÊËéèêëæÍÌÎÏíìîïÑñÖÓÒÔÕØöóòôõøSsßÜÚÙÛüúùûÝYýÿ??' good='_______AAAAAAaaaaaaCcEEEEeeeeeIIIIiiiiNnOOOOOOooooooSssUUUUuuuuYYyyZz' TRANSMAP=string.maketrans(bad, good) def fixId(anId): anId = string.translate(anId, TRANSMAP) stolen with trembling fingers from CMFOptions Robert ----- Original Message ----- From: "Gitte Wange" <gitte@mmmanager.org> To: "Zope mailinglist" <zope@zope.org> Sent: Monday, October 08, 2001 10:44 AM Subject: [Zope] Checking string for specific characters
Hello,
I need to create some filenames from the titles of some objects. In order to make these filenames correct, I need to create a function that checks the title string in order to see if there are any "non-allowed" characters in the string and strip them.
Right know I am doing a string.replace for the characters that aren't allowed, but it would be much easier to specify what characters that _is_ allowed.
I guess the function that adds a new object to Zope does it ... but I cannot find that function.
-- Gitte Wange Jensen
Sys Admin, Developer and a lot more MMmanager.org Aps, Denmark
Phone: +45 29 72 79 72 Email: gitte@mmmanager.org Web: www.mmmanager.org
Quote of the day: I strongly believe that trying to be clever is detrimental to your health.
- Linus Torvalds
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andreas Jung -
Gitte Wange -
Robert Rottermann