<br><font size=2 face="sans-serif">I don't understand why space is considered
as a control char,</font>
<br><font size=2 face="sans-serif">while and del is not considered so.</font>
<br>
<br>
<br>
<br>
<br>
<br><font size=6 face="Tahoma"><b>I</b></font><font size=5 face="Tahoma">nternet</font>
<br><font size=1 face="sans-serif">philipn@gmail.com@lists.danga.com -
08/28/2007 06:13 PM</font>
<br><font size=1 face="sans-serif"> </font>
<p><font size=1 color=#800080 face="sans-serif">Sent by:
memcached-bounces@lists.danga.com</font>
<p>
<p><font size=1 color=#800080 face="sans-serif">To:
</font><font size=1 face="sans-serif">memcached</font>
<p><font size=1 color=#800080 face="sans-serif">cc:
</font>
<p><font size=1 color=#800080 face="sans-serif">Subject:
</font><font size=1 face="sans-serif"><b>Re: check_key</b></font>
<br>
<br><font size=2><tt>>>> c = 'hi there'<br>
>>> space = c[2]<br>
>>> ord(space)<br>
32<br>
<br>
The memcached protocol spec says no control chars. ord(c) < 33
does that.<br>
<br>
That is the latest version of the client. You can grab new releases<br>
here: http://www.tummy.com/Community/software/python-memcached/<br>
<br>
--Philip Neustrom<br>
<br>
On 8/28/07, jacques.ales@bnpparibas.com <jacques.ales@bnpparibas.com>
wrote:<br>
><br>
> hello<br>
><br>
> I'm using the python wrapper for memcached in it's version<br>
> __author__ = "Evan Martin <martine@danga.com>"<br>
> __version__ = "1.36"<br>
> __copyright__ = "Copyright (C) 2003 Danga Interactive"<br>
> __license__ = "Python"<br>
><br>
> I can't figure out if this is the latest since the verion available
in the<br>
> svn repository is<br>
> http://code.sixapart.com/svn/memcached/trunk/api/python/memcache.py<br>
> __author__ = "Evan Martin <martine@danga.com>"<br>
> __version__ = "1.2"<br>
> __copyright__ = "Copyright (C) 2003 Danga Interactive"<br>
> __license__ = "Python"<br>
><br>
><br>
> anyway, my concern is that version 1.36 checks key validity with the<br>
> followinf function, that excludes spaces char (ascii32)<br>
> as being 'control characters'.<br>
><br>
> I was wondering is this is correct.<br>
> and also wondering why other chars as DEL(ascii127) are not excluded<br>
><br>
> thanks for your clues<br>
><br>
> jacques<br>
><br>
><br>
><br>
> def check_key(key, key_extra_len=0):<br>
> """Checks sanity of key. Fails
if:<br>
> Key length is > SERVER_MAX_KEY_LENGTH
(Raises MemcachedKeyLength).<br>
> Contains control characters (Raises
MemcachedKeyCharacterError).<br>
> Is not a string (Raises MemcachedStringEncodingError)<br>
> """<br>
> if not isinstance(key, str):<br>
> raise Client.MemcachedStringEncodingError,
("Keys<br>
> must be str()'s, not"<br>
> "unicode.
Convert your unicode strings using "<br>
> "mystring.encode(charset)!")<br>
><br>
> if isinstance(key, basestring):<br>
> if len(key) + key_extra_len > SERVER_MAX_KEY_LENGTH:<br>
> raise Client.MemcachedKeyLengthError,
("Key length is > %s"<br>
>
% SERVER_MAX_KEY_LENGTH)<br>
> for char in key:<br>
> if ord(char) < 33:<br>
> raise Client.MemcachedKeyCharacterError,<br>
> "Control characters not allowed"<br>
><br>
><br>
><br>
><br>
><br>
><br>
> This message and any attachments (the "message") is intended
solely for the<br>
> addressees and is confidential.<br>
> If you receive this message in error, please delete it and immediately<br>
> notify the sender. Any use not in accord with<br>
> its purpose, any dissemination or disclosure, either whole or partial,
is<br>
> prohibited except formal approval.<br>
> The internet can not guarantee the integrity of this message.<br>
> BNP PARIBAS (and its subsidiaries) shall (will) not therefore be liable
for<br>
> the message if modified.<br>
> Do not print this message unless it is necessary, consider the environment.<br>
> ---------------------------------------------<br>
> Ce message et toutes les pieces jointes (ci-apres le "message")
sont etablis<br>
> a l'intention exclusive de ses destinataires et sont confidentiels.
Si vous<br>
> recevez ce<br>
> message par erreur, merci de le detruire et d'en avertir immediatement<br>
> l'expediteur.<br>
> Toute utilisation de ce message non conforme a sa destination, toute<br>
> diffusion ou toute publication, totale ou partielle, est interdite,
sauf<br>
> autorisation expresse.<br>
> L'internet ne permettant pas d'assurer l'integrite de ce message,
BNP<br>
> PARIBAS (et ses filiales) decline(nt) toute responsabilite au titre
de ce<br>
> message, dans l'hypothese ou il aurait ete modifie.<br>
> N'imprimez ce message que si necessaire, pensez a l'environnement.<br>
><br>
><br>
</tt></font>
<br>