On Oct 28, 2:44 am, "Ted Gifford" <[EMAIL PROTECTED]> wrote:
> Random number, perhaps?http://www.python.org/doc/2.5.2/lib/module-random.html
A random number is much less unique than a incremented number, because
you have
the chance - even if it's a very small one - that you get the number
twice.

> I'm wondering if you actually need the ID, or if it just makes it more
> convenient to write some javascript or something. How do you use it?
I need the ID for javascript, in order to call getElementById on it.
Because the macro could get used twice on the same wiki page I need
unique IDs.

I now implemented it with a class integer variable which gets
incremented every time the macro is called - which works ok so far.
Because it isn't reset (as long trac isn't restarted) there might be
in theory an overrun after a long runtime, which should be ok.

Martin


> > Hi,
> > I'm writing on a macro for trac 0.11 and have to return a div tag with
> > an HTML id attribute. This have to be unique per HTML page, so I can't
> > use a fixed predefined string, e.g. the macro name, because this would
> > produce problems when the macro is used twice on the same wiki page.
>
> > My first idea is to put the macro arguments through an hash algorithm,
> > e.g. MD5, and use this and the macro name as id. This allows for
> > multiple macro calls with different arguments, but still produces an
> > invalid HTML output (i.e. multiple indentical IDs) if the macro is
> > called with the same arguments twice.
>
> > My knowledge of the trac  API  and python itself is limited, so I need a
> > little help here.
> > Is there something in the trac environment which is unique for every
> > single macro call on a wiki page? Maybe the position or something like
> > this.
>
> > Could I just introduce a class variable which counts up every time the
> > macro is called and use this as part of the ID?
>
> > Thanks in advance for your help.
> > Martin
>
> --
>           +                       -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
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/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to