Hi im currently trying to get a value from my view and store it in a global variable declared in my hub.
so that i can use it throughout my hub
however i have no idea how to sen the value from my view to the hub and store it in a variable in my hub
using Signal R
Example:
View: value=1
hub: int id
I am not sure I quite follow your question, but you can simply from your View call a method on a SignalR client and pass the value as a parameter. Server side, from within the handling method for the call, you could set the global variable in your hub?
Louis
Related
I would like to use an api key stored in an environment variable. I know I can just put it directly in the html (I don't think it is bad security wise since it is a public key). But I can't get access it an my react component.
useEffect(()=>{
SetRecaptchaKey(import.meta.env.VITE_SITE_RECAPTCHA_KEY);
console.log(recaptchaKey)
});
outside my component function (above) I have this:
const key = import.meta.env;
console.log(key)
it logs the object in the console, and it has the variable i'm looking for.
Another thing, is that I have two VITE_... variables and another variable. Only one of VITE_.. is loaded (which is what I want) but I don't understand why.
Thanks in advance
In order to use an environment variable in client side Astro, you need to prefix the variable with "ASTRO_". For example, if you have an environment variable named "TEST_VAR", you would access it in client side Astro as "ASTRO_TEST_VAR".
https://www.twilio.com/docs/studio/widget-library#run-function
When you invoke a Function, you have two possible options for using variables: (1) you can pass Flow variables as parameters into a Function (e.g. flow.data.foo), and (2) you may set Flow variables with data returned from the Function (TwiML or JSON can be returned).
Does anyone know how to set Flow variables with data returned from a Function?
You should be able to follow the Liquid Syntax documented here, to do so.
Liquid Template Language - Assigning Variables
https://www.twilio.com/docs/studio/user-guide/liquid-template-language#variable-assignment
Or just call the returned variable by addressing the Function widget as shown at the link below:
https://www.twilio.com/docs/studio/widget-library#run-function
widgets.MY_FUCTION_WIDGET_NAME.parsed.xxxxx (where xxxxx is the JSON path).
Alan
I want to know if the POST /message function of the Camunda REST API is updating process instance variables or does I have to update variables using the Update/Delete Process Variable function before sending a message ?
Camunda REST API :
Message reference : http://docs.camunda.org/latest/api-references/rest/#message-deliver-a-message
Update/Delete Process Variable reference : http://docs.camunda.org/latest/api-references/rest/#process-instance-updatedelete-process-variables
I just found the answer : The Message function is correctly updating the process instance variables.
Is there a way to either create a new Environment Variable from within a WF 4.0 workflow or update an existing one if it already exists?
You can set a enviroment variable inside an code activity.
You can use the System.Activities.Statements.InvokeMethod activity to call the System.Environment.SetEnvironmentVariable static method.
In the Parameters setting, you'll need to pass 2 'In' parameters. The first will be the name of your environment variable, the 2nd will be the value.
I need a global variable that I can call from the templates.
I edited app_globals.py in lib directory to declare PATH_TO_IMAGES like this
class Globals(object):
"""Container for objects available throughout the life of the application.
One instance of Globals is created during application initialization and
is available during requests via the 'app_globals' variable.
"""
PATH_TO_IMAGES = ""
def __init__(self):
"""Do nothing, by default."""
pass
Now I can call from any template the image path like this
<img src="${g.PATH_TO_IMAGES}/${p.image}" />
The image path is stored inside a settings table on the app's database, but I can't initialize it from Globals declaration, i get this error:
sqlalchemy.exc.UnboundExecutionError:
Could not locate a bind configured on
mapper
Mapper|Settings|settings,
SQL expression or this Session
My guess is that database binding happens after Globals is initialized. So my questions is, which is the best place to initialize a global variable in TurboGears 2 and which is the best practice to that.
Just use a cached property:
class Globals(object):
"""Container for objects available throughout the life of the application.
One instance of Globals is created during application initialization and
is available during requests via the 'app_globals' variable.
"""
#property
def PATH_TO_IMAGES(self):
try:
return self._path_to_images
except AttributeError:
self._path_to_images = db_session.query(XXX) # Fill in your query here
return self._path_to_images
PS : your question is a generic Python question really. I suggest you read the official Python docs before posting other similar questions.
You probably need to create your own database connection to get this data from the database.
In SQLAlchemy terms, you'll want to create your own engine, session, etc. Just make sure to clean up after you're done.
I would probably do this in app_cfg.py using on_startup to get it into the config, and then stick it in the Globals object later on if you still need to.
You may set PATH_TO_IMAGES to it's definite value once the models are initialized. The sooner being at the end of the 'init_model' function declared in model/init.py.