Extending built-in function unicode

"Rajeev J Sebastian" <[email protected]>
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
Hi,

I'm using PEAK_Rules-0.5a1.dev_r2576-py2.4

I get an exception when trying to "extend" the unicode function:

@when(unicode, (types.ClassType,))
def unicode_model(m):
    return m._meta.app_label+'.'+m._meta.object_name


( this is to print a good string when the object 'm' is a django model class)

However, I get something like:

AttributeError: type object 'unicode' has no attribute 'func_code'

when this code loads.

It seems this is because 'unicode' is not a python function (?). Could
someone suggest a better way to achieve this ?

Regards
Rajeev J Sebastian


Partial Traceback:
  File "build\bdist.win32\egg\peak\util\decorators.py", line 600, in do_decorate
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 185, in callback
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 309, in rules_for
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 547, in callback
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 153, in __call__
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 312, in rules_for
  File "build\bdist.win32\egg\peak\util\addons.py", line 55, in __call__
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 334, in __init__
  File "/usr/lib/python2.4/site-packages/PEAK_Rules-0.5a1.dev_r2576-py2.4.egg/peak/rules/core.py",
line 358, in _regen_code
  File "build\bdist.win32\egg\peak\util\assembler.py", line 858, in
from_function
AttributeError: type object 'unicode' has no attribute 'func_code'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.