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.execute("select '%';")
print cursor.fetchall()

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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

2008-10-19 Thread Siah

Thank you!
Sia

On Oct 19, 5:20 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
> In the compilation function of your template tag, you can force the  
> parser to parse until tag named "endyourcustomtag" by calling nodelist  
> = parser.parse(("endyourcustomtag", ). This will return the contents  
> of your block tag as a list of nodes. Finally you can "drop off" the  
> end tag by calling parser.delete_first_token() because parser.parse  
> left the parser in a state where "endyourcustomtag" is still unparsed.
>
> Find a find 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 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 customTag implementation, have 'hello' as a parameter.
>
> > Thanks for all the help in advance,
> > 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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 customTag implementation, have 'hello' as a parameter.

Thanks for all the help in advance,
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 cookie
with dynamically setting this variable?

-- side note: My localhost cannot hold cookies as soon as
SESSION_COOKIE_DOMAIN variable is set with a starting dot. Ideally
django would take care of it. Not sure if I must file a ticket for it.

Thanks Everyone,
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need a Middleware to select urlpatterns

2008-06-06 Thread Siah

Very cool! Worked as promised.
Thank you,
Sia

On Jun 6, 1:46 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> You can set `urlconf`(plain string - path to the needed urlconf)
> attribute to request object that is passed into `process_request`.
> Then django will use it not default.
>
> 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 should mean there must be a
> > way for me to tell django to use a different urlpatterns. I checked on
> > CommonMiddleware that does a bit of url-rewriting and found it does a
> > HttpResponsePermenentRedirect and not change the actual url in place
> > which seems odd to me as I expected the middleware to rewrite the URL
> > in place.
>
> > Thanks for all the help and your super framework,
> > 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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 does a bit of url-rewriting and found it does a
HttpResponsePermenentRedirect and not change the actual url in place
which seems odd to me as I expected the middleware to rewrite the URL
in place.

Thanks for all the help and your super framework,
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 how it was done is not easy to understand.

To state it simply again: How does django know the PK of the object it
just saved, given it is the server that sets the PK?

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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

2007-09-23 Thread Siah

My examples was faulty. Sorry. I meant after you save the object for
the first time, that is:

obj = Product(name='Apple')
obj.save()

At this point obj has an ID in it. How does it know that ID?

A SQL statement similar to the following must be generated:
insert into product_table (id, name) values(next_sequence, 'Apple');

But that SQL statement doesn't return its generated ID. Is it that
Django first gets the next ID in sequence and then uses it in insert
or it retrieves it in a different way.

As Alex mentioned above, if there is a select statement, what could it
be? (Select id from product_table where name='Apple') doesn't seem
plausible.

Once again, I have an AFTER trigger that sets my PKs from a different
table and need to understand how django does it, so I can understand
how to approach my own problem,

Thanks again,
Sia


On Sep 23, 5:58 pm, Richard Dahl <[EMAIL PROTECTED]> wrote:
> Actually,
> from the db-api documentation.
>
> "To create an object, instantiate it using keyword arguments to the
> model class, then call save() to save it to the database. ...
>
> ... Django doesn't hit the database until you explicitly call save()."
>
> The code:
> obj = Product(name='Apple')
>
> obj.id  will not be set until you either explicitly set it, or call
> save(), at which time django will utilize the lack of a pk (among
> other things) to determine whether 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:00, Siah <[EMAIL PROTECTED]> wrote:
> >> 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 trying to understand how I can integrate them.
>
> >> 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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 trying to understand how I can integrate them.

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 the add method or adding decorators.
However, I have no idea how to do that as the whole model2_set class
is manufactured by django.

Please help me with the above,
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]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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, or even change it to somethings else.

How can I accomplish that?

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 hits, but I do much datawarehousing on the
same server using Django API.

Django really takes care of closing the connections, so do I have to
really worry about that?

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 django.

How many postmaster instances should be running at once?

There isn't much happening differently in terms of load on the days
that the server is crashing to the days that the server is working
smoothly.

Here is my top:

Tasks: 665 total,  10 running, 655 sleeping,   0 stopped,   0 zombie
Cpu(s): 14.9% us, 16.7% sy,  0.0% ni,  0.0% id, 68.4% wa,  0.0% hi,
0.0% si
Mem:   2074932k total,  2051572k used,23360k free, 2736k
buffers
Swap:  2096440k total,  188k used,   251992k free,   102968k cached

  PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEMTIME+  COMMAND
 6420 postgres  15   0 26912  11m  10m R  3.6  0.6   0:00.11 postmaster
 6565 postgres  16   0 26912  11m  10m S  3.6  0.6   0:00.12 postmaster
 6707 postgres  15   0 26912  11m  10m S  3.3  0.6   0:00.10 postmaster
 6715 postgres  15   0 26912  11m  10m S  3.3  0.6   0:00.11 postmaster
 6765 postgres  15   0 26912  11m  10m S  3.3  0.6   0:00.11 postmaster
 6147 postgres  15   0 26912  11m  10m R  3.0  0.6   0:00.15 postmaster
 6311 postgres  15   0 26904  11m  10m R  3.0  0.6   0:00.10 postmaster
 6551 postgres  15   0 26912  11m  10m R  3.0  0.6   0:00.09 postmaster
 6803 postgres  16   0 26912  11m  10m R  3.0  0.6   0:00.09 postmaster
 6255 postgres  15   0 26904  11m  10m R  2.6  0.6   0:00.14 postmaster
 6357 postgres  15   0 26912  11m  10m R  2.6  0.6   0:00.11 postmaster
 6455 postgres  15   0 26912  11m  10m S  2.6  0.6   0:00.10 postmaster
 6457 postgres  15   0 26912  11m  10m S  2.6  0.6   0:00.11 postmaster
 6276 postgres  15   0 26912  11m  10m S  2.3  0.6   0:00.10 postmaster
 6475 postgres  15   0 26912  11m  10m R  2.3  0.6   0:00.11 postmaster
 6868 postgres  15   0 26912  11m  10m S  2.3  0.6   0:00.07 postmaster
 6891 postgres  15   0 26912  11m  10m S  1.3  0.6   0:00.19 postmaster


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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 doing wrong?

