Re: [Zope] Underscore Caracter

2000-10-07 Thread Kapil Thangavelu

Chris McDonough wrote:
 
 Yes.  Thank you.
 
 Note however that methods of modules accessed via the underscore namespace
 may be filtered individually, so although 'replace' exists as a method of
 the Python string module, this does not necessarily make it accessible
 implicitly through Zope via _.string.replace.  It happens to be accessible
 in this case, but I'd bet there are cases in which methods accessible
 via modules of the _ namespace have been removed for "safe scripting"
 purposes.

having recently gone through the code to produce ZModules (defined
interface for adding modules to _), it was apparent that all the modules
that live in namespace are completely exposed.


Kapil

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Underscore Caracter

2000-10-07 Thread knight

 Chris McDonough wrote:
  
  Yes.  Thank you.
  
  Note however that methods of modules accessed via the underscore namespace
  may be filtered individually, so although 'replace' exists as a method of
  the Python string module, this does not necessarily make it accessible
  implicitly through Zope via _.string.replace.  It happens to be accessible
  in this case, but I'd bet there are cases in which methods accessible
  via modules of the _ namespace have been removed for "safe scripting"
  purposes.
 
 having recently gone through the code to produce ZModules (defined
 interface for adding modules to _), it was apparent that all the modules
 that live in namespace are completely exposed.

What's the problem with that? Aren't most, if not all, the modules living
in the _ namespace just standard python modules available anyways?

Knight


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Underscore Caracter

2000-09-06 Thread Duncan Booth

Tino Wildenhain wrote:

  Turn "asd_asd" into "asd asd" and output:
  
  dtml-var "_.string.join(_.string.split('asd_asd', '_'))"
  
 I've seen this on plenty lines of digicools code and wondered
 about if this is more efficient then using just string.replace()
 ?
 I would say string.replace() should be a bit faster.

I think the reasons may be historical. For a long time the Zope 
documentation listed the join and split members of the string 
module, but whoever wrote the documentation the first time around 
missed out replace. So anyone coming at Zope from the DTML 
direction is likely not to spot the replace method.

Calling _.string.replace requires two attribute lookups and one 
python method call. replace itself requires zero or one memory 
allocation for the result.
Calling join/split requires four attribute lookups, two python method 
calls and n+3 memory allocations where n replacements are made 
(1 allocation when n is 0).

So I agree, replace should be faster, although given everything else 
that is going on, unless you do a lot of them you probably won't 
notice.

-- 
Duncan Booth [EMAIL PROTECTED]
int month(char *p){return(124864/((p[0]+p[1]-p[2]0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Underscore Caracter

2000-09-06 Thread Toby Dickenson

On Tue, 5 Sep 2000 20:23:47 -0600, "T.J. Mannos" [EMAIL PROTECTED]
wrote:

Now, who do I have to beat up to get the 're' module added to the namespace
variable???  :)

Not a good idea its too easy for a buggy regex to eat up lots of
memory and processor time.

Toby Dickenson
[EMAIL PROTECTED]

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Underscore Caracter

2000-09-05 Thread Tino Wildenhain

Hi Chris,

Chris McDonough wrote:
 
 Hi Marcus,
 
 This is untested.
 
 Turn "asd asd" into "asd_asd" and output:
 
 dtml-var "_.string.join(_.string.split('asd asd'), '_')"
 
 Turn "asd_asd" into "asd asd" and output:
 
 dtml-var "_.string.join(_.string.split('asd_asd', '_'))"
 
I've seen this on plenty lines of digicools code and wondered
about if this is more efficient then using just string.replace()
?
I would say string.replace() should be a bit faster.

Regards
Tino

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Underscore Caracter

2000-09-05 Thread T.J. Mannos

Hmm.. Shouldn't that be:

_.string.join(_.string.split('asd asd'), ' '), '_')

Or, alternatively (and more intuitively),

_.string.replace('asd asd', ' ', '_')
_.string.replace('asd_asd', '_', ' ')

- T.J.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Chris
McDonough
Sent: Monday, September 04, 2000 5:56 PM
To: Marcus Mendes
Cc: [EMAIL PROTECTED]
Subject: Re: [Zope] Underscore Caracter


Hi Marcus,

This is untested.

Turn "asd asd" into "asd_asd" and output:

dtml-var "_.string.join(_.string.split('asd asd'), '_')"

Turn "asd_asd" into "asd asd" and output:

dtml-var "_.string.join(_.string.split('asd_asd', '_'))"

On Sun, 3 Sep 2000, Marcus Mendes wrote:
 Hello,
 
 I need replace 0x20 (space caracter ) to Undescore Caracter. I need also
 a function that UNDO this operation. How can I to do this in DTML
 sintaxe?

Chris McDonough
Digital Creations, Publishers of Zope
http://www.zope.org


___
Zope maillist  -  [EMAIL PROTECTED]
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 )


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Underscore Caracter

2000-09-05 Thread Chris McDonough

On Tue, 5 Sep 2000, T.J. Mannos wrote:
 Hmm.. Shouldn't that be:
 
 _.string.join(_.string.split('asd asd'), ' '), '_')

The second argument is implicit on string.split (it defaults to a single
space).  But your way works too.

 Or, alternatively (and more intuitively),
 
 _.string.replace('asd asd', ' ', '_')
 _.string.replace('asd_asd', '_', ' ')

