Using % with psycopg2

2008-12-01 Thread Siah
Hi, The following code fails on windows, and works just fine on my unix box. To fix the problem in windows, I must replace('%', '%%') so its internal string formatting doesn't fail on me. Should I file this bug for psycopg2? from django.db import connection cursor=connection.cursor() cursor.exec

Re: Custom Template Tag with {% end... %} tag

2008-10-19 Thread Siah
ind on "def do_if(parser, token):" -- check out how the if tag   > has been written. > > Erik > > On 19.10.2008, at 23:24, Siah wrote: > > > > > Hi, > > > I can't understand how template tags such as if, for and ifequal > > manage to have an a

Custom Template Tag with {% end... %} tag

2008-10-19 Thread Siah
Hi, I can't understand how template tags such as if, for and ifequal manage to have an accompanying endif, endfor and endifequal, and I can't have it. Or I can't manage to find out how to do it. So, I basically want to do something like: {% customTag %} hello {% endcustomTag %} and within my cu

How to set SESSION_COOKIE_DOMAIN for multiple Domain Names

2008-06-14 Thread Siah
Hi, My django app must serve multiple domain names. I also have a need to have my session available on my domain and subdomains. So, reading up on Django docs, I realized I have to do this: SESSION_COOKIE_DOMAIN = '.mysite.com' So, my question is: How do I have my sub-domains share the same coo

Re: Need a Middleware to select urlpatterns

2008-06-06 Thread Siah
> > On Jun 6, 8:42 pm, Siah <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I need to select different urlpatterns in my middleware's > > process_request hook. The docs say, process_request is called -before- > > the appropriate view is selected, which shou

Need a Middleware to select urlpatterns

2008-06-06 Thread Siah
Hi, I need to select different urlpatterns in my middleware's process_request hook. The docs say, process_request is called -before- the appropriate view is selected, which should mean there must be a way for me to tell django to use a different urlpatterns. I checked on CommonMiddleware that doe

Re: How does Django know the PK of the newly created object

2007-09-23 Thread Siah
Thanks everyone, Once again, I do not expect to know the record's ID before having saved it. But once I save it, that object DOES HAVE an id. I am assuming it was a simple insert command underneath, but do not know how this DB assigned is has become visible to Django. The django code representing

Re: How does Django know the PK of the newly created object

2007-09-23 Thread Siah
or not to do an insert or update. > > -richard > > On Sep 23, 2007, at 9:38 AM, Alex Koshelev wrote: > > > > > I think that when you create Product object django inserts new row > > into database and retrieves with SELECT new id. > > > On 23 сент, 16:0

How does Django know the PK of the newly created object

2007-09-23 Thread Siah
Hi, When in a model you run something like this: >> obj = Product(name='Apple') >> obj.id 4 I realize the first statement will turn into an insert table. But, how does django know of its newly assigned primary key(ID). I have a legacy database whose ID is assigned with an after trigger, and am

Need to add Decorator to a many-to-many's Add method

2007-05-25 Thread Siah
Hi, I have a many to many relationships between Model1 and Model2. So django gives me the ability to add an object of Model2 to Model1 as follows: Model1_Object.model2_set.add( model2_Object ) Now, I need to have some clean up done once the above takes place. So, i was considering overriding th

Hiding Referrer URL

2006-12-03 Thread Siah
Hi, I need to hide referrer url on HttpResponseRedirect. I was expecting to find something like ReferrerURL in HttpResponseRedirect.headers, but did not. I was hopping to change the header information right before HttpResponseRedirect sends the user to the other server to hide the referrer URL, o

Re: Django, Postgres and Server Crash

2006-10-16 Thread Siah
Per connection? Does it mean per request, or page view? I tried increasing the number of postgres connections, and it ended up completely killing the server. The server I'm working with has 2 django sites running, one of which receives around 3M hits a month. The other one somewhere around 200K h

Django, Postgres and Server Crash

2006-10-16 Thread Siah
Hello, I am running django on heavy load server, and multiple times a week I have my postgres crashing due to high server load. When I get TOP, I see many many postmasters running at the same time, until I get 'Too many connections' postgres failiour error from postmaster emailed to me from djang

Directional Many-to-many

2006-08-29 Thread Siah
Hello, Given this model: class Person(models.Model): name = models.CharField(maxlength=200) children = models.ManyToManyField('self') I can do: FatherObj.children.add(ChildObj) Somehow though, if I go to ChildObj and ask for its children, I will get the FatherObj as well. What am I

Re: Multiple copies of a Block in my Template

