* Christoph H. Larsen: " [Mayan EDMS: 882] Re: Using python functions within
  Mayan EDMS" (Wed, 8 Oct 2014 03:36:12 -0700 (PDT)):

Hi Chris,

did you have a look at:

https://github.com/mayan-edms/mayan-edms/pull/58

Cheers,
Mathias

> Dear Roberto, dear Gary,
> 
> I thought I posted a reply earlier today but it seems it did not get 
> through. If it did, my apologies for double-posting.
> Due to my lack of in-depth experience with Django, I beg for some more 
> detailed information how to get Python functions working with automatic 
> metadata.
> Here is a use case:
> I plan to have time-constrained documentation sitting inside Mayan EDMS, 
> such as warranty certificates, or performance verification certificates, 
> which are valid for only N days.
> Ideally, the "Valid through" metadata should automagically calculate a 
> default expiry date from different metadata, e.g. purchase date, or 
> revision date. 
> Also, it would of course be great to then automatically change flags from 
> green to yellow, or whatever.
> This needs a wee bit of Python magic (which I am OK with on the Python 
> side) with the default metadata as a function. But how can I, as Django 
> dummy, implement this (step by step) inside Mayan EDMS.
> Thanks a million!
> 
> Chris
> 
> 
> On Wednesday, 10 September 2014 16:26:09 UTC+3, Gary D Walborn wrote:
> >
> > Roberto,
> >
> >   Thanks.  I should have mentioned that I figured that out the other day 
> > by looking at the source code.   Be aware that the current code does not 
> > override "__builtins__", so it is possible to enter code in the LOOKUP area 
> > to do anything that you want.  For example,
> >
> > __import__('my_custom_module').my_function()
> >
> > I think that is probably not intended, but it works.
> >
> > Gary W. 
> >
> > On Tuesday, September 9, 2014 2:22:12 PM UTC-4, Roberto Rosario wrote:
> >>
> >> Create you own custom settings.py file in mayan/settings directory:
> >>
> >> # my_settings.py file
> >> from my_custom_module import my_function
> >>
> >> METADATA_AVAILABLE_MODELS = {'my_function': my_function}
> >>
> >> and launch Mayan with --settings=mayan.settings.my_settings.py
> >>
> >> now my_function should be available in the namespace of your metadata 
> >> lookup snippets.
> >>
> >>
> >> On Tuesday, September 9, 2014 8:59:02 AM UTC-4, Gary D Walborn wrote:
> >>>
> >>> I found a work-around for this, but I think it is also a huge security 
> >>> hole in Mayan-EDMS.  I think I'll use it, but it will probably go away
> >>> when (if) the security hole is fixed. :-(  
> >>>
> >>> On Thursday, September 4, 2014 3:48:38 PM UTC-4, Gary D Walborn wrote:
> >>>>
> >>>> I have written a python function (lets call it 'options') that returns 
> >>>> a list of strings.  I would like to use this function to populate the 
> >>>> drop-down lists in a metadata type.  I have tried all sorts of ways to
> >>>> do this, and none of them seem to work.  The documentation is very scant
> >>>> on this subject.  Can anyone provide any information on how this is
> >>>> supposed to work?
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Gary Walborn
> >>>>
> >>>>
> 



-- 

    Mathias Behrle
    PGP/GnuPG key availabable from any keyserver, ID: 0x8405BBF6

Attachment: signature.asc
Description: PGP signature

Reply via email to