It should be noted that _.string.replace() is not mentioned in the DTML
reference guide.  If it exists, it should be used.  Sigh.  I can't wait
for the Zope Book to come out, I'm going to be the first buyer.  ;-)

 Hi Marcus,
 
 This is untested.
 
 Turn "asd asd" into "asd_asd" and output:
 
 dtml-var "_.string.join(_.string.split('asd asd'), '_')"
 
 Turn "asd_asd" into "asd asd" and output:
 
 dtml-var "_.string.join(_.string.split('asd_asd', '_'))"
 
 On Sun, 3 Sep 2000, Marcus Mendes wrote:
  Hello,
  
  I need replace 0x20 (space caracter ) to Undescore Caracter. I need also
  a function that UNDO this operation. How can I to do this in DTML
  sintaxe?
 

Chris McDonough
Digital Creations, Publishers of Zope
http://www.zope.org


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Underscore Caracter

2000-09-05 Thread T.J. Mannos

Yep, it's there, but it's not documented.

Basically, anything in the python "string" module should be accessible from
Zope DTML.

Now, who do I have to beat up to get the 're' module added to the namespace
variable???  :)

- T.J.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Chris
McDonough
Sent: Tuesday, September 05, 2000 7:54 PM
To: T.J. Mannos
Cc: Marcus Mendes; [EMAIL PROTECTED]
Subject: RE: [Zope] Underscore Caracter


On Tue, 5 Sep 2000, T.J. Mannos wrote:
 Hmm.. Shouldn't that be:

 _.string.join(_.string.split('asd asd'), ' '), '_')

The second argument is implicit on string.split (it defaults to a single
space).  But your way works too.

 Or, alternatively (and more intuitively),

 _.string.replace('asd asd', ' ', '_')
 _.string.replace('asd_asd', '_', ' ')

It should be noted that _.string.replace() is not mentioned in the DTML
reference guide.  If it exists, it should be used.  Sigh.  I can't wait
for the Zope Book to come out, I'm going to be the first buyer.  ;-)

 Hi Marcus,

 This is untested.

 Turn "asd asd" into "asd_asd" and output:

 dtml-var "_.string.join(_.string.split('asd asd'), '_')"

 Turn "asd_asd" into "asd asd" and output:

 dtml-var "_.string.join(_.string.split('asd_asd', '_'))"

 On Sun, 3 Sep 2000, Marcus Mendes wrote:
  Hello,
 
  I need replace 0x20 (space caracter ) to Undescore Caracter. I need also
  a function that UNDO this operation. How can I to do this in DTML
  sintaxe?


Chris McDonough
Digital Creations, Publishers of Zope
http://www.zope.org


___
Zope maillist  -  [EMAIL PROTECTED]
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 )


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Underscore Caracter

2000-09-05 Thread Dennis Nichols

At 9/5/00 09:54 PM, Chris McDonough wrote:
It should be noted that _.string.replace() is not mentioned in the DTML
reference guide.  If it exists, it should be used.  Sigh.  I can't wait
for the Zope Book to come out, I'm going to be the first buyer.  ;-)

Not that I would expect it to exist, but according to "Python Essential 
Reference" p. 117, it is indeed present in the string module:

 replace( str, old, new [,max] )



--
Dennis Nichols
[EMAIL PROTECTED]


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Underscore Caracter

2000-09-05 Thread Chris McDonough

Yes.  Thank you.

Note however that methods of modules accessed via the underscore namespace
may be filtered individually, so although 'replace' exists as a method of
the Python string module, this does not necessarily make it accessible
implicitly through Zope via _.string.replace.  It happens to be accessible
in this case, but I'd bet there are cases in which methods accessible
via modules of the _ namespace have been removed for "safe scripting"
purposes.

The solution is proper documentation.

On Tue, 5 Sep 2000, Dennis Nichols wrote:

 At 9/5/00 09:54 PM, Chris McDonough wrote:
 It should be noted that _.string.replace() is not mentioned in the DTML
 reference guide.  If it exists, it should be used.  Sigh.  I can't wait
 for the Zope Book to come out, I'm going to be the first buyer.  ;-)
 
 Not that I would expect it to exist, but according to "Python Essential 
 Reference" p. 117, it is indeed present in the string module:
 
  replace( str, old, new [,max] )
 
 
 
 --
 Dennis Nichols
 [EMAIL PROTECTED]
 
 
 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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 )
 

Chris McDonough
Digital Creations, Publishers of Zope
http://www.zope.org


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Underscore Caracter

2000-09-04 Thread Chris McDonough

Hi Marcus,

This is untested.

Turn "asd asd" into "asd_asd" and output:

dtml-var "_.string.join(_.string.split('asd asd'), '_')"

Turn "asd_asd" into "asd asd" and output:

dtml-var "_.string.join(_.string.split('asd_asd', '_'))"

On Sun, 3 Sep 2000, Marcus Mendes wrote:
 Hello,
 
 I need replace 0x20 (space caracter ) to Undescore Caracter. I need also
 a function that UNDO this operation. How can I to do this in DTML
 sintaxe?

Chris McDonough
Digital Creations, Publishers of Zope
http://www.zope.org


___
Zope maillist  -  [EMAIL PROTECTED]
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 )