Hi,
I have built my models and so forth, but I have the need to check
whether the user requesting an instance or set of instances from the
database has permission to do so.
For this I have a stored procedure (saved procedure) in the database
that when I give it a user id, it then returns the item if I am
allowed it. Its a stored procedure because its not possible to do it
in a SELECT, it potentially would open up a lot of database requests
if I wanted to do it straight from the App server.
I want to use this in Django, and I thought about using a Manager on
the model like so:
class MediaItemManager(models.Manager):
def get_perm(self, *args, **kwargs):
from django.db import connection
cursor = connection.cursor()
cursor.execute("""
SELECT * FROM permfindernew(2, 132);
""")
row = cursor.fetchone()
return row
Problem comes in that although I return what I want (I will replace 2,
132 with the correct args when I am done), its not in a format of a
queryset or anything else that I can see how I can use.
Another way I could do this is to get the stored procedure to give me
back a true/false and then do another query if I have got true back.
This only hits the database twice, but I would like to just return a
row if possible.
Is there a way to turn what I get back from the database into
something I can then use in a template:
(132,
u'Tsunami_by_hokusai_19th_century.jpg',
u'Tsunami_by_hokusai_19th_century.jpg',
u'',
u'',
datetime.datetime(2009, 2, 17, 16, 54, 38, 892350),
None,
u'image-jpg',
u'c4a6afe0a71e3632',
3,
u'[]',
5,
False,
False,
False,
True,
True,
1,
u'',
1,
None,
False,
1,
"'19th':4,9 'hokusai':3,8 'tsunami':1,6 'century.jpg':5,10")
Thanks,
Tim.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---