2006-08-12 Thread Siah
Thanks you guys. Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PRO

Multiple copies of a Block in my Template

2006-07-31 Thread Siah
I can think of instances where you would need multiple copies of a given block. For instance, I am want to show a page counter (Page 1, (2), 3, 4, 5, 6) both on top and bottom of my page. I had to use the {% include %} tag twice to load it. Except, I realized I want my template for both standard v

Re: New Django manage.py bugs

2006-05-25 Thread Siah
Thanks for the response adrian. Somehow I felt the result of Alter Table is not as efficient as properly creating the table in the first place. If I'm incorrect, that I think I am, your suggestion is actually very good and should make my life more efficient. I guess if I go with above, I don't h

New Django manage.py bugs

2006-05-25 Thread Siah
I am 7 months into coding a large django application. Due to needing extra bytea fields with my database, I started maintaining my own SQL instead of django-admin install app. Everytime I made changes to my model, I would take django-admin sqlall app and apply those changes. Its been a few days I'

Re: FYI: Primitive Python Version of GWT Working

2006-05-25 Thread Siah
Good work. Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED]

View Post Processing

2006-05-19 Thread Siah
Reviewing my own application, I realized there are much my view has to take care of that doesn't need to delay HttpResponse to the user. For instance, I need to - extract the newly uploaded PDF file to extract and index its text. - create PDF docs for new orders - Resize uploaded image, etc All

Re: Django time-zone chaos

2006-04-11 Thread Siah
John, I had the same problem and chose to ignore it. I think it might be a bug with Django. Regards, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to d

Re: What is Caching my DB

2006-04-01 Thread Siah
Thanks Michael, I did it all, non seems to help. Its wired that I am the only one with this problem. I am thinking of reconfiguring my site in hope of having this problem go away. Thanks, Sia --~--~-~--~~~---~--~~ You received this message because you are subscr

Re: What is Caching my DB

2006-03-28 Thread Siah
Thank you Michael, I must add that on my laptop using django's runserver command, this problem does not exist. Moreover, my settings.py middlewares are default installation and holds no information in regard to caching: MIDDLEWARE_CLASSES = ( "django.middleware.common.CommonMiddleware",

Re: What is Caching my DB

2006-03-27 Thread Siah
I don't think that's it. My django site is very generic. It has to be some sort of configuration I am missing. Any other ideas? Thanks, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. T

What is Caching my DB

2006-03-27 Thread Siah
I just launched my django site for a client. My problem is something is caching my db data in a bizzar way. Here are some of the behaviours I get: - I login, and every other page it makes me login again for a 5 minutes or so and then it remembers that I am logged in. - I add a record, it refl

Re: Strings and % sign fails - Help Please

2006-03-24 Thread Siah
I see. Thanks, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTE

Re: Strings and % sign fails - Help Please

2006-03-23 Thread Siah
heh.. It works except I am using psycopg.Binary(somebinarystructure), and I am not really doing it by hand to just add the extra %, and psycopg.Binary doesn't do it. I'd imagine it's a bug with psycopg package. Any quick way to project a string from freak '%' problems? Thanks, Sia --~--~--

Strings and % sign fails - Help Please

2006-03-23 Thread Siah
It seems like a freak problem to me. I spent a long hour to track the problem down and here it is: The following statement fails because it has the '%' sign in it. cursor.execute("select '%'") The error is: IndexError: list index out of range How do I address this problem? Please note that th

Re: Can/Should I place python objects in Django Session?

2006-03-07 Thread Siah
True, python objects are very useful all by themselves. I think I still can get away with DB objects, by regularly updating them, never using session DB objects for insert/update and even monitoring reads on what value is being used. I have not yet utilized the caching system as I thought it is i

Re: Can/Should I place python objects in Django Session?

2006-03-06 Thread Siah
Thanks John, It is extremely tempting to place objects in sessions though. I'm pretty sure I'll still use it to a safe extent. Thanks, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To p

Can/Should I place python objects in Django Session?

2006-03-06 Thread Siah
I used to think I can't and it is a bad practice to place objects (non-strings) in django sessions. I just realized I can, but I don't know if it's a good practice. Some feedback in this regard is appreciated, Thanks, Sia --~--~-~--~~~---~--~~ You received this

Re: Bug: On add_object created date is not retireved

2006-03-05 Thread Siah
Just incase I wasn't clear, in case I don't refresh the object the error indicates that it can't save the object with 'None' for its created date field. That is, when the object was added, its created date field was not populated. Sia --~--~-~--~~~---~--~~ You r

Bug: On add_object created date is not retireved