In my real example, the childObj can have many parent nodes, thus
many-to-many is required.

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 view and search result, and that got all too nasty.

So, I think if we could do something like
{% block foo %}
some html
{% endblock %}


{% PasteBlock foo %}

{% PasteBlock foo %}

That would be great.
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 have to cry over 'init' again, and
thanks for the quick tutorial on install django_apps.

In terms of broken pieces. My sqlall worked fine right now, but my
sqlclear generates something like this:
...
ALTER TABLE "ss_accountinfo" DROP CONSTRAINT
"bill_address_id_referencing_ss_address_id";
...

that gives me this error:

ERROR:  constraint "bill_address_id_referencing_ss_address_id" does not
exist

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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've been trying to upgrade my django from 9.1 to
9.2. My biggest problem so far is how broken sqlall and sqlclear are.

sqlall generates sql with tables out of order, thus my postgresql
cannot create constraints. And sqlclear generates non-working sql.

Furthermore, I needed django-admin init that would create initial
tables before I manually add my own tables. Please give it back to me.

What could make my day would be if there was a way for me to supply an
alternate 'sql' for the CREATION of that specific model. It would save
me a lot of time not going through my gizilioon tables everytime I made
a change.

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 of which do not need the user to wait around for the process. I was
thinking to run those processes on a second thread as the view, but I
wasn't sure if it's a good practice. So, I was thinking it would be
ideal if Django can provide some sort of post processing features
either within the same function (instead of returning HttpResponse, you
call it) or a secondary function that is called when the view returns.

I'd appreciate ideas,
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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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",
"django.middleware.sessions.SessionMiddleware",
"django.middleware.doc.XViewMiddleware",
)

I am still stock, so all help is greatly appreciated,
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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 reflects it to the site in close to 5 minutes from

now
- Every other DB related change takes some time to reflect


My temporary domain is (a #  # a# r #m # i #n   d o t##c o# m).
Please remove (#, space, and replace dot with .). To see this for
yourself login to the site by going to /admin/ with username and
password: django 


Thanks, 
Sia 


ps. django rocks


--~--~-~--~~~---~--~~
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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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


--~--~-~--~~~---~--~~
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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 the following work just fine:
cursor.execute("select 'x'")

and the following also fails with the same error:
cursor.execute("""select '%'""")
cursor.execute("select '\%'")

astr = "select '\%'"
cursor.execute(astr)

I greatly appreciate all helps,
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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 ideal for
write once and read many times news-site type of applications. I don't
know how much of my basecamp type application can be cached given that
it is an interactive app with random read and writes.

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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 it's new_object.created date is
None. So, if I continue to do:

new_object.title='bar'
new_object.save()

I will recieve an error. I currently do:

new_object = objects.get_object(pk=new_object.id)

Just to refresh my new_object and be able to save it again if needed.

Best 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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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.

Please let me know if this feature is available, or else I'll find out
how to implement it as a filter myself. 

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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


--~--~-~--~~~---~--~~
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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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
  utilityfunctions.py

When I try to import utilityfunctions.py from my python console using
the following command, it works just fine:

from myproject.utility.utilityfunctions import *

However, once I place this good looking import command inside my
myproject/apps/polls/models/polls.py it gives me error (ImportError: No
module named utility.utilityfunctions)once I try to import the models
in using:

from django.models.polls import *

What is my problem?

Thanks for your help in advance,
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 django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 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]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 postgresql is not really updated. If I run the
same select statement it would have no recollection of such record what
so ever. As soon as I reset my python session, the data disappears.

What is the problem? Do I have to commit the data? How come there is no
documentation for it?

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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



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 for the great framework,

Regards,
Sia



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 foreignkey to branch), etc. They aren't
necessarily meant to represent 1-many relationship, rather, just
pointing to another object data.

Thanks,
Sia



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.djangoproject.com/wiki/BackwardsIncompatibleChanges),
address them on spot and let your application evolve with it.

Best of luck,
Sia



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
soon as I remove phone, it will automatically delete my contact object
too. This would make sense with poll/choice, but not everywhere. What
is the magic keyword for me to ask it to stop messing with me. :)

contacts.get_list()[0].get_phone().delete()

Thanks,
Sia



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 file? Notice that these view files are relatively short, since
they represent pieces of the software.

I am not a big fan of too many files; it makes the whole show a bit too
confusing :)

Thanks,
Sia

"Make everything as simple as possible, but not simpler."  --  Albert
Einstein