2006-03-05 Thread Siah
Hi, On the following model: class Object(meta.Model): created = meta.DateTimeField(auto_now_add=True) account = meta.ForeignKey(Account) title = meta.CharField(maxlength=200) ... When I do: new_object = account_obj.add_object(title='foo') My new_object.title=='foo' is True, but

Re: To Truncate a Word to # of chars

2006-02-26 Thread Siah
emm.. But wait a sec! How do I call a python function from django template. I don't think it is allowed, meaning that I'd still have to write a filter using textwrap: >>> wrap('siasookhteh', 5) ['siaso', 'okhte', 'h'] Sia - --~--~-~--~~~---~--~~ You received thi

Re: To Truncate a Word to # of chars

2006-02-26 Thread Siah
Thanks David. I did feel there should be a way to do this since it seems common enough. I'll read up on textwrap now, Regards, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to th

To Truncate a Word to # of chars

2006-02-26 Thread Siah
Hi, I noticed there is no filter to truncate a string to a given number of characters as apposed to just words. It can be useful. For instance I am trying to show contact list that includes email addresses, and given that some people have bizarrely long emails, I'd like to limit it to some value.

How to iterate through form object in template

2006-02-17 Thread Siah
Hi, I will be creating my custom manipulator dynamically, so I don't know what fields I have, and I simply want to iterate through them in my templates? Doing a simple: {% for a in form %} {{ a}} {% endfor %} doesn't work... Any ideas? Thanks, Sia --~--~-~--~~~--

Re: Simple Import Module Question

2006-02-17 Thread Siah
Thanks for the help. I figured if I place the module out of my myproject directory, I can import it. I'll do that for now until 9.2 comes out. Regards, Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django u

Simple Import Module Question

2006-02-16 Thread Siah
Probably simple, but this is a problem I cannot figure out. Under my django project directory I have a folder called 'utility': - myproject - urls.py - settings.py - manage.py - __init__.py - apps - - polls - utility __init__.py utilityfunction

Re: DB.cursor doesn't work properly

2006-02-16 Thread Siah
Reading up on transaction, I figured I have to commit it, except cursor.commit() gives me this error: Error: serialized connection: cannot commit on this cursor Any ideas? Sia --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

DB.cursor doesn't work properly

2006-02-16 Thread Siah
Hi, Some may call this a feature, I call it a bug: If I do: cursor = db.cursor() cursor.execute("insert into tablename values(5,'somename')") It will work without giving me an error. Even if I run a select statement within the same session, it would confirm that that record was entered. But, my

Re: Multiple Database & 1 Django

2006-02-13 Thread Siah
Russ, I see the priorities. I'm going to go ahead with a single db for now, hopefully by the time I launch it the feature is out and I would rework some of the necessary changes. Thanks, Sia

Multiple Database & 1 Django

2006-02-12 Thread Siah
Hi, I am aware that there is a ticket for it: http://code.djangoproject.com/ticket/1142 I was wondering if the wrapper was small enough that can be squeezed by in version 9.2 or anytime soon as I am in desperate need to use it. Specifically, to separate cheap data from expensive data. Thanks fo

Re: Deleting ForeignKey Delets my Object!

2006-02-09 Thread Siah
Jonathan, Don't be unkind to my schema. I enjoyed your blog though. Sia

Re: Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah
Please excuse the lack of applicability for this example. It was meant to serve as an example, apparently not a good one. In my database, I have tons of such relationships. I have a Person model having foreign keys to django authentication user model, to the current branch he resides (a foreignke

Re: Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah
The title should say: deletes, not delets

Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Siah
Hey Todd, I am working on a large web app with django and backward incompatibility issues shows up on my nightmares from time to time. I would say start your app with the latest version of SVN and always keep it updated. On every SVN update read backward incompatible changes (http://code.djangop

Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah
Hi, I have a model similar to: class Phone(meta.Model): number = meta.CharField(maxlength=50, null=True) class Contact(meta.Model): phone = meta.ForeignKey(Phone, null=True) name = meta.CharField(maxlength=200) After I have data in, I want to be able to delete a contact's phone. As

Re: Placing urlpatterns inside view files

2006-02-03 Thread Siah
Thanks Adrian. My main concern was with speed, and I'm glad that's not the case. Regards, Sia

Placing urlpatterns inside view files

2006-02-03 Thread Siah
Hi, I have lots of views. So, I separated them into sections. I want to package them together with the views they are associated with. Is it incorrect design decision to place my URLs in the same file as my View? Does it make it any slower? What about my manipulators + views + URL in the